commit
Create conventional commits with proper formatting
- License 许可
- MIT
- 最近更新
- 2026-11-09
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- model
- sonnet
- description
- Create conventional commits with proper formatting
- allowed-tools
- Read, Bash
- argument-hint
- [type] [scope] [message] - or leave blank for interactive
03 SKILL.md 正文
Commit
Create a well-formatted conventional commit.
Stage related files logically and create conventional commit messages following the format: type(scope): description
Variables
TYPE: $1 || "" # feat, fix, docs, style, refactor, test, chore SCOPE: $2 || "" # Component/area affected MESSAGE: $3 || "" # Commit message (auto-generated if blank)
Workflow
1. Analyze Changes
echo "=== Analyzing Changes ==="
git status --short
echo ""
echo "=== Diff Summary ==="
git diff --stat
echo ""
echo "=== Staged Changes ==="
git diff --cached --stat
Review the changes to understand:
- What files were modified
- Whether changes are already staged
- The nature of the changes (new feature, fix, docs, etc.)
2. Determine Commit Type
If TYPE not provided, analyze changes to suggest:
| Pattern | Suggested Type |
|---|---|
| New files/features | feat |
| Bug fixes, error handling | fix |
| Documentation only (.md, comments) | docs |
| Formatting, whitespace | style |
| Code restructure, no behavior change | refactor |
| Test files only | test |
| Dependencies, config, tooling | chore |
3. Determine Scope
If SCOPE not provided, infer from file paths:
| Path Pattern | Suggested Scope |
|---|---|
cli/ |
cli |
primitives/ |
primitives |
docs/ |
docs |
tests/ |
tests |
*.rs |
core |
*.py |
python |
| Multiple distinct areas | omit scope |
4. Generate Message
If MESSAGE not provided:
- Summarize the changes in imperative mood ("add", not "added")
- Keep under 72 characters
- Focus on what changed, not how
- Be specific but concise
Good examples:
feat(cli): add version bump commandfix(validators): handle empty metadata filesdocs: update ADR-019 with examples
Bad examples:
fixed stuff(vague)Updated the validation logic to check for...(too long, wrong tense)
5. Stage Changes
# If nothing staged, selectively stage tracked file changes
if [ -z "$(git diff --cached --name-only)" ]; then
echo "=== Staging Changes ==="
# Use git add -u for tracked files, or explicitly add specific paths
git add -u
git status --short
fi
6. Create Commit
# Build commit message
if [ -n "${SCOPE}" ]; then
FULL_MESSAGE="${TYPE}(${SCOPE}): ${MESSAGE}"
else
FULL_MESSAGE="${TYPE}: ${MESSAGE}"
fi
echo ""
echo "=== Creating Commit ==="
echo "Message: ${FULL_MESSAGE}"
echo ""
git commit -m "${FULL_MESSAGE}"
7. Verify
echo ""
echo "=== Commit Created ==="
git log -1 --oneline
git log -1 --stat
Report
## Commit Created
**Hash:** <short-hash>
**Type:** ${TYPE}
**Scope:** ${SCOPE}
**Message:** ${MESSAGE}
**Full commit:**
\`\`\`
${TYPE}(${SCOPE}): ${MESSAGE}
\`\`\`
**Files Changed:**
<file list with +/- stats>
**Next Steps:**
- Run `/devops/push` to push to remote
- Or continue making changes
Conventional Commit Types
| Type | When to Use | Example |
|---|---|---|
feat |
New feature for users | feat(auth): add OAuth login |
fix |
Bug fix for users | fix(api): handle null response |
docs |
Documentation only | docs: add setup instructions |
style |
Formatting, no code change | style: fix indentation |
refactor |
Code change, no behavior change | refactor: extract helper function |
test |
Adding/updating tests | test: add unit tests for parser |
chore |
Maintenance, tooling | chore(deps): update dependencies |
Examples
Example 1: Auto-detect everything
/commit
Analyzes changes and suggests type, scope, and message.
Example 2: Specify type only
/commit feat
Uses feat type, auto-detects scope and message.
Example 3: Full specification
/commit feat cli "add version bump command"
Creates: feat(cli): add version bump command
Example 4: No scope
/commit docs "" "update README with examples"
Creates: docs: update README with examples
04 同仓库更多 Skills
testing-expert
Expert knowledge for analyzing testing architecture and planning improvements
security-hardening
Audit and harden repository security — supply chain, CI/CD scanners, secrets, credentials
review
Review implementation against project plan and verify completeness
qa-setup
Verify or create standardized QA commands for polyglot projects
prioritize
Prioritize review comments by severity
pre-commit-qa
Run standardized QA checks before committing changes