Git Smart Commit
Generate a commit message that matches the repository's actual rules. Default to one short header for cohesive changes; include a short body when one intent spans multiple areas.
Use When
- The user asks for a commit message
- The user wants to refine a draft commit header
- The user wants a commit title based on staged or working tree changes
Do Not Use
- For changelogs, PR titles, or release notes
- When the user already gave the exact final commit header
Workflow
- Inspect staged changes first:
git diff --cached --name-only
git diff --cached --stat
- If nothing is staged, inspect working tree changes:
git status --short
git diff --name-only
- Discover commit rules, in order:
.commitlintrc.*
commitlint.config.*
package.json
.cz-config.*
.czrc*
lefthook.yml
.husky/*
AGENTS.md
README*
CONTRIBUTING*
- contribution or git workflow docs
git log --oneline -20
- If docs and executable config disagree, follow executable config.
- Assess cohesion:
- one logical change
- one dominant change plus incidental ripple
- several unrelated changes
- Treat formatting, lockfile, generated-file churn, and tests removed with covered code as incidental ripple.
- Write the subject from the primary intent, not from the area with the most files.
Hard rules
- Prefer
type(scope): subject.
- Use
type: subject only when the repo does not require scope or no valid scope is clear.
- Obey the repo's max header length if configured. Otherwise keep it under
72 and preferably under 60.
- Prefer
2-6 subject words. Avoid more than 8 unless required.
- No ending period.
- Avoid vague subjects such as
update code, fix issue, minor changes, optimize.
- Match the dominant language of the repo's recent commits when it is obvious.
- If the repo has no commit history and no explicit language rule, default to English.
- Do not invent custom types or scopes unless the repo explicitly allows them.
- For docs, config, lint, CI, types, tests, build, or release work, use the matching non-feature type. Do not default to
feat.
- If no explicit type rules exist, use common Conventional Commit types:
feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert.
Scope rules
- If scopes are enumerated, only use those values and exact spelling.
- If the repo uses package names as scopes, prefer the nearest
package.json.name.
- If the repo has no scope convention and scope adds little value, omit it.
- For root-level mixed or unrelated changes, use a broad allowed scope if one exists. Otherwise omit scope.
Output
Default to one line: the recommended commit header.
When to add structure
- If one intent spans several areas, return the header, one blank line, then a short body of up to
5 bullets.
- If several unrelated changes are present, recommend splitting the commit first, then provide concise one-line headers grouped by path or intent.
General rules
- If
type or scope is genuinely ambiguous, return at most 3 one-line candidates, best first.
- Keep the header within the same length limits whether or not a body follows.
- Never pad a cohesive change with bullets.
- Do not add labels or explanations for a normal one-line header. A multi-line message may use a single code block for readability.
- Prefer a single best answer whenever the repo signals are clear.
Examples
fix(api): trim login payload
docs: update setup guide
chore(lint): tune oxlint config
refactor(core): simplify init flow
One intent across areas:
chore(lint): align shared lint rules
- update shared eslint config
- adjust affected package scripts
- refresh lint docs
Unrelated changes:
Split this changeset:
- `fix(auth): handle expired sessions` for `src/auth/**`
- `docs: update setup guide` for `README.md`
1---2name: git-smart-commit3description: Use when the user wants a git commit message or wants to refine one. Detect the current project's commit convention first, then generate a matching header; include a short body when one intent spans multiple areas.4---56# Git Smart Commit78Generate a commit message that matches the repository's actual rules. Default to one short header for cohesive changes; include a short body when one intent spans multiple areas.910## Use When1112- The user asks for a commit message13- The user wants to refine a draft commit header14- The user wants a commit title based on staged or working tree changes1516## Do Not Use1718- For changelogs, PR titles, or release notes19- When the user already gave the exact final commit header2021## Workflow22231. Inspect staged changes first:24 - `git diff --cached --name-only`25 - `git diff --cached --stat`262. If nothing is staged, inspect working tree changes:27 - `git status --short`28 - `git diff --name-only`293. Discover commit rules, in order:30 - `.commitlintrc.*`31 - `commitlint.config.*`32 - `package.json`33 - `.cz-config.*`34 - `.czrc*`35 - `lefthook.yml`36 - `.husky/*`37 - `AGENTS.md`38 - `README*`39 - `CONTRIBUTING*`40 - contribution or git workflow docs41 - `git log --oneline -20`424. If docs and executable config disagree, follow executable config.435. Assess cohesion:44 - one logical change45 - one dominant change plus incidental ripple46 - several unrelated changes476. Treat formatting, lockfile, generated-file churn, and tests removed with covered code as incidental ripple.487. Write the subject from the primary intent, not from the area with the most files.4950## Hard rules5152- Prefer `type(scope): subject`.53- Use `type: subject` only when the repo does not require scope or no valid scope is clear.54- Obey the repo's max header length if configured. Otherwise keep it under `72` and preferably under `60`.55- Prefer `2-6` subject words. Avoid more than `8` unless required.56- No ending period.57- Avoid vague subjects such as `update code`, `fix issue`, `minor changes`, `optimize`.58- Match the dominant language of the repo's recent commits when it is obvious.59- If the repo has no commit history and no explicit language rule, default to English.60- Do not invent custom types or scopes unless the repo explicitly allows them.61- For docs, config, lint, CI, types, tests, build, or release work, use the matching non-feature type. Do not default to `feat`.62- If no explicit type rules exist, use common Conventional Commit types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`.6364## Scope rules6566- If scopes are enumerated, only use those values and exact spelling.67- If the repo uses package names as scopes, prefer the nearest `package.json.name`.68- If the repo has no scope convention and scope adds little value, omit it.69- For root-level mixed or unrelated changes, use a broad allowed scope if one exists. Otherwise omit scope.7071## Output7273Default to one line: the recommended commit header.7475### When to add structure7677- If one intent spans several areas, return the header, one blank line, then a short body of up to `5` bullets.78- If several unrelated changes are present, recommend splitting the commit first, then provide concise one-line headers grouped by path or intent.7980### General rules8182- If `type` or `scope` is genuinely ambiguous, return at most `3` one-line candidates, best first.83- Keep the header within the same length limits whether or not a body follows.84- Never pad a cohesive change with bullets.85- Do not add labels or explanations for a normal one-line header. A multi-line message may use a single code block for readability.86- Prefer a single best answer whenever the repo signals are clear.8788## Examples8990- `fix(api): trim login payload`91- `docs: update setup guide`92- `chore(lint): tune oxlint config`93- `refactor(core): simplify init flow`9495One intent across areas:9697```text98chore(lint): align shared lint rules99100- update shared eslint config101- adjust affected package scripts102- refresh lint docs103```104105Unrelated changes:106107```text108Split this changeset:109110- `fix(auth): handle expired sessions` for `src/auth/**`111- `docs: update setup guide` for `README.md`112```