Commit message conventions, staging practices, and commit best practices. Covers conventional commits, explicit staging workflow, logical change grouping, humble fact-based communication style, and automatic issue detection. Use when user mentions committing changes, writing commit messages, git add, git commit, staging files, or conventional commit format.
| Use this skill when... | Use the alternative when... |
|---|---|
| Designing the conventional-commit message and staging conventions for a repo | Use git-commit to actually create a commit (handles pre-commit hooks, issue detection) |
| Reviewing how to group changes logically into focused commits | Use git-commit-trailers for BREAKING CHANGE / Co-authored-by trailer rules |
| Discussing humble, fact-based commit communication style | Use github-issue-autodetect to add Fixes #N / Closes #N links to messages |
| Authoring feat(scope): subject rules for your codebase | Use github-pr-title to apply the same conventional format to PR titles |
Expert guidance for commit message conventions, staging practices, and commit best practices using conventional commits and explicit staging workflows.
For detailed examples, advanced patterns, and best practices, see REFERENCE.md.
Before staging any files — especially for bulk-edit / commit-loop workflows that touch many subdirectories — verify the working tree is yours alone:
| Check | Why | How |
|-------|-----|-----|
| Coworker check | Another Claude session in the same checkout may have already pre-staged files (git commit -a retry, abandoned staging) that your loop would sweep into the wrong commit. Run this up front, not opportunistically. | SlashCommand → /git:coworker-check |
| Working tree scoped | Confirm git status --porcelain shows only your edits | git status --porcelain |
If /git:coworker-check returns anything other than clear, stop and either move to a fresh worktree (git worktree add ../<repo>-<task>) or ask the user before proceeding. See .claude/rules/agent-coworker-detection.md for the four detection signals.
Note: Commits are made on main branch and pushed to remote feature branches for PRs. See git-branch-pr-workflow skill for the main-branch development pattern.
type(scope): description
[optional body]
[optional footer(s)]
For footer/trailer patterns (Co-authored-by, BREAKING CHANGE, Release-As), see git-commit-trailers skill.
# Feature with scope
git commit -m "feat(auth): implement OAuth2 integration"
# Bug fix with body
git commit -m "fix(api): resolve null pointer in user service
Fixed race condition where user object could be null during
concurrent authentication requests."
# Breaking change
git commit -m "feat(api)!: migrate to GraphQL endpoints
BREAKING CHANGE: REST endpoints removed in favor of GraphQL.
See migration guide at docs/migration.md"
DO:
Fixes #123, Closes #456, Resolves #789Refs #N for related issues that should not auto-closeDON'T:
Fixes) when you only mean to reference (Refs)Before committing, gather all context in one command:
# Basic context: status, staged files, diff stats, recent log
bash "${CLAUDE_PLUGIN_ROOT}/skills/git-commit-workflow/scripts/commit-context.sh"
# With issue matching: also fetches open GitHub issues for auto-linking
bash "${CLAUDE_PLUGIN_ROOT}/skills/git-commit-workflow/scripts/commit-context.sh" --with-issues
The script outputs: branch info, staged/unstaged status, diff stats, detected scopes, recent commit style, pre-commit config status, and optionally open issues. Use this output to compose the commit message. See scripts/commit-context.sh for details.
# Show current status
git status --porcelain
# Stage files one by one for visibility
git add src/auth/login.ts
git add src/auth/oauth.ts
git status # Verify what's staged
# Show what will be committed
git diff --cached --stat
git diff --cached # Review actual changes
# Commit with conventional message
git commit -m "feat(auth): add OAuth2 support"
When a single change touches many subdirectories (per-plugin, per-package, per-doc) and each needs its own scoped commit for release-please, write a one-shot script rather than chaining commands inline.
| Pattern | What blocks it |
|---------|----------------|
| for d in a b c; do git add "$d/" && git commit -m "..."; done | bash-antipatterns.sh blocks git add ... && git commit ... — chaining index-modifying git commands risks an index.lock race condition |
| git add -A, git add --all, git add . | bash-antipatterns.sh blocks broad staging — sweeps in .env, large binaries, and any coworker session's in-flight files in a shared checkout (see .claude/rules/agent-coworker-detection.md) |
| Repeating git add <paths>; git commit -m "..." as separate Bash tool calls per plugin | Works, but ~3 tool calls × N plugins becomes hundreds of round-trips for a 40-plugin sweep |
Write the loop to /tmp/commit-loop-<slug>.sh, then run it in one Bash call. The hook treats the file as a script, not a chain — index-modifying commands are sequential within bash, not racing through separate tool invocations.
#!/bin/bash
# /tmp/commit-loop-trim-descriptions.sh
set -uo pipefail
cd "$REPO_ROOT" || exit 1
for p in plugin-a plugin-b plugin-c; do
# Skip plugins with nothing staged or modified inside them
[ -z "$(git status --porcelain "$p/")" ] && continue
git add "$p/skills/" # explicit path, never -A or .
git commit -m "docs($p): trim skill descriptions for listing budget"
done
Invoke once:
bash /tmp/commit-loop-trim-descriptions.sh
Each iteration runs pre-commit hooks and produces a clean per-plugin commit. Use ; or newlines (not &&) between git add and git commit inside the script.
If the loop aborts mid-way (a pre-commit hook fails on plugin K of N), the commits for plugins 1..K-1 have already landed — they are not rolled back. Recovery rules:
| Situation | Action |
|-----------|--------|
| Pre-commit hook caught a real issue in plugin K | Fix the issue, re-run the script — the [ -z ... ] && continue guard skips plugins with no remaining changes |
| Script re-run picks up plugin K's leftover staged paths | Good — the unstaged-or-staged check via git status --porcelain "$p/" catches both |
| You want to skip plugin K and continue | Edit the script to remove plugin K from the list, re-run |
Do not re-stage paths that already committed cleanly; git status is the source of truth for what's left.
Compose a multi-line message with a HEREDOC, not by slurping a temp file.
git commit -m "$(cat <<'EOF'
feat(auth): add OAuth2 support
Implements token refresh and secure storage.
Fixes #123
EOF
)"
Passing the message by path is equally accepted — git commit -F <file> /
--file=<file> is git's analogue of gh --body-file, and the
bash-antipatterns hook exempts it (#2462):
git commit -F /tmp/commit-msg.txt
What the hook still nudges away from is the roundabout middle ground: writing a
temp file and then slurping it back through -m "$(cat /tmp/commit-msg.txt)".
Either compose inline with a heredoc, or pass the file by path.
# Good: Concise, factual, modest
git commit -m "fix(auth): handle edge case in token refresh"
git commit -m "feat(api): add pagination support
Implements cursor-based pagination for list endpoints.
Includes tests and documentation."
Focus on facts: What changed, Why it changed (if non-obvious), and Impact (breaking changes).
| Scenario | Pattern | Example |
|----------|---------|---------|
| Bug fix resolving issue | Fixes #N | Fixes #123 |
| Feature completing issue | Closes #N | Closes #456 |
| Related but not completing | Refs #N | Refs #789 |
| Cross-repository | Fixes owner/repo#N | Fixes org/lib#42 |
| Multiple issues | Repeat keyword | Fixes #1, fixes #2 |
# Subject line: <= 72 characters
feat(auth): add OAuth2 support
# Body: <= 72 characters per line (wrap)
# Use blank line between subject and body
| Context | Command |
|---------|---------|
| Pre-commit context | bash "${CLAUDE_PLUGIN_ROOT}/skills/git-commit-workflow/scripts/commit-context.sh" |
| Context + issues | bash "${CLAUDE_PLUGIN_ROOT}/skills/git-commit-workflow/scripts/commit-context.sh" --with-issues |
| Quick status | git status --porcelain |
| Staged diff stats | git diff --cached --stat |
| Recent commit style | git log --format='%s' -5 |
| Open issues for linking | gh issue list --state open --json number,title --limit 30 |
npx skills add laurigates/git-commit-workflow下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer