All articles

Letting Claude Write Your Commit Messages

Writing a good commit message takes a moment of thought most of us would rather spend elsewhere. Claude Code can read your staged diff and draft one for you, so you review instead of write from scratch.

Stage first, then ask

Stage the changes you want in the commit, then ask Claude to summarize them. It runs git diff --staged itself and turns the result into a message.

git add -p
claude "Write a commit message for the staged changes. Keep the subject under 50 characters and add a short body explaining why."

Because Claude reads the actual diff, the message describes what changed rather than what you meant to change. That gap is where most vague commits come from.

Keep your conventions in CLAUDE.md

If your team follows a format, write it down once in CLAUDE.md so every session applies it. For example, a rule like "prefix each commit subject with the ticket number from the branch name" means Claude infers AX-123 from a branch called AX-123-fix-login without being told each time.

Review before it lands

Treat the draft as a first pass, not a final answer. Read it, tweak the wording, and only then commit. A safe pattern is to let Claude propose the message and run the commit while you watch, or to have it print the message so you paste it yourself.

claude "Draft a commit message for the staged changes and show it to me. Do not commit yet."

Keep commits small and focused. A tight, single-purpose diff gives Claude less to summarize and gives you a message that actually means something when you read the log six months later.

Comments

Be the first to comment.