From c3
Guide git commit operations with atomic commits and conventional format. Use when committing changes, creating commits, or when user says "/commit", "commit these changes", "create a commit". Analyzes changes, groups by functionality, detects sensitive files, and waits for user verification.
How this skill is triggered — by the user, by Claude, or both
Slash command
/c3:commitThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guide git commit operations with atomic commits, functionality-based grouping, and conventional commit format.
Guide git commit operations with atomic commits, functionality-based grouping, and conventional commit format.
| Capability | Description |
|---|---|
| Git safety protocol | Enforce safe git operations, prevent destructive actions |
| Atomic commits | Group changes by logical functionality |
| Conventional format | Apply type/scope/description format |
| Sensitive file detection | Block .env, *.key, credentials files |
| User verification | Wait for approval before committing |
Use this skill when:
CRITICAL: Follow these rules without exception unless user explicitly requests otherwise.
| Rule | Reason |
|---|---|
| NEVER commit directly to master/main in project mode | User acceptance happens on PRs |
| NEVER update git config | Preserves user's configuration |
NEVER skip hooks (--no-verify, --no-gpg-sign) | Hooks exist for safety |
| NEVER amend commits | Except to add missing attribution |
| NEVER force push to main/master | Protects shared branches |
NEVER use -i flag (interactive) | Not supported in non-interactive context |
Prefer specific files over git add -A or git add . | Avoids sensitive files, large binaries |
Project Management Mode:
When invoked via project-manage skill:
Destructive Operations:
Avoid these unless user explicitly requests:
git push --force, git reset --hard, git checkout .git restore ., git clean -f, git branch -DWhen hooks fail: Fix the underlying issue, don't bypass. Create a NEW commit after fixing.
Before any commit, verify:
git status to check staged filesruff format src tests for Python projectsNote: Test/type/lint validation should be performed by the project-manager agent before invoking this skill.
Before committing, verify:
All edited files should end with a newline character.
# Check if file ends with newline (returns 0 if no newline)
test "$(tail -c1 file | wc -l)" -ne 0 && echo "Missing newline"
# Or check all staged files
git diff --cached --name-only | while read file; do
if test "$(tail -c1 "$file" 2>/dev/null | wc -l)" -ne 0; then
echo "Missing newline: $file"
fi
done
If missing newline:
# Add newline to file
echo "" >> file
Before committing Python code, run formatting:
# Format code
ruff format src tests
# Or use makefile if available
make lint
If formatting is needed:
ruff format src testsgit add src testsIf either check fails:
Block commits containing these files:
| Pattern | Risk Level | Action |
|---|---|---|
.env, .env.local, .env.*.local | High | Block, warn about secrets |
*.pem, *.key | High | Block, warn about credentials |
secrets.*, credentials.* | High | Block, warn about sensitive data |
password, api_key, token in code | Medium | Warn, suggest .env |
If sensitive file detected:
git restore --staged <file>Analyze staged changes by:
File Type:
*.py backend changes → separate commit*.vue, *.tsx frontend changes → separate commit*.test.*, *_test.* test changes → separate commit*.md documentation → separate commitDirectory:
src/api/ → API changessrc/models/ → data model changessrc/ui/ → UI changestests/ → test changesChange Type:
featfixrefactordocstestCan you describe the commit without using "and"?
If multiple "and"s needed, split into separate commits.
When a file touches multiple concerns:
git add -p to stage specific hunkstype(scope): description
[optional body]
🤖 Implemented together with a coding agent.
CRITICAL: Every commit MUST end with the attribution line:
🤖 Implemented together with a coding agent.
This attribution is mandatory. If a commit is created without it, use git commit --amend to add it.
| Type | Usage | Example |
|---|---|---|
feat | New feature | feat(cart): add quantity adjustment |
fix | Bug fix | fix(checkout): handle empty cart |
refactor | Code restructuring | refactor(api): simplify user endpoint |
perf | Performance improvement | perf(search): optimize query |
test | Adding/updating tests | test(cart): add checkout edge cases |
docs | Documentation changes | docs(readme): update install steps |
style | Formatting (no logic change) | style: fix indentation |
chore | Build, deps, tooling | chore: update dependencies |
Run these commands in parallel to gather context:
git status # See untracked files (never use -uall flag)
git diff HEAD # See staged and unstaged changes
git log --oneline -10 # Follow repository's commit message style
Categorize changes:
Some files are regenerated during development (demo screenshots, build artifacts, compiled outputs). After committing implementation changes:
make demos, make build, or similar commands were rungit status.gitignore)Example: After implementing a new tool, make demos regenerated screenshot files.
These should be committed to reflect the current state of the project.
Show user:
Then use AskUserQuestion to confirm the approach:
AskUserQuestion with:
question: "How would you like to proceed with these changes?"
header: "Commit plan"
options:
- label: "Proceed with suggested commits"
description: "Create commits as proposed above"
- label: "Combine into single commit"
description: "Merge all changes into one commit"
- label: "Cancel"
description: "Abort without committing"
.pre-commit-config.yaml or package.json with lint-stagedHEREDOC Syntax: Always use HEREDOC for commit messages to ensure proper formatting:
git commit -m "$(cat <<'EOF'
type(scope): description
Optional body explaining why (not how).
🤖 Implemented together with a coding agent.
EOF
)"
Single logical change:
Stage specific files and commit in parallel:
git add path/to/file1 path/to/file2
git commit -m "$(cat <<'EOF'
type(scope): description
🤖 Implemented together with a coding agent.
EOF
)"
Multiple logical changes:
Run git status and git log -1 --format=%B to verify commit success, then:
🤖 Implemented together with a coding agent.git commit --amend to add itAttribution is for COMMITS only, NOT for comments.
| Context | Add Attribution? |
|---|---|
| Git commits | ✅ Yes - Required |
| PR comments | ❌ No - Do NOT add |
| Issue comments | ❌ No - Do NOT add |
| PR body (description) | Optional - via PR template |
CRITICAL: Never commit without user verification.
Always use the AskUserQuestion tool to request commit confirmation. This provides a clean UX with multiple choice options:
AskUserQuestion with:
question: "Ready to commit? [commit message preview]"
header: "Commit"
options:
- label: "Yes, proceed"
description: "Create the commit with the proposed message"
- label: "No, cancel"
description: "Abort the commit operation"
- label: "Edit message first"
description: "You want to modify the commit message before proceeding"
multiSelect: false
The tool automatically provides an "Other" option for custom input, allowing the user to specify alternative instructions.
Per user memory (commit_after_testing.md):
wip: or --wip prefixgit add for specific filesWhen a pre-commit hook fails:
Why not amend: After hook failure, --amend would modify the PREVIOUS commit, potentially destroying work or losing changes.
Exception: Amending to add missing attribution is allowed for successful commits.
When this skill is invoked via project-manage:
Verify branch: Check that current branch is NOT master/main
git branch --show-current
If on master/main, project-manage should have created a feature branch.
Commit to feature branch: All commits go to the feature branch
After commit, do NOT push automatically — Let project-manage handle push and PR creation
Return control to project-manage for:
Direct commits to master/main are NEVER allowed in project management mode.
patterns/atomic-commits.md - Detailed atomic commit patternspatterns/conventional-commits.md - Conventional commit format guide| Issue | Solution |
|---|---|
| Changes affect multiple concerns | Propose splitting into separate commits |
| Sensitive file in commit | Block immediately, warn user, suggest .gitignore |
| Pre-commit hooks failing | Fix issue, create NEW commit (never amend after failure) |
| Commit message too long | Keep subject under 50 chars, move details to body |
| User didn't review changes | Present diff, wait for explicit approval |
| Accidentally staged sensitive file | Use git restore --staged <file> to unstage |
| Missing attribution in commit | Use git commit --amend to add attribution line |
Creates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.
npx claudepluginhub christophevg/marketplace --plugin c3