commit
4
总安装量
3
周安装量
#50432
全站排名
安装命令
npx skills add https://github.com/johnie/skills --skill commit
Agent 安装分布
claude-code
3
windsurf
1
opencode
1
codex
1
gemini-cli
1
Skill 文档
Commit Skill
Create semantically correct, granular git commits by analyzing staged and unstaged changes.
Auto-staging: All tracked changes are staged automatically. Use --dry-run to preview first.
Model
Use haiku for all operations unless complex reasoning is required.
Arguments
(none): Auto-commit without confirmation-vor--verify: Show plan and ask for confirmation before committing--dry-run: Show commit plan without executing--amend: Amend last commit (always requires -v verification for safety)push: After committing, push to current remote branchpush -v/push --verify: Push with verification prompt
Workflow
- Check for merge conflicts – abort if found
- Check current branch – warn if committing to main/master
- Run
git statusandgit diffto understand current changes - Run
git diff --cachedto see already staged changes - Analyze changes and group them logically
- Create atomic commits with clear messages
- If
pushargument: push to remote
Grouping Strategy
Prefer more commits over fewer. Group by:
- Feature/functionality: Related changes that implement one thing
- File type: Config changes, test files, types, etc.
- Scope: Single module/component changes together
- Nature: Refactors separate from features separate from fixes
Never combine unrelated changes. When in doubt, split.
Commit Message Format
<type>(<scope>): <description>
Types
feat: New featurefix: Bug fixrefactor: Code restructuring without behavior changechore: Maintenance, deps, configdocs: Documentation onlytest: Adding/updating testsstyle: Formatting, whitespaceperf: Performance improvement
Rules
- Subject line: max 72 chars, imperative mood, no period
- Body: only if necessary to explain why, not what
- No body for obvious changes (typos, simple additions, config tweaks)
Good Examples
feat(auth): add JWT refresh token rotation
fix(api): handle null response from payment provider
refactor(utils): extract date formatting helpers
chore: upgrade typescript to 5.4
test(cart): add edge cases for discount calculation
Execution Steps
- Check safety: Detect conflicts, warn on protected branches (main/master)
- Analyze:
git diff --statandgit difffor full context - Plan: Determine commit groups with files and messages
- Verify (if
-v/--verify/--dry-run/--amend): Show plan, wait for confirmation--dry-run: Exit after showing plan--amend: Modify last commit instead of creating new
- Execute: For each commit:
git add <files> git commit -m "<message>" # or for --amend: git add <files> git commit --amend -m "<message>" - Push (only if
pushargument): Rungit push origin HEAD- On failure: show git error, stop (user handles manually)
Example Session
User: /commit
Claude: Analyzing 7 changed files...
â feat(api): add user preferences endpoint
- src/routes/preferences.ts, src/types/preferences.ts
â test(api): add preferences endpoint tests
- tests/preferences.test.ts
â chore: add zod dependency
- package.json, package-lock.json
4 commits created.
With -v: Shows plan, asks “Proceed? (y/n/edit)” before executing
With --dry-run: Shows plan, exits without executing
With --amend -v: Shows plan to amend last commit, asks for confirmation
With push: Adds “Pushing to origin/main… â Pushed successfully.” at end
Edge Cases
- Protected branches: Warn if committing directly to main/master
- Merge conflicts: Abort and instruct user to resolve first
- Single file: Still analyze if it contains multiple logical changes
- Large refactors: May warrant a single commit if truly atomic
- Mixed changes: Always split features from fixes from refactors
- Already staged files: Respect existing staging, offer to commit separately or include