commit
npx skills add https://github.com/pigfoot/claude-code-hubs --skill commit
Agent 安装分布
Skill 文档
Commit Skill
Creates well-formatted commits following conventional commit standards with emoji prefixes.
When to Use
- User says “commit”, “commit these changes”, or uses
/commit - After code changes are ready to be committed
- Need help with commit message formatting
- Want automatic detection of multi-concern changes
Core Features
- GPG signing with cached passphrase (if
$GPG_PASSPHRASEset) - Staged vs unstaged detection – commits only staged files when present
- Split suggestions – analyzes diffs for multiple logical changes
- Conventional commits –
<emoji> <type>: <description>format - Pre-commit hook integration – respects Husky/other hooks
- Always –signoff – DCO compliance
Process
1. Environment Check
# Check GPG passphrase availability
if [ -n "$GPG_PASSPHRASE" ]; then
# Cache passphrase
gpg --batch --pinentry-mode loopback \
--passphrase-file <(echo "$GPG_PASSPHRASE") \
--clearsign >/dev/null 2>&1 <<< "test"
USE_GPG="yes"
else
USE_GPG="no"
fi
2. Analyze Changes
git status --short
# Prefer staged files if any exist
if ! git diff --staged --quiet; then
git diff --staged --stat # Staged changes
else
git diff HEAD --stat # All changes
fi
3. Multi-Concern Detection
Suggest split if:
- Different patterns:
src/+test/+docs/ - Mixed types: feat + fix + docs
- Unrelated concerns: auth logic + UI styling
- Large changeset: >500 lines
Ask user:
Multiple concerns detected:
1. Auth changes (src/auth/*)
2. UI updates (src/components/*)
3. Docs (README.md)
Split into 3 commits?
- ⨠feat: add JWT authentication
- ð style: update login UI
- ð docs: update auth documentation
[split/all]
4. Create Commit
Format: <emoji> <type>: <description>
Rules:
- Imperative mood (“add” not “added”)
- First line <72 chars
- Atomic (single purpose)
- Use body for “why” if needed
git commit --signoff ${USE_GPG:+--gpg-sign} -m "<emoji> <type>: <description>"
5. Handle –no-verify
If user requests --no-verify:
â ï¸ Requested to skip pre-commit hooks.
Bypasses: linting, tests, formatting
Reason: [ask user]
Approve? [yes/no]
Only proceed if confirmed.
Commit Types & Emoji
| Type | Emoji | Use Case |
|---|---|---|
| feat | ⨠| New feature |
| fix | ð | Bug fix |
| docs | ð | Documentation |
| style | ð | Formatting, styling |
| refactor | â»ï¸ | Code restructure |
| perf | â¡ | Performance |
| test | â | Tests |
| chore | ð§ | Build/tools |
| ci | ð | CI/CD |
| security | ðï¸ | Security fix |
| build | ðï¸ | Build system |
| revert | âªï¸ | Revert changes |
| wip | ð§ | Work in progress |
Extended emoji map: ð move | â add-dep | â remove-dep | ð± seed | ð§âð» dx | ð·ï¸ types | ð business | ð¸ ux | 𩹠minor-fix | ð¥ errors | ð¥ remove | ð¨ structure | ðï¸ hotfix | ð init | ð release | ð ci-fix | ð pin-deps | ð· ci-build | ð analytics | âï¸ typos | ð license | ð¥ breaking | ð± assets | â¿ï¸ a11y | ð¡ comments | ðï¸ db | ð logs | ð remove-logs | ð gitignore | ð¸ snapshots | âï¸ experiment | ð© flags | ð« animations | â°ï¸ dead-code | 𦺠validation | âï¸ offline
Split Decision Examples
â Bad – Mixed concerns
+ src/auth/login.ts (feat)
+ src/components/Button.css (style)
+ README.md (docs)
Split into: 3 separate commits
â Good – Single concern
+ src/auth/login.ts
+ src/auth/middleware.ts
+ tests/auth.test.ts
One commit: ⨠feat: add authentication
â Bad – Mixed types
+ Add export feature (feat)
+ Fix date bug (fix)
Split into: 2 commits by type
â Bad – Large multi-feature
300+ lines: auth system
200+ lines: UI components
150+ lines: database
Split into: 3 commits by feature
Critical Rules
NEVER
- â Add Claude signature to commits
- â Commit without checking staged status
- â Skip split suggestions for multi-concern
- â Use past tense (“added” â “add”)
- â Make first line >72 chars
- â Bypass hooks without asking
ALWAYS
- â Use –signoff flag
- â Check GPG passphrase first
- â Analyze diff before commit
- â Suggest splits when appropriate
- â Use imperative mood
- â Pick correct emoji + type
- â Ask approval for –no-verify
Integration Notes
With CLAUDE.md
CLAUDE.md references this skill: “Use /commit or say ‘commit changes'”
With spec-kit
Reference planning docs in commit body:
⨠feat: add user authentication
- JWT token validation
- Protected routes middleware
- Tests cover happy/error paths
Related to Stage 2 of PLAN.md (User Story 1.2)
With Husky
Hooks run automatically unless –no-verify used (requires approval).
Example Sessions
Simple commit
User: "commit these changes"
Process:
1. Check GPG â
2. Analyze: src/auth/login.ts (modified)
3. Single concern â
4. Create: ⨠feat: add login endpoint
5. Execute: git commit --signoff --gpg-sign -m "..."
Split required
User: "commit"
Process:
1. Detect: auth + UI + docs
2. Suggest split (3 commits)
3. User confirms "split"
4. Commit each separately with proper emoji/type
Skip hooks
User: "/commit --no-verify"
Response:
"â ï¸ Skip hooks? Bypasses linting/tests.
Reason: [wait]"
User: "hotfix for production"
Action: Proceed with --no-verify
Troubleshooting
GPG fails
echo $GPG_PASSPHRASE # Check set
gpg --clearsign <<< "test" # Test manually
# If fails: commit without --gpg-sign
Hook fails
Check output â fix issue â retry Critical case only: ask about –no-verify
No changes
git status
# No changes: inform user
# Unstaged only: "Stage files first?"
Progressive Disclosure
Keep this main file under 500 lines. For extensive reference:
- Emoji cheatsheet â See
emoji-reference.md(if needed) - Advanced patterns â See
advanced-commits.md(if needed)
Current approach: All essential info in this file for immediate use.