Git Commit Formatter
Overview
Generate a commit message that matches repository conventions and accurately summarizes code changes. Detect style first, then produce one final message candidate plus optional alternatives only when requested.
Workflow
- •Detect the expected format from repository signals.
- •Summarize the real intent of the change from diffs, not filenames alone.
- •Produce a message with strict structure and length constraints.
- •Validate against local conventions and rewrite once if needed.
Detect Format
Check in this order and follow the first clear signal:
- •
.git/COMMIT_EDITMSGrecent style (if available) - •
commitlint.config.*,.commitlintrc*,lefthook.yml,.husky/* - •
package.jsonscripts/tools mentioning commitlint or cz - •Recent
git log --onelinepattern
If no clear convention is detected, default to Conventional Commits.
Build Message
Use this template unless repo rules differ:
text
type(scope): subject body footer
Apply these rules:
- •
type: choose the smallest accurate type (feat,fix,refactor,docs,test,chore,build,ci,perf,style) - •
scope: include only if clear and stable (package/module/domain) - •
subject: imperative, present tense, no trailing period, target <= 50 chars - •
body: explain why and what changed; wrap around 72 chars - •
footer: includeBREAKING CHANGE:and issue links when applicable
Mapping Heuristics
Use these defaults when intent is ambiguous:
- •Bug correction with behavior change:
fix - •New user-visible behavior:
feat - •Behavior-preserving cleanup:
refactor - •Test-only updates:
test - •Tooling/dependency/build-only:
choreorbuildorci - •Comment/readme/docs-only:
docs
Prefer correctness over verbosity. If multiple logical changes are mixed, propose split commits.
Output Contract
Return:
- •Final commit message in a single fenced block.
- •Short rationale (1-3 lines) mapping diff to
type/scope. - •If uncertainty is high, ask one focused question; otherwise choose best default.
Do not include git commands unless explicitly requested.