git-conventional-commit
Generates and executes git commits following the Conventional Commits specification. It analyzes git diffs, stages changes, and creates formatted commit messages. Use this skill when the user wants to
SKILL.md.claude/skills/git-conventional-commit/SKILL.md
GitHubGit Conventional Commit Generator
This skill automates the process of staging changes and committing them using the Conventional Commits specification.
Core Process
- Analyze Changes: Check for staged and unstaged changes using
git statusandgit diff. - Stage Files: If no changes are staged, ask the user if they would like to stage all changes (
git add .) or specific files. - Generate Message: Analyze the diff to determine the appropriate type, scope, and description.
- User Review: Present the proposed commit message to the user for approval.
- Execute: Once approved, run the commit command. Never push the changes to a remote repository.
Conventional Commit Format
The generated message must follow this structure:
<type>[optional scope]: <description>
Allowed Types
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the code (white-space, formatting, etc)refactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary tools and libraries
Instructions
1. Identify the Diff
If the user hasn't provided a diff, use the shell tool to retrieve it:
- To see staged changes:
git diff --cached - To see unstaged changes:
git diff - To see a summary of modified files:
git status --short
2. Draft the Message
- Type: Choose the most relevant type based on the diff.
- Scope: Use a noun describing a section of the codebase (e.g.,
(api),(ui),(auth)). - Description: Use the imperative, present tense: "change" not "changed" nor "changes". Do not capitalize the first letter and do not end with a period.
3. Confirmation
Present the message clearly to the user:
Proposed Commit Message:
feat(auth): add JWT validation logicWould you like me to execute this commit?
4. Execution
Upon confirmation, run:
git commit -m "<message>"
Examples
Example 1: New Feature
User: "Commit these changes for me."
Claude: (After checking diff) "I've analyzed your changes to user_controller.go. I suggest the following commit: feat(users): add password reset endpoint. Should I proceed?"
Example 2: Bug Fix
User: "I fixed the alignment in the header, can you commit it?"
Claude: "I see the changes in header.css. Proposed message: fix(ui): correct logo alignment in mobile header. Shall I commit this for you?"
Constraints
- Do Not Push: Never run
git push. Only perform local commits. - Confirmation Required: Always ask for confirmation before running the
git commitcommand. - No Empty Commits: If there are no changes to commit, inform the user.