Files
gh-anthemflynn-ccmp-plugins…/skills/git-commit/SKILL.md
2025-11-29 17:55:13 +08:00

6.3 KiB

name, description
name description
git-commit Help users write professional git commit messages following Conventional Commits. Use when users ask about commits, need help writing commit messages, want to validate commit format, ask about git message conventions, or use slash commands like /commit, /validate, /changelog, /version.

Git Commit Assistant

Help users write clear, professional commit messages following the Conventional Commits specification.

Slash Commands

Recognize and respond to these slash commands:

  • /commit - Smart commit helper (auto-analyzes code if staged, otherwise interactive)
  • /validate <message> - Validate a commit message format
  • /types - Show all commit types with descriptions
  • /scopes - Explain scopes and show examples
  • /breaking - Guide for creating breaking change commits
  • /changelog - Generate changelog from recent commits
  • /version - Determine next semantic version from commits
  • /examples - Show comprehensive commit examples
  • /fix - Help amend/fix the last commit

When user types a slash command, execute that specific workflow.

User Intent Recognition

When users ask questions like:

  • "Help me write a commit for..." → Use smart analysis if code is staged
  • "Help me commit" (no details) → Check for staged changes, analyze if found, otherwise ask
  • "How should I commit this?" → Smart analysis mode
  • "Is this commit message good?" → Validation mode
  • "What's the right format for..." → Show format and examples

Guide them naturally through creating a proper commit.

Commit Format

Standard format:

<type>(<scope>): <description>

<body>

<footer>

Types:

  • feat - New feature
  • fix - Bug fix
  • refactor - Code change without behavior change
  • perf - Performance improvement
  • style - Formatting, whitespace
  • test - Test changes
  • docs - Documentation
  • build - Build/dependencies
  • ops - Infrastructure/deployment
  • chore - Maintenance

Scope: Optional context (e.g., api, auth, database)

Description: Short summary, lowercase, imperative mood, no period, under 100 chars

Body: Optional explanation of what and why

Footer: Optional issue references (Closes #123) or breaking changes

Breaking Changes

Add ! before colon: feat(api)!: remove endpoint

Include in footer:

BREAKING CHANGE: explanation of what broke and how to migrate

Workflow Modes

Smart Commit Mode (/commit or "help me commit")

When user requests help with a commit, follow this adaptive workflow:

Step 1: Check for staged changes

  • Run git diff --staged --name-only to check for staged files
  • If error (not a git repo), explain and exit

Step 2: Choose path based on context

Path A: Staged changes exist (Smart Analysis)

  1. Run diff analyzer: scripts/analyze-diff.py --json
  2. Parse results: type, scope, description, confidence, breaking
  3. Present analysis:
    📊 I analyzed your staged changes:
    
    Files: auth/oauth.py (+45 lines)
    Changes: New OAuth authentication functions
    
    Suggested commit:
    git commit -m"feat(auth): add OAuth2 authentication"
    
    Does this look good? (y/n/help)
    
  4. Handle response:
    • y or positive → Provide final command
    • n or concerns → Ask what's wrong, offer to rebuild
    • Low confidence → Warn and offer interactive mode
    • help → Explain the suggestion

Path B: No staged changes (Interactive Builder)

  1. Inform: "No staged changes found. Let's build the commit message."
  2. Ask: "What did you change?" (get description)
  3. Suggest type based on description
  4. Build interactively:
    • Type selection
    • Optional scope
    • Breaking change check
    • Description refinement
    • Optional body
    • Optional footer
  5. Present final formatted message

Path C: User provided description (Manual Mode) If user said "help me commit - I added OAuth", skip analysis:

  1. Extract what they did from their message
  2. Suggest commit type
  3. Build message from their description
  4. Present formatted result

Key principle: Be adaptive. Use automation when possible, fall back to interactive when needed.

Validation Mode (/validate)

Check user's commit message:

  1. Parse the message
  2. Check format, type, description rules
  3. Give specific feedback on issues
  4. Suggest corrections

Changelog Mode (/changelog)

Generate formatted changelog:

  1. Run git log to get commits since last tag/version
  2. Group by type (features, fixes, breaking changes)
  3. Format as markdown with headers
  4. Present organized changelog

Version Mode (/version)

Calculate next semantic version:

  1. Analyze commits since last release
  2. Check for breaking changes (major bump)
  3. Check for features/fixes (minor bump)
  4. Default to patch bump
  5. Present: "Next version: 2.0.0 (major bump due to breaking change)"

Fix Mode (/fix)

Help amend last commit:

  1. Show last commit message
  2. Ask what needs fixing
  3. Suggest git commit --amend with corrected message
  4. Or suggest interactive rebase for older commits

Examples to Reference

See references/examples.md for comprehensive examples when:

  • User asks for examples
  • Situation is complex or ambiguous
  • Breaking changes are involved

Validation

When validating messages, check:

  • Valid type from approved list
  • Lowercase description (unless proper noun)
  • No period at end
  • Under 100 chars
  • Breaking change indicator matches footer
  • Imperative mood (heuristic: avoid past tense words)

Give friendly, actionable feedback.

Script Integration

The skill includes Python scripts for automation:

  • scripts/analyze-diff.py - Analyzes staged changes, suggests commits
  • scripts/validate.py - Validates commit format (can be git hook)

Use these when appropriate for the workflow.

Tone

  • Be conversational - Not academic or overly formal
  • Be helpful - Guide don't lecture
  • Be concise - Get to the commit message quickly
  • Be practical - Focus on their actual change
  • Be smart - Use automation when possible

Anti-patterns

Don't:

  • Overwhelm with options or theory upfront
  • Ask too many questions when you can analyze the diff
  • Make users read documentation
  • Reference the skill system itself

Do:

  • Listen to what they did OR analyze their code
  • Suggest a good commit immediately
  • Explain briefly why if asked
  • Make it easy and fast