Commit Message Generator
Purpose
Generate well-formatted commit messages following the Conventional Commits specification.
When to Use
- •User asks "help me write a commit message"
- •User says "commit this" or "commit my changes"
- •User wants to review staged changes before committing
- •User asks for commit message suggestions
- •User mentions "conventional commit" or asks about commit format
Instructions
- •
Check staged changes:
bashgit diff --staged
- •
If no staged changes, check unstaged:
bashgit diff
- •
Analyze the changes and identify:
- •Type: feat, fix, docs, refactor, test, chore, perf, ci, style, build
- •Scope: Affected area/module (optional but recommended)
- •Description: What changed and why
- •
Generate commit message in format:
codetype(scope): brief description Optional body with more details. - Bullet points for multiple changes - Explain the "why" not just "what" Optional footer for breaking changes or issue refs.
Commit Types
| Type | Description |
|---|---|
feat | New feature or capability |
fix | Bug fix |
docs | Documentation only |
refactor | Code change that neither fixes nor adds feature |
test | Adding or updating tests |
chore | Maintenance, dependencies, configs |
perf | Performance improvement |
ci | CI/CD changes |
style | Formatting, whitespace (no code change) |
build | Build system or external dependencies |
Examples
Example 1: Feature Addition
Changes: Added new user authentication endpoint
Output:
code
feat(auth): add user authentication endpoint - Implement JWT-based authentication - Add login and logout endpoints - Include token refresh mechanism Closes #123
Example 2: Bug Fix
Changes: Fixed date display issue in reports
Output:
code
fix(reports): correct date formatting in timezone conversion Use UTC timestamps consistently across report generation. Previous implementation used local time, causing incorrect dates for users in different timezones.
Example 3: Refactoring
Changes: Extracted duplicate validation logic
Output:
code
refactor(validation): extract common validation utilities - Move email validation to shared utils - Create reusable phone number validator - Reduce code duplication across forms
Example 4: Breaking Change
Changes: Changed API response format
Output:
code
feat(api)!: change response format to JSON:API spec BREAKING CHANGE: API responses now follow JSON:API specification. Clients need to update their response parsing logic. Migration guide: docs/migration-v2.md
Guidelines
- •First line: Under 72 characters
- •Use imperative mood: "add" not "added", "fix" not "fixed"
- •Scope is optional but helps with changelogs
- •Body: Explain "why" for non-obvious changes
- •Footer: Reference issues, note breaking changes
- •Separate concerns: One logical change per commit
Co-Author Attribution
When AI assists with commits, include attribution:
code
Co-Authored-By: Claude <noreply@anthropic.com>