Use before EVERY git commit - no exceptions. Enforces pre-commit quality checks, atomic commits, and conventional commit format to prevent hook failures and maintain clean history
Use before ANY commit - never skip for "simple" changes.
STOP: Create TodoWrite checklist BEFORE running any commands.
Correct pattern:
Wrong pattern (will fail):
Create these TodoWrite items as your FIRST action, ALL steps are required:
pnpm pre-commit (if available) AND Read docs/commit_specification.md (PARALLEL)git diff and analyze staging (see below)git add <files> (stage atomic unit of related files)git diff --staged (preview commit).claude/.commit-state.json (signals workflow completion)git commit -m "type(scope): description"Parallel optimization: Step 1 runs pnpm pre-commit (if the script exists) and reads docs/commit_specification.md simultaneously since they have no dependencies.
Before running git add, check current staging state:
Never stage files containing secrets (.env, credentials.json, *.pem, *_key, etc.) - warn user if these appear in diff.
Some files already staged? User pre-selected - verify staged files form atomic unit.
No files staged? After reviewing git diff, evaluate what constitutes an atomic unit:
Multiple logical changes? See Atomic Commits section below for how to identify and split.
Write this file after steps 1-4 and before step 6:
GIT_ROOT=$(git rev-parse --show-toplevel) && \
mkdir -p "$GIT_ROOT/.claude" && \
cat > "$GIT_ROOT/.claude/.commit-state.json" <<'EOF'
{
"workflow_completed": true
}
EOF
Important: This command:
.claude/ directory if it doesn't existThis signals the pre-commit hook that you followed the workflow. Considered stale after 5 minutes. If the commit fails (e.g., git's pre-commit hook rejects it), you can retry immediately without rewriting this file.
type(scope): description - see docs/commit_specification.md
Focus on PURPOSE, not process:
Review FULL diff - message describes collective change, not just latest conversation.
One logical change per commit. If multiple concerns (mixed types, different scopes, unrelated files) โ suggest splitting.
If breaking backward compatibility โ use feat(api)!: description and include BREAKING CHANGE: footer.
If you think any of these, STOP and follow checklist:
pnpm pre-commit" โ Hooks fail on "simple" changespnpm pre-commit fails on your changes? Fix before committing.
pnpm pre-commit fails on unrelated code? Ask user:
Never assume "error is unrelated, skip check" - ask.
--no-verifyNever use git commit --no-verify without explicitly asking user permission first in bold text.