Git Commit Skill
Automatically analyzes staged git changes and generates Conventional Commits compliant messages with proper formatting and execution.
When to Apply
This skill activates when:
- •User types
/commit - •User asks to "commit changes", "save changes", "create commit"
- •User mentions "conventional commits" or "git commit"
- •Working directory has staged changes
Context Analysis
Before generating the commit message, you must:
- •Check Status: Run
git statusto confirm what is staged. - •Analyze Diff: Run
git diff --stagedto understand the exact changes. - •User Input: Consider any arguments provided (e.g.,
/commit fixing auth bug) as additional context for the commit intent.
Message Generation Rules (Strict)
You must generate a commit message that follows the Conventional Commits specification, strictly adhering to these constraints:
- •Language: The message must be written in English only.
- •Structure: The message must consist of a header, a concise description paragraph, and a mandatory footer.
- •Backticks Rule (CRITICAL):
- •Scope: The scope inside the parentheses must be enclosed in backticks (e.g.,
feat(api):). - •References: All references to code members (variables, functions, classes, filenames) and third-party libraries (e.g.,
react-query,axios) must be enclosed in backticks in both the title and description.
- •Scope: The scope inside the parentheses must be enclosed in backticks (e.g.,
- •Forbidden: Do not use bullet points or numbered lists. Do not use line breaks inside the description paragraph itself.
- •Footer (MANDATORY):
- •Leave one empty line after the description.
- •Append the signature:
Co-Authored-By: Claude Code (<model>) - •Replace
<model>with the specific name of the model generating this response (e.g., Claude 3.5 Sonnet, Claude 3 Opus).
- •Focus: Summarize the most significant change only. Discard minor details.
- •Types: Use only:
feat,fix,docs,style,refactor,perf,test,build,ci,chore,revert.
Commit Type Guidelines
| Type | When to Use |
|---|---|
feat | New features or significant functionality additions |
fix | Bug fixes |
refactor | Code restructuring without changing behavior |
perf | Performance improvements |
style | Code formatting, whitespace, missing semicolons |
docs | Documentation changes only |
test | Adding or updating tests |
chore | Maintenance tasks, dependency updates |
build | Changes to build system or dependencies |
ci | CI/CD configuration changes |
Execution Protocol
- •Analyze staged changes thoroughly
- •Generate commit message following all rules above
- •Construct the final git command:
git commit -m "<message>" - •Execute the command immediately using the bash tool
- •Confirm the commit was successful
Important: Do not ask for confirmation unless the diff is empty or confusing.
Example Output
bash
# After analyzing changes to authentication system git commit -m "fix(\`auth\`): resolve token expiration handling in \`useSession\` hook Updated the \`useSession\` hook to properly check token expiration before making API requests. This prevents unnecessary 401 errors and improves user experience by proactively refreshing tokens when needed. The fix integrates with the existing \`react-query\` cache invalidation strategy. Co-Authored-By: Claude Code (Claude 3.5 Sonnet)"
Reference: Conventional Commits