Write a Commit Message
Purpose
Produce a commit message that a reviewer, a future maintainer running history search, and release tooling can all use: a scannable subject, the reasoning behind the change, and machine-readable signals for versioning and changelogs.
When to use
- A diff or change description is ready and needs a commit message.
- A staged change mixes concerns and should be split into several commits.
- A team adopts Conventional Commits and wants messages that drive automated versioning or changelogs.
When not to use
- Describing a whole branch for reviewers. Use
pull-request-description.
- Writing user-facing release history. Use
changelog-entry or release-notes.
Inputs
Required:
- The diff, or a precise description of what changed.
Optional, improves quality:
- The reason for the change (bug, requirement, incident, refactoring goal).
- Work item or issue ID, team scope names, whether the change is breaking.
- Team conventions (allowed types and scopes, subject length, sign-off rules).
If neither a diff nor a description is given, ask for one. If the reason is missing, write the body with a [TBD: why] placeholder instead of guessing.
Process
- Read the change and list each logical modification. If they serve unrelated purposes (e.g., a feature plus an unrelated rename), recommend separate commits and write one message per commit.
- Choose the type:
feat, fix, refactor, perf, test, docs, build, ci, chore, revert, style. Pick by user-visible effect, not by file types touched.
- Choose an optional scope from the module or bounded context affected, using the team's existing scope names when known.
- Write the subject: imperative mood, lowercase after the colon, no trailing period, at most ~50 characters (hard limit 72). It says what the commit does, not what the developer did.
- Decide whether the change is breaking (public API, schema, config key, message contract, CLI flag). If so, add
! after the type/scope and a BREAKING CHANGE: footer with migration guidance.
- Write the body, wrapped at 72 columns: the problem or motivation, why this approach, notable side effects or trade-offs. Do not restate the diff line by line.
- Add footers:
Refs: or Closes: with work item IDs, Co-authored-by: if pairing, and any required sign-off.
- Check that the message contains no secrets, customer data, internal hostnames or credentials copied from the diff.
- If the user continues toward review or release, suggest
pull-request-description for the branch, changelog-entry for user-facing history, or semantic-versioning when a breaking change affects the next version number.
Output format
<type>(<scope>)<!>: <imperative subject, <=50 chars>
<why: problem or motivation, 1-3 sentences>
<how / trade-offs worth knowing, optional>
BREAKING CHANGE: <what breaks and how to migrate> (only if breaking)
Refs: <work item ID or [TBD]>
If splitting is recommended, list each proposed commit with the files or hunks it contains, followed by its message.
Quality checklist
Common pitfalls
- Vague subjects such as "fix bug" or "update code". Name the behavior: "fix: reject expired tokens in refresh flow".
- Labelling a behavior change as
refactor. A refactoring changes no observable behavior; otherwise it is feat or fix.
- Hiding a breaking config or contract change in a
chore. Release tooling will then publish it as a patch.
Example
Input: "Added exponential backoff retry (3 attempts) to PaymentClient; renamed config key payment.timeOut to payment.timeout."
Weak: fix: update payment stuff — mixes two changes, hides a breaking rename, no why.
Strong, excerpt of output (split into two commits):
fix(payment)!: rename timeout config key to payment.timeout
The old key was misspelled and silently ignored, so the client
always used the 100 s library default.
BREAKING CHANGE: rename `payment.timeOut` to `payment.timeout`
in every environment config before deploying.
Refs: [TBD]
feat(payment): retry transient failures with exponential backoff
1---2name: commit-message3description: "Writes a commit message in Conventional Commits format with a precise subject, a body that explains why the change was made, and footers for breaking changes and work item references. Use when a developer has a diff, a list of changes or a short description and needs a commit message, or wants to split a mixed change into well-scoped commits."4license: MIT5metadata:6 source: https://skillmd.com/skills/muratdincer/commit-message7 version: "1.0.0"8 language: en9 category: 05-engineering10 role: developer11 area: collaboration12 title: "Write a commit message"13 related: "pull-request-description, changelog-entry, semantic-versioning, branching-strategy"14 prompt: "Write a commit message for this diff. It adds retry with backoff to the payment client and fixes the timeout config key name."15---1617# Write a Commit Message1819## Purpose20Produce a commit message that a reviewer, a future maintainer running history search, and release tooling can all use: a scannable subject, the reasoning behind the change, and machine-readable signals for versioning and changelogs.2122## When to use23- A diff or change description is ready and needs a commit message.24- A staged change mixes concerns and should be split into several commits.25- A team adopts Conventional Commits and wants messages that drive automated versioning or changelogs.2627## When not to use28- Describing a whole branch for reviewers. Use `pull-request-description`.29- Writing user-facing release history. Use `changelog-entry` or `release-notes`.3031## Inputs32Required:33- The diff, or a precise description of what changed.3435Optional, improves quality:36- The reason for the change (bug, requirement, incident, refactoring goal).37- Work item or issue ID, team scope names, whether the change is breaking.38- Team conventions (allowed types and scopes, subject length, sign-off rules).3940If neither a diff nor a description is given, ask for one. If the reason is missing, write the body with a `[TBD: why]` placeholder instead of guessing.4142## Process431. Read the change and list each logical modification. If they serve unrelated purposes (e.g., a feature plus an unrelated rename), recommend separate commits and write one message per commit.442. Choose the type: `feat`, `fix`, `refactor`, `perf`, `test`, `docs`, `build`, `ci`, `chore`, `revert`, `style`. Pick by user-visible effect, not by file types touched.453. Choose an optional scope from the module or bounded context affected, using the team's existing scope names when known.464. Write the subject: imperative mood, lowercase after the colon, no trailing period, at most ~50 characters (hard limit 72). It says what the commit does, not what the developer did.475. Decide whether the change is breaking (public API, schema, config key, message contract, CLI flag). If so, add `!` after the type/scope and a `BREAKING CHANGE:` footer with migration guidance.486. Write the body, wrapped at 72 columns: the problem or motivation, why this approach, notable side effects or trade-offs. Do not restate the diff line by line.497. Add footers: `Refs:` or `Closes:` with work item IDs, `Co-authored-by:` if pairing, and any required sign-off.508. Check that the message contains no secrets, customer data, internal hostnames or credentials copied from the diff.519. If the user continues toward review or release, suggest `pull-request-description` for the branch, `changelog-entry` for user-facing history, or `semantic-versioning` when a breaking change affects the next version number.5253## Output format54```markdown55<type>(<scope>)<!>: <imperative subject, <=50 chars>5657<why: problem or motivation, 1-3 sentences>58<how / trade-offs worth knowing, optional>5960BREAKING CHANGE: <what breaks and how to migrate> (only if breaking)61Refs: <work item ID or [TBD]>62```63If splitting is recommended, list each proposed commit with the files or hunks it contains, followed by its message.6465## Quality checklist66- [ ] One logical change per commit; mixed changes are flagged with a split proposal.67- [ ] Type reflects the effect (`fix` vs `refactor` vs `perf`) and matches team conventions.68- [ ] Subject is imperative, specific and within the length limit.69- [ ] Body explains why; nothing in it can be read directly from the diff alone.70- [ ] Breaking changes are marked both with `!` and a `BREAKING CHANGE:` footer.71- [ ] No invented issue IDs; unknown references are `[TBD]`.72- [ ] All checks pass; if any fails, revise the output and re-run this checklist before answering.7374## Common pitfalls75- Vague subjects such as "fix bug" or "update code". Name the behavior: "fix: reject expired tokens in refresh flow".76- Labelling a behavior change as `refactor`. A refactoring changes no observable behavior; otherwise it is `feat` or `fix`.77- Hiding a breaking config or contract change in a `chore`. Release tooling will then publish it as a patch.7879## Example80Input: "Added exponential backoff retry (3 attempts) to PaymentClient; renamed config key `payment.timeOut` to `payment.timeout`."8182Weak: `fix: update payment stuff` — mixes two changes, hides a breaking rename, no why.8384Strong, excerpt of output (split into two commits):85```86fix(payment)!: rename timeout config key to payment.timeout8788The old key was misspelled and silently ignored, so the client89always used the 100 s library default.9091BREAKING CHANGE: rename `payment.timeOut` to `payment.timeout`92in every environment config before deploying.93Refs: [TBD]94```95```96feat(payment): retry transient failures with exponential backoff97```