/best-practices-git:commit [scope hint or a subject line]from Best Practices: Git
Stages and commits changes by inferring the repo's own conventions from git history. Screens for credentials, partitions into logical changes, and writes messages explaining why.
Ships in Best Practices: Git. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Optional argument: $ARGUMENTS — treat it as a scope hint or a partial subject
the user wants in the message.
A commit is not a save button. It is the only durable explanation of a change
that travels with the code — the thing someone reads at 2am, six months from
now, when git blame lands on a line nobody understands and the ticket system
that held the context has since been replaced.
Two failures cause most of the pain, and both are avoidable in the thirty
seconds before you type git commit:
Everything below serves those two points.
Current branch:
!git branch --show-current
Working tree:
git status --short
Unstaged:
git diff --stat
Already staged:
git diff --cached --stat
This repo's actual convention — the style oracle. Match it, do not override it:
git log --oneline -20
Full recent messages (do bodies exist? do trailers exist? what do they look like?):
git log -4 --format='%s%n%n%b%n---'
Top-level layout (candidate scopes, if this repo uses scopes):
ls -1
If the current branch is protected — main, master, develop, release,
production, prod, or anything listed under protectedBranches in
.claude/best-practices-git.json — stop. Do not commit.
Protected branches are shared history. A commit landed straight on one skips review and skips CI, and if it turns out to be wrong, the fix is a public revert rather than a closed pull request nobody had to see.
Offer to create a branch instead and carry the work over — git switch -c <type>/<slug> is non-destructive and brings uncommitted changes with it. Suggest
a name from the repo's existing branch convention (git branch -a shows it); if
there is none, <type>/<short-slug> matching the commit type you are about to
use. Wait for the user before continuing.
Read the two git log blocks above and answer these, in your head, for this
repo:
feat:, fix(scope):)? Bare imperative
subjects? A ticket prefix (PROJ-123: …)? Sentence case or lower case?git add -p when the repo favors small commits).Co-Authored-By:,
Signed-off-by:, a ticket link)? Reproduce exactly what is already there.A repo's conventions beat this skill's preferences, always. Consistency is worth
more than any individual style rule — the history is only searchable if it is
uniform. If .claude/best-practices-git.json sets commit.convention,
commit.scopes, commit.trailers, or language, those settings win over your
inference; they exist for the case where the team is deliberately changing style.
Group every changed path (staged and unstaged) by what it is for, not by where it lives. Then check:
If the working tree holds more than one logical change, show the user the partition and propose an order. Do not silently commit them together, and do not split without telling them — a split changes what lands on the branch.
Look at the file list before staging. Refuse to stage, unless the user explicitly insists after you have named the file:
.env, .env.*, *.envcredentials*, service-account*, *-key.json, *.pem, *.key, id_rsa*,
*.p12, *.gpg*.sqlite, *.db, dump.*, backup.*dist/, build/, node_modules/) —
if these show up in git status, the .gitignore is wrong; say so.Say plainly why. "A pushed credential is a leaked credential — rotating it is the only fix, and it stays in the history of every fork and every clone forever" is the whole argument, and it is worth making once rather than arguing about the file.
git add path/one path/two
Never git add -A, git add ., or git add -u. Those stage whatever happens to
be in the tree — including the file another agent wrote thirty seconds ago in a
parallel session, the debug print you meant to delete, and the local config you
never intended to share. Naming the files is the last checkpoint where a human
decision is still possible.
Confirm with git status --short after staging, then read the staged diff itself:
git diff --cached
You are looking for what you did not mean to include: leftover console.log,
commented-out code, a stray whitespace reflow. Fix those now — after the commit
they cost a second commit.
<subject — imperative, one line, fits in ~70 characters>
<body — only when the subject cannot carry the meaning>
<trailers the repo already uses>
Subject. Imperative mood: "add", not "added" or "adds" — a commit describes what applying it does. No trailing period. Concrete over categorical: "reject uploads over 10 MB" beats "improve upload validation". Use the format Step 2 inferred.
Body — this is the part that matters. Write one only when there is a why worth keeping, and then write the why, not the what:
Do not restate the diff in prose. If the body reads like a changelog of the files, delete it — you have written the one thing the reader can already see.
Wrap the body at ~72 characters. If $ARGUMENTS was given, work it into the
subject naturally rather than pasting it.
Use a heredoc so newlines and trailers survive intact:
git commit -m "$(cat <<'EOF'
<subject>
<body>
<trailers>
EOF
)"
Hard rules:
--no-verify. Hooks are the team's agreement with itself. A hook you
skipped runs in CI anyway, ten minutes later, in front of everyone.--amend unless the user asked for an amend in this turn. Amending
rewrites a commit that may already be pushed and may already be someone else's
base.commit -a. It stages by side effect and defeats Step 5.The commit did not happen. This matters: --amend at this point would
rewrite the previous commit — someone else's work — and that is the single most
common way this goes badly wrong.
If the hook keeps failing for a reason unrelated to the diff (a missing tool, a broken environment), surface that to the user. Do not disable the hook.
Four lines at most: the commit hash and subject; the branch; anything you left out (out-of-scope files, refused files); one next step if it is obvious. Do not re-summarize the diff — the user just watched you stage it.
git add -A / . / -u. Stage by name.--no-verify, never --amend unasked, never commit -a..env, or a data dump. Naming it and asking is
not optional politeness — it is the last line of defense.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
3 skills in this plugin
/git-prOpen a pull request from the current branch against the repo's base branch,
and leave the working checkout free by moving the PR into its own worktree.
Three independent guards make pushing to a protected branch impossible; if the
user is standing on one with work in progress, it branches off first instead of
refusing. Delegates to the `commit` skill when the tree is dirty, composes
title and body from the commits (what changed, why, how to check it), assigns
the author, and requests the changed paths' CODEOWNERS as reviewers. Never
force-pushes, never merges. Use when the user says "open a PR", "PR this",
"ship this branch", "abre el PR", "create the pull request", or finishes a
branch and wants it up for review.
/worktreeCreate, list, and remove git worktrees so several branches can be open at once
without anyone switching a branch out from under anyone else — the default way
to work when agents and humans share a repository. Modes: a new branch in its
own checkout, an existing PR checked out for review, list, remove, prune.
Worktrees land in a sibling directory, each with its own dependencies and its
own local config, copied rather than symlinked. Backed by a zero-dep Node
script. Use when the user says "worktree", "check out that PR locally",
"work on two branches at once", "haz un worktree", "spin up a branch in
parallel", or needs the current checkout free without losing what is in it.
npx claudepluginhub pappcorn/universe --plugin best-practices-git