Commit Writer
Generate clear, standardized Git commit messages following the Conventional Commits specification. Produces machine-readable messages that work with semantic versioning, changelog generators, and CI pipelines.
Quick Reference
| Situation | Command / Action |
|---|---|
| Need commit from staged changes | Run git diff --cached --stat + git diff --cached |
| Need commit from all changes | Run git diff --stat + git diff |
| Need recent history context | Run git log --oneline -5 |
| Amend last commit | Use git commit --amend (confirm with user first) |
Conventional Commits Format
<type>(<scope>): <subject>
<body>
<footer>
Type Reference
| Type | When to Use | Example |
|---|---|---|
feat |
A new feature | feat(auth): add OAuth2 login flow |
fix |
A bug fix | fix(parser): handle empty input edge case |
docs |
Documentation only | docs: fix typo in README |
style |
Formatting, missing semicolons, etc. (no production code change) | style: format with prettier |
refactor |
Code restructuring (no feature/fix) | refactor(api): extract validation middleware |
perf |
Performance improvement | perf(db): add index on user email column |
test |
Adding or fixing tests | test(api): add endpoint integration tests |
build |
Build system or dependencies | build: bump lodash to 4.17.21 |
ci |
CI/CD configuration | ci: add GitHub Actions release workflow |
chore |
Maintenance, tooling, config | chore: configure ESLint |
revert |
Revert a previous commit | revert: feat(auth): add OAuth2 login flow |
Subject Rules
- Maximum 50 characters (hard limit: 72)
- No period at the end
- Imperative mood ("add" not "added" / "adds")
- Lowercase after type/scope, not capitalized
Scope
Optional but recommended when the change is localized:
- Feature name:
feat(auth),fix(checkout) - Module name:
refactor(database),perf(api) - Area:
docs(readme),test(e2e)
Breaking Changes
Append ! after type/scope or add a BREAKING CHANGE footer:
feat(api)!: remove deprecated v1 endpoints
Migrate to v2 endpoints. See migration guide.
BREAKING CHANGE: v1 API endpoints removed. Use /api/v2/* instead.
Body
Use when the subject alone is insufficient:
- Why the change was made (not what — the subject covers that)
- How it differs from the previous behavior
- Bullet points for multiple motivations (use
-)
feat(cart): add quantity validation
- Prevent checkout with zero-quantity items
- Show inline error per line item
Footer
For issue tracking and breaking changes:
BREAKING CHANGE: <description>— breaking change noticeCloses #123,Fixes #456— issue referencesRefs #789— related issueCo-authored-by: Name <email>— collaborators
Analysis Process
When generating a commit message from a diff:
- Read the diff stat first: understand which files changed
- Categorize the change: is it a feat, fix, refactor, etc.?
- Identify the scope: which module/feature area does it affect?
- Write a subject: concise, imperative, under 50 chars
- Add body if needed: explain motivation for non-obvious changes
- Add footer if needed: breaking changes, issue references
Grouping Multiple Changes
When a diff contains multiple unrelated changes:
- Split into separate commits if they are genuinely independent
- Use the dominant type if changes are thematically related
- Prefer narrower scope over cramming everything into one message
Examples
Simple feature
feat(api): add pagination support to listings
Bug fix with context
fix(parser): handle malformed JSON gracefully
The parser crashed when receiving truncated JSON from upstream.
Return a partial result with error metadata instead.
Refactor with breaking change
refactor(db)!: merge users and profiles tables
BREAKING CHANGE: The `profiles` table is removed. Profile data
is now in the `users` table under the `profile` JSONB column.
Multi-file chore
chore: configure ESLint and Prettier
- Add .eslintrc.json with TypeScript rules
- Add .prettierrc with project formatting settings
- Add lint-staged for pre-commit checks
Test addition
test(e2e): add checkout flow tests
- Add test for complete purchase flow
- Add test for coupon application
- Add test for payment failure recovery
Edge Cases
Merge Commits
Preserve the default merge message format (Merge branch '...'). Do not rewrite merge commits unless explicitly asked.
Reverts
Use revert: type. Include the original commit hash in subject:
revert: feat(auth): add OAuth2 login flow
This reverts commit a1b2c3d4e5f6...
WIP / Temporary Commits
Use WIP: prefix only when user explicitly asks for a work-in-progress commit, or default to chore: wip with a brief description.
Squash Commits
When squashing, use the most significant type among squashed changes. If the squash includes both feat and fix, default to feat.
Empty / Config-Only Changes
chore: update .gitignore
chore: configure tsconfig.json paths
chore: add editorconfig
docs: update issue templates
Workflow
When the user says "write a commit message":
- Run
git statusto check state - Run
git diff --cached --statto see what's staged - Run
git diff --cachedto see the full staged diff - Optionally run
git log --oneline -5for recent context - Propose the commit message in the format above
- Confirm with the user before committing




