Git Commit Message
Rules
When inspecting changes for commit messages or change summaries:
- Only
git diff HEAD defines what changed (all local changes vs last commit)
- Never run
git diff --staged, git diff --cached, or git diff HEAD --cached
- Never infer changes from
git status "Changes to be committed"
- Never warn about or analyze index vs working-tree mismatches from the staged list
- If
git diff HEAD is empty, there is nothing to commit — stop
Quick Start
When the user needs a commit message:
- Inspect changes:
git status, git diff HEAD (all local changes vs last commit)
- Read recent style:
git log --oneline -15
- Draft a single-line Conventional Commits message matching repo conventions
- Return the message only — do not commit unless explicitly asked
Run status, diff, and log in parallel when possible.
Message Format
Single line only — no body:
<type>[<scope>]: <subject>
| Part |
Rules |
| type |
Required. One of: feat, fix, refactor, docs, test, chore, perf, ci, build, style, revert |
| scope |
Optional. Module or area in square brackets (e.g. [auth], [api], [ui]). Omit brackets entirely if unclear |
| subject |
Imperative mood, lowercase, no trailing period, ≤72 chars. Must stand alone — pack intent into this line |
Never add a blank line or body paragraph after the subject.
Type Selection
| Type |
When |
feat |
New user-facing capability |
fix |
Bug fix |
refactor |
Code change without behavior change |
docs |
Documentation only |
test |
Tests only |
chore |
Maintenance, deps, tooling |
perf |
Performance improvement |
ci |
CI/CD config |
build |
Build system or external deps |
style |
Formatting, whitespace (no logic change) |
revert |
Revert a prior commit |
Scope Guidelines
- Use existing scopes from recent commits when present
- Prefer short, stable names:
auth, db, config, deps
- Drop scope rather than guess incorrectly
Workflow
Task Progress:
- [ ] Run git status + `git diff HEAD`
- [ ] Read recent git log for style alignment
- [ ] Identify primary change type and scope
- [ ] Draft single-line subject (imperative, self-contained)
- [ ] Check for secrets or files that should not be committed
- [ ] Present message to user
Split vs Single Commit
- One logical change → one commit
- Unrelated changes (feat + fix in different areas) → suggest splitting
- Large refactor + feature → suggest separate commits
Safety
- Never include secrets (.env, credentials, tokens) in the commit
- Warn if changed files look sensitive
- Do not run
git commit unless the user explicitly requests it
Output
Present exactly one line in a copy-paste block:
feat[auth]: add jwt token refresh endpoint
fix[ui]: prevent double submit on checkout form
CLI
Copy-paste commands: cli/git-commit-message.md
Additional Resources
- More examples: examples.md
1---2name: git-commit-message3description: Generate single-line Conventional Commits messages by analyzing git diffs and repository history. Use when the user asks for commit messages or help writing commits.4---56# Git Commit Message78## Rules910When inspecting changes for commit messages or change summaries:1112- **Only** `git diff HEAD` defines what changed (all local changes vs last commit)13- Never run `git diff --staged`, `git diff --cached`, or `git diff HEAD --cached`14- Never infer changes from `git status` "Changes to be committed"15- Never warn about or analyze index vs working-tree mismatches from the staged list16- If `git diff HEAD` is empty, there is nothing to commit — stop1718## Quick Start1920When the user needs a commit message:21221. Inspect changes: `git status`, `git diff HEAD` (all local changes vs last commit)232. Read recent style: `git log --oneline -15`243. Draft a single-line Conventional Commits message matching repo conventions254. Return the message only — do not commit unless explicitly asked2627Run status, diff, and log in parallel when possible.2829## Message Format3031Single line only — **no body**:3233```34<type>[<scope>]: <subject>35```3637| Part | Rules |38|------|-------|39| **type** | Required. One of: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`, `perf`, `ci`, `build`, `style`, `revert` |40| **scope** | Optional. Module or area in square brackets (e.g. `[auth]`, `[api]`, `[ui]`). Omit brackets entirely if unclear |41| **subject** | Imperative mood, lowercase, no trailing period, ≤72 chars. Must stand alone — pack intent into this line |4243**Never** add a blank line or body paragraph after the subject.4445### Type Selection4647| Type | When |48|------|------|49| `feat` | New user-facing capability |50| `fix` | Bug fix |51| `refactor` | Code change without behavior change |52| `docs` | Documentation only |53| `test` | Tests only |54| `chore` | Maintenance, deps, tooling |55| `perf` | Performance improvement |56| `ci` | CI/CD config |57| `build` | Build system or external deps |58| `style` | Formatting, whitespace (no logic change) |59| `revert` | Revert a prior commit |6061### Scope Guidelines6263- Use existing scopes from recent commits when present64- Prefer short, stable names: `auth`, `db`, `config`, `deps`65- Drop scope rather than guess incorrectly6667## Workflow6869```70Task Progress:71- [ ] Run git status + `git diff HEAD`72- [ ] Read recent git log for style alignment73- [ ] Identify primary change type and scope74- [ ] Draft single-line subject (imperative, self-contained)75- [ ] Check for secrets or files that should not be committed76- [ ] Present message to user77```7879### Split vs Single Commit8081- **One logical change** → one commit82- **Unrelated changes** (feat + fix in different areas) → suggest splitting83- **Large refactor + feature** → suggest separate commits8485## Safety8687- Never include secrets (.env, credentials, tokens) in the commit88- Warn if changed files look sensitive89- Do not run `git commit` unless the user explicitly requests it9091## Output9293Present exactly one line in a copy-paste block:9495```96feat[auth]: add jwt token refresh endpoint97```9899```100fix[ui]: prevent double submit on checkout form101```102103## CLI104105Copy-paste commands: [cli/git-commit-message.md](../../../cli/git-commit-message.md)106107## Additional Resources108109- More examples: [examples.md](examples.md)