Git Commit Skill
Create a git commit for the current changes. Follow these steps:
Steps
- •Run the following commands in parallel to understand the current state:
- •
git status— see untracked and modified files - •
git diff— see unstaged changes - •
git diff --staged— see already staged changes - •
git log --oneline -10— understand the commit message style
- •
- •If there are no changes (no untracked files, no modifications, no staged changes), inform the user and stop.
- •Analyze all changes and draft a commit message following the rules below.
- •Stage the relevant files (prefer
git add <specific-files>overgit add .). If changes are already staged, use them as-is unless there are additional unstaged changes that should be included. - •Create the commit. Pass the message via HEREDOC to avoid escaping issues:
bash
git commit -m "$(cat <<'EOF' <commit message here> EOF )"
- •Run
git statusto verify the commit succeeded. - •If the commit fails due to a pre-commit hook, fix the issue, re-stage, and create a new commit. NEVER use
--no-verifyto skip hooks. - •After a successful commit, run
git pushto push to the remote.
Commit Message Rules
Follow the Conventional Commits specification:
code
<type>(<optional scope>): <description> [optional body]
Guidelines
- •Always write commit messages in English, consistent with the project's existing style
- •Infer
scopefrom the changed directory or module (e.g.,feat(auth),fix(api)) - •Keep the description concise (under 72 characters)
- •Use imperative mood ("add feature" not "added feature")
- •Focus on the "why" rather than the "what"
- •Use the body for additional context when needed
- •Do not commit files that likely contain secrets (.env, credentials, etc.)
- •NEVER add
Co-Authored-By,Generated by, or any Claude/AI signature to the commit message