Git Commit Quality
Use this skill to produce clean, maintainable, reviewer-friendly git
history. Prefer several well-scoped commits over one large mixed-purpose commit
when the working tree contains separable changes.
Core Principles
- Make each commit atomic: one coherent change, one reason, one review unit.
- Make commits logical: related files and tests belong together; unrelated work
does not.
- Make commits reviewable: a reviewer should understand the intent from the
commit message and confirm it from the diff.
- Make history useful later: future readers should understand what changed and
why without reverse-engineering every line.
- Follow local repository conventions over generic advice when they are clear.
- Do not create commits unless the user or active workflow authorizes commits;
otherwise propose grouping and draft messages.
Scope and Routing
Use this skill to construct new commits: inspect changes, choose logical groups,
stage intentionally, validate, write messages, commit when authorized, and report
the result.
Use git-workflows for amend/fixup and autosquash,
branch switching, merge or rebase, cherry-pick, revert or reset, conflict and
reflog recovery, fetch/pull/push, remotes, tags, and worktrees. Authorization to
commit never authorizes those operations or a push.
Load security-review and
security-review-evidence when a commit
surface includes secrets, credentialed URLs, signing trust, untrusted hooks or
configuration, or other security boundaries. Use
dependency-supply-chain-review
for submodule, hook-tool, dependency, vendored-source, or provenance review.
Workflow
Detect repository conventions.
- Inspect recent history, for example
git log --oneline -10.
- Check project docs such as contributing guides, commit templates, hook
configuration, or release notes when present.
- Check established commit-signing and signoff policy. Follow it without
changing key or trust configuration merely to complete the commit.
- In an unfamiliar repository, inspect the effective hook source before the
first commit. Treat hooks and
core.hooksPath as executable configuration;
stop when provenance is unclear and do not bypass trusted hooks merely to
make a commit succeed.
- Prefer existing style, casing, type names, scopes, ticket references, and
body/footer conventions.
- Do not introduce a new convention into an established repository without a
clear reason.
Inspect the working tree.
- Review
git status --short before staging.
- Review unstaged changes with
git diff and staged changes with
git diff --staged.
- Identify generated files, lockfiles, snapshots, vendored files,
dependency updates,
.gitmodules, submodule gitlinks, local machine files,
editor state, and other artifacts that need extra care.
- Never stage secrets, credentials, private keys, environment files with real
values, generated junk, or unrelated artifacts.
- If a secret may already be staged, committed, reflog-reachable, or pushed,
stop without printing it. Determine the exposure class, rotate or revoke
first, and coordinate any history rewrite or remote cleanup through the
security skills.
Choose commit groups.
- Commit after a coherent unit of work is complete.
- Avoid committing unrelated changes together.
- Avoid committing broken code unless the repository explicitly uses
checkpoint or WIP commits.
- Separate formatting-only changes from behavior changes when practical.
- Separate refactors from feature or bug-fix changes when practical.
- Separate dependency updates from code changes when practical.
- Separate tests from implementation when that improves reviewability; keep
them together when the tests are the best evidence for the same behavior
change.
- Use partial staging, such as
git add -p, when a file contains unrelated
edits that belong in different commits.
- Do not use reset, restore, checkout, clean, stash, amend, or rebase to make
grouping easier unless that exact operation is separately requested and
handled through
git-workflows.
Validate before committing.
- Run the most relevant available formatter, linter, typecheck, build, or
test command when practical.
- If full validation is too expensive, run focused checks for the changed
area and remember the limitation for the final summary.
- Before every commit, check
git diff --staged and confirm only intended
files are staged.
Write the commit message.
- Use a concise subject line; aim for about 50 characters when practical and
avoid exceeding 72 without a good reason.
- Use imperative mood where appropriate:
Add, Fix, Refactor, Remove,
Document, Update.
- Explain what changed and why. The diff shows how.
- Add a body when context, rationale, tradeoffs, side effects, migration
notes, or notable implementation details matter.
- Separate subject, body, and footers with blank lines.
- Wrap body text around 72 characters when practical.
- Avoid vague subjects such as
updates, misc, fix stuff, changes,
wip, or temp in durable history.
Report the result.
- Summarize what was committed and why the grouping was chosen.
- Include commit hashes when available.
- State validation performed and any validation limitations.
- Redact credentialed URLs, secrets, private keys, and sensitive hook output.
Conventional Commits
Conventional Commits is a recommended structured format when a repository uses
it or when no local convention conflicts with it. It is not an unconditional
requirement.
Format:
<type>[optional scope][!]: <description>
[optional body]
[optional footer(s)]
Use scopes to name the affected area when helpful and consistent with the
project, for example fix(parser): handle empty input.
Breaking changes:
- Add
! after the type or scope, such as feat(api)!: require signed tokens.
- Add a
BREAKING CHANGE: footer explaining what changed and how users should
adapt.
- Use either form when local convention allows it; use both when extra clarity
helps.
Example:
fix(cache): prevent stale entries after rename
Renaming an item updated the primary record but left the old cache key in
place. Invalidate both keys so subsequent reads cannot return stale metadata.
Load references/commit-examples.md when the
task needs type selection, breaking-change examples, message comparisons, or a
worked mixed-tree grouping example.
Pre-Commit Checklist
- Local convention checked.
- Working tree inspected.
- Signing/signoff policy and effective hooks checked when applicable.
- Commit grouping chosen and unrelated edits kept out.
- Secrets, local files, generated junk, and unintended artifacts excluded.
- Lockfiles, generated files, snapshots, vendored files, and dependencies are
included only when intentional and explained by the commit.
- Submodule gitlinks and
.gitmodules reviewed when present.
- Relevant validation run, or limitation recorded.
- Staged diff reviewed.
- Commit message explains what changed and why.
- Final response will summarize commits, hashes, validation, and limitations.
When to Ask the User
Ask for clarification only when the desired grouping is genuinely ambiguous or
risky, for example:
- The working tree contains unrelated user changes and it is unclear what may be
committed.
- A generated file, lockfile, snapshot, vendored file, or dependency update looks
accidental.
- The repository convention conflicts with the user's requested message style.
- The user requested a single commit, but the changes are clearly separable and
mixing them would make review or revert materially worse.
- Hook provenance is unclear, signing policy cannot be satisfied safely, or a
secret may already exist in Git history or a remote.
Otherwise, proceed with the safest coherent non-destructive grouping and explain
the choice. Do not push or rewrite history as part of a commit request.
1---2name: git-commit3description: Write high-quality git commits and commit messages. Use when the user asks to commit changes, split a working tree into logical commits, improve commit messages, prepare reviewer-friendly new commits, or apply Conventional Commits guidance in any plain git repository. Do not use for amend/fixup/autosquash, branch operations, integration, recovery, push, tags, or worktrees; use git-workflows.4---56# Git Commit Quality78Use this skill to produce clean, maintainable, reviewer-friendly `git`9history. Prefer several well-scoped commits over one large mixed-purpose commit10when the working tree contains separable changes.1112## Core Principles1314- Make each commit atomic: one coherent change, one reason, one review unit.15- Make commits logical: related files and tests belong together; unrelated work16 does not.17- Make commits reviewable: a reviewer should understand the intent from the18 commit message and confirm it from the diff.19- Make history useful later: future readers should understand what changed and20 why without reverse-engineering every line.21- Follow local repository conventions over generic advice when they are clear.22- Do not create commits unless the user or active workflow authorizes commits;23 otherwise propose grouping and draft messages.2425## Scope and Routing2627Use this skill to construct new commits: inspect changes, choose logical groups,28stage intentionally, validate, write messages, commit when authorized, and report29the result.3031Use [`git-workflows`](../git-workflows/SKILL.md) for amend/fixup and autosquash,32branch switching, merge or rebase, cherry-pick, revert or reset, conflict and33reflog recovery, fetch/pull/push, remotes, tags, and worktrees. Authorization to34commit never authorizes those operations or a push.3536Load [`security-review`](../security-review/SKILL.md) and37[`security-review-evidence`](../security-review-evidence/SKILL.md) when a commit38surface includes secrets, credentialed URLs, signing trust, untrusted hooks or39configuration, or other security boundaries. Use40[`dependency-supply-chain-review`](../dependency-supply-chain-review/SKILL.md)41for submodule, hook-tool, dependency, vendored-source, or provenance review.4243## Workflow44451. Detect repository conventions.46 - Inspect recent history, for example `git log --oneline -10`.47 - Check project docs such as contributing guides, commit templates, hook48 configuration, or release notes when present.49 - Check established commit-signing and signoff policy. Follow it without50 changing key or trust configuration merely to complete the commit.51 - In an unfamiliar repository, inspect the effective hook source before the52 first commit. Treat hooks and `core.hooksPath` as executable configuration;53 stop when provenance is unclear and do not bypass trusted hooks merely to54 make a commit succeed.55 - Prefer existing style, casing, type names, scopes, ticket references, and56 body/footer conventions.57 - Do not introduce a new convention into an established repository without a58 clear reason.59602. Inspect the working tree.61 - Review `git status --short` before staging.62 - Review unstaged changes with `git diff` and staged changes with63 `git diff --staged`.64 - Identify generated files, lockfiles, snapshots, vendored files,65 dependency updates, `.gitmodules`, submodule gitlinks, local machine files,66 editor state, and other artifacts that need extra care.67 - Never stage secrets, credentials, private keys, environment files with real68 values, generated junk, or unrelated artifacts.69 - If a secret may already be staged, committed, reflog-reachable, or pushed,70 stop without printing it. Determine the exposure class, rotate or revoke71 first, and coordinate any history rewrite or remote cleanup through the72 security skills.73743. Choose commit groups.75 - Commit after a coherent unit of work is complete.76 - Avoid committing unrelated changes together.77 - Avoid committing broken code unless the repository explicitly uses78 checkpoint or WIP commits.79 - Separate formatting-only changes from behavior changes when practical.80 - Separate refactors from feature or bug-fix changes when practical.81 - Separate dependency updates from code changes when practical.82 - Separate tests from implementation when that improves reviewability; keep83 them together when the tests are the best evidence for the same behavior84 change.85 - Use partial staging, such as `git add -p`, when a file contains unrelated86 edits that belong in different commits.87 - Do not use reset, restore, checkout, clean, stash, amend, or rebase to make88 grouping easier unless that exact operation is separately requested and89 handled through `git-workflows`.90914. Validate before committing.92 - Run the most relevant available formatter, linter, typecheck, build, or93 test command when practical.94 - If full validation is too expensive, run focused checks for the changed95 area and remember the limitation for the final summary.96 - Before every commit, check `git diff --staged` and confirm only intended97 files are staged.98995. Write the commit message.100 - Use a concise subject line; aim for about 50 characters when practical and101 avoid exceeding 72 without a good reason.102 - Use imperative mood where appropriate: `Add`, `Fix`, `Refactor`, `Remove`,103 `Document`, `Update`.104 - Explain what changed and why. The diff shows how.105 - Add a body when context, rationale, tradeoffs, side effects, migration106 notes, or notable implementation details matter.107 - Separate subject, body, and footers with blank lines.108 - Wrap body text around 72 characters when practical.109 - Avoid vague subjects such as `updates`, `misc`, `fix stuff`, `changes`,110 `wip`, or `temp` in durable history.1111126. Report the result.113 - Summarize what was committed and why the grouping was chosen.114 - Include commit hashes when available.115 - State validation performed and any validation limitations.116 - Redact credentialed URLs, secrets, private keys, and sensitive hook output.117118## Conventional Commits119120Conventional Commits is a recommended structured format when a repository uses121it or when no local convention conflicts with it. It is not an unconditional122requirement.123124Format:125126```text127<type>[optional scope][!]: <description>128129[optional body]130131[optional footer(s)]132```133134Use scopes to name the affected area when helpful and consistent with the135project, for example `fix(parser): handle empty input`.136137Breaking changes:138139- Add `!` after the type or scope, such as `feat(api)!: require signed tokens`.140- Add a `BREAKING CHANGE:` footer explaining what changed and how users should141 adapt.142- Use either form when local convention allows it; use both when extra clarity143 helps.144145Example:146147```text148fix(cache): prevent stale entries after rename149150Renaming an item updated the primary record but left the old cache key in151place. Invalidate both keys so subsequent reads cannot return stale metadata.152```153154Load [`references/commit-examples.md`](references/commit-examples.md) when the155task needs type selection, breaking-change examples, message comparisons, or a156worked mixed-tree grouping example.157158## Pre-Commit Checklist159160- Local convention checked.161- Working tree inspected.162- Signing/signoff policy and effective hooks checked when applicable.163- Commit grouping chosen and unrelated edits kept out.164- Secrets, local files, generated junk, and unintended artifacts excluded.165- Lockfiles, generated files, snapshots, vendored files, and dependencies are166 included only when intentional and explained by the commit.167- Submodule gitlinks and `.gitmodules` reviewed when present.168- Relevant validation run, or limitation recorded.169- Staged diff reviewed.170- Commit message explains what changed and why.171- Final response will summarize commits, hashes, validation, and limitations.172173## When to Ask the User174175Ask for clarification only when the desired grouping is genuinely ambiguous or176risky, for example:177178- The working tree contains unrelated user changes and it is unclear what may be179 committed.180- A generated file, lockfile, snapshot, vendored file, or dependency update looks181 accidental.182- The repository convention conflicts with the user's requested message style.183- The user requested a single commit, but the changes are clearly separable and184 mixing them would make review or revert materially worse.185- Hook provenance is unclear, signing policy cannot be satisfied safely, or a186 secret may already exist in Git history or a remote.187188Otherwise, proceed with the safest coherent non-destructive grouping and explain189the choice. Do not push or rewrite history as part of a commit request.