Auto-triggers on commit-related prompts so the rules apply whenever Claude is about to check work in. Covers message style (imperative, no emojis, no Conventional Commits prefixes), HEREDOC discipline, attribution trailer, and logically-separated-commits guidance. Also reinforces the global Claude Code git-safety protocol (no --no-verify, no amend-without-ask, no force-push to main) so it sits in one place next to the repo-specific style rules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.8 KiB
name, description
| name | description |
|---|---|
| git-commit | Git commit conventions for this repo — message style, attribution trailer, and the safety rules that always apply. Use whenever the user says "commit", "commit this", "create a commit", "make a commit", "amend", or asks Claude to check work into git in any form. |
Git commit rule — this repo
Follow these conventions whenever you create a commit in this repository. These are in addition to the standard Claude Code git-safety protocol (no --no-verify, no force-push to main, prefer new commits over --amend, etc.).
Message style
- First line: imperative mood, ≤ 70 characters. Examples:
add d2-diagram skill,fix researcher phase-1 clarification wiring,update Scribe frontmatter schema. - Body (optional): wrap at ~72 chars. Explain the why — the reason this change exists. The diff already shows the what; don't restate it in prose.
- No emojis. Anywhere.
- Don't prefix with types like
feat:orfix:— this repo isn't Conventional Commits. - Don't reference the current task or flow (
for the /council implementation,used by the Researcher) — that context belongs in the PR description and rots as the repo evolves.
Logically-separated commits
Default to one logical change per commit, even when a lot of work lands in the tree at once. When there's a pile of uncommitted or untracked files:
- Read
git status+git difffirst — never stage the whole tree blind. - Group by concern, not by file location. Typical concerns to separate:
- Bookkeeping —
.gitignore, editor/IDE config, Obsidian ignore filters, lockfiles. - Documentation —
README.md,CLAUDE.md, design notes, archived plans. - General-purpose tooling / skills — things that aren't project-specific (reusable skills, shared scripts).
- Project-specific conventions — this repo's own rules (the
git-commitskill is an example). - Feature or subsystem — one cohesive change per commit; if the same commit ships two independent features, split it.
- State / scaffolding — empty-with-header files, seeded directories, index files like Obsidian Bases.
- Bookkeeping —
- Sequence the commits so each one is cleanly scoped, but don't obsess about whether each intermediate commit "works" — for scaffolding PRs it's fine if the full picture only snaps together at the end.
- Prefer many small focused commits over one large mixed one — a reviewer can read, revert, or cherry-pick a focused commit; they can't do any of those to a blob.
- Use
git add <specific paths>— nevergit add -Aorgit add .when splitting, or you'll sweep in the next commit's work by accident. - Verify between commits with
git statusandgit log -1to confirm the split landed as intended.
Corollary: if a commit's subject line needs the word "and" to be accurate, it probably should have been two commits.
Attribution trailer
Every commit ends with the Claude co-author line:
Co-Authored-By: Claude <noreply@anthropic.com>
The model-identifier variant produced by the Claude Code harness (e.g. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>) is also accepted — don't rewrite it if the harness emits that form.
HEREDOC discipline
Pass commit messages via HEREDOC so multi-line formatting survives:
git commit -m "$(cat <<'EOF'
short imperative summary
Optional longer body explaining why this change was needed,
wrapped at about 72 characters.
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Never pass multi-line messages via -m "line1\nline2" or multiple -m flags — Git's behavior differs between shells and quoting regimes and the trailer can end up in the wrong place.
What not to commit
.envand any*.env.local— see.gitignore..obsidian/workspace.jsonand.obsidian/workspace-mobile.json— personal layout state, ignored..claude/settings.local.json— user-specific Claude Code settings, ignored.- Anything in
sessions/<slug>/that's mid-run — wait until a session finishes before committing it, so partial transcripts don't land onmain.
Safety reminders (reinforced from the global Claude Code protocol)
- Never
--no-verify. If a pre-commit hook fails, fix the underlying issue and create a new commit. - Never
--amenda commit unless the user explicitly asks. A failed-hook commit didn't land, so amending would overwrite the previous commit and lose work. - Never force-push to
mainormaster. Warn the user if they ask. - When staging, prefer naming specific files over
git add -A/git add .— those can sweep in secrets or unintended files. git statusbefore staging,git diff --stagedbefore committing,git log -1after committing to confirm.