Git Commit
Generate concise and descriptive git commit messages based on staged code changes.
Commit Message Format
code
<Subject> <Description>
Best Practices
1. Capitalization and Punctuation
- •Capitalize the first word of the subject line
- •Do NOT end the subject line with punctuation
2. Imperative Mood
Use imperative mood in the subject line—give the tone of giving an order or request.
Good:
- •Add fix for dark mode toggle state
- •Update API authentication flow
- •Remove deprecated database fields
Bad:
- •Added fix for dark mode toggle state
- •Updating API authentication flow
- •Removing deprecated database fields
3. Length Limits
- •Subject line: Maximum 50 characters
- •Body lines: Maximum 72 characters
4. Content Style
Be direct and concise. Eliminate filler words and phrases such as:
- •"though"
- •"maybe"
- •"I think"
- •"kind of"
- •"just"
- •"simply"
Think like a journalist—state what was done clearly and directly.
Analysis Framework
To craft thoughtful commit messages, consider:
- •Why were these changes made?
- •What effect do the changes have?
- •Why was the change needed?
- •What are the changes in reference to (issue numbers, PRs, tickets)?
Examples
Simple bug fix:
code
Fix authentication timeout Increase session timeout from 30 to 60 minutes to prevent frequent re-authentication for active users. Fixes #123
Feature addition:
code
Add dark mode support Implement system-wide dark mode using CSS custom properties. Users can toggle between light and dark themes via new settings menu option. Refs #456
Refactoring:
code
Extract payment processing module Move payment-related logic into dedicated module to improve testability and reduce controller complexity.
Breaking change:
code
Remove deprecated user endpoints Delete /users/legacy endpoints which were marked for removal in v2.0. Clients must use /v2/users endpoints instead. BREAKING CHANGE: Migrate to v2 endpoints before upgrading
Workflow
- •Run
git statusto see staged changes - •Run
git diff --stagedto review the actual changes - •Run
git log -5 --onelineto understand recent commit message style - •Analyze changes to understand the "why" and "what"
- •Draft the commit message following the format and practices above
- •Verify: subject under 50 chars, imperative mood, no trailing punctuation