Writing commit messages
Process
- Read the staged diff (
git diff --cached), not just file names. - Identify the type: feat, fix, refactor, docs, test, chore.
- Write a subject line:
type(scope): summary, imperative mood, under 72 chars. - Only add a body if the diff needs context a reviewer wouldn't infer from the code — the reason for the change, not a restatement of what changed.
Template
type(scope): short imperative summary
Optional body explaining why, not what — only if non-obvious.
Avoid
- Listing every changed file in the body (the diff already shows that).
- Vague subjects like "fix bug" or "update code" — name the actual bug/change.
- Mixing unrelated changes into one commit message — flag it instead of summarizing both.