Git Commit Message Generator
by @michaelatamuk
Generate conventional commit messages by analyzing staged changes automatically
clawhub install git-commit-message-generatorπ About This Skill
name: git-commit-message-generator description: Generate conventional commit messages by analyzing staged changes automatically version: 1.0.0 metadata: openclaw: emoji: "π" homepage: https://www.conventionalcommits.org requires: bins: - git os: ["macos", "linux", "windows"]
Git Commit Message Generator
Automatically generates high-quality conventional commit messages by analyzing your staged Git changes. No more staring at a blank commit message wondering what to write - this skill reads your git diff, understands the context, and creates a properly formatted commit message following the Conventional Commits specification.
What This Skill Does
This skill analyzes your staged changes and generates commit messages that follow the Conventional Commits format:
(): [optional body]
[optional footer(s)]
It intelligently detects:
Why Use This Skill
Saves Time
Improves Quality
Enables Automation
When to Use This Skill
Use this skill whenever you're about to commit code:
git addWhen NOT to Use This Skill
git revert auto-messages)How It Works
Step-by-Step Process
1. Reads staged changes: Executes git diff --staged to see what you're about to commit
2. Analyzes file patterns: Identifies which files changed (components, tests, docs, config)
3. Detects change type: Determines if it's a feature, fix, refactor, etc.
4. Identifies scope: Extracts the affected module/component name
5. Checks for breaking changes: Looks for API changes, removed exports, major refactors
6. Generates message: Creates a properly formatted conventional commit message
7. Validates format: Ensures it follows best practices (length, mood, structure)
Detection Logic
Type Detection:
feat: - New files in src/, new functions/classes, new exportsfix: - Changes to existing logic, bug-related file names, error handlingdocs: - Changes to .md files, JSDoc/comments, README updatestest: - Changes to test files, spec files, test utilitiesrefactor: - Code restructuring without behavior change, renaming, cleanupstyle: - Formatting, linting fixes, whitespace, semicolonsperf: - Performance optimizations, caching, algorithm improvementsbuild: - package.json, webpack, build scripts, dependenciesci: - GitHub Actions, .yml files, CI configchore: - Tooling, configs, gitignore, minor maintenanceScope Detection:
src/components/Button.tsx β (button)src/auth/login.ts β (auth)(api), (ui), (db), (tests), (docs)Breaking Change Detection:
BREAKING CHANGE: footerUsage Examples
Example 1: Feature Addition
You run:
# Stage your changes
git add src/components/UserProfile.tsxAsk Claude:
"Generate a commit message for my staged changes"
Claude analyzes:
+ export function UserProfile({ userId }: Props) {
+ const user = useUser(userId);
+ return {user.name};
+ }
Generated message:
feat(user-profile): add user profile componentImplements new UserProfile component that displays user information
based on userId prop. Integrates with useUser hook for data fetching.
Example 2: Bug Fix
You run:
git add src/api/auth.tsAsk Claude:
"Create a commit message"
Claude analyzes:
- if (token == null) {
+ if (token === null || token === undefined) {
throw new Error('Invalid token');
}
Generated message:
fix(auth): use strict equality check for token validationFixes bug where token with value 0 or empty string would incorrectly
pass validation. Now uses strict equality to properly check for null
or undefined values.
Example 3: Breaking Change
You run:
git add src/api/users.tsAsk Claude:
"Generate commit message"
Claude analyzes:
- export async function getUser(id: string): Promise {
+ export async function getUser(id: string, options?: GetUserOptions): Promise {
Generated message:
feat(api)!: add options parameter to getUser functionExtends getUser API to accept optional configuration object for
including related data. Return type changed to UserResponse for
better type safety.
BREAKING CHANGE: getUser now returns UserResponse instead of User.
Update all callers to access user data via response.data property.
Example 4: Documentation Update
You run:
git add README.md docs/api.mdAsk Claude:
"Generate commit"
Generated message:
docs: update API documentation and READMEAdd authentication examples to API docs
Update installation instructions in README
Fix typos in configuration section
Example 5: Dependency Update
You run:
git add package.json package-lock.jsonAsk Claude:
"Make commit message"
Claude analyzes:
- "react": "^17.0.2"
+ "react": "^18.2.0"
Generated message:
build(deps): upgrade react to v18.2.0Updates React from v17 to v18 for improved concurrent rendering
features and automatic batching. No breaking changes in our usage.
Configuration
Optional: Customize Commit Style
While this skill uses Conventional Commits by default, you can customize the style in your conversation:
"Generate a commit message following Angular style"
"Create a commit using Gitmoji format with emojis"
"Write a detailed commit message with bullet points in the body"
Optional: Set Default Scope
If you're working in a monorepo or specific module:
"Generate commit messages with scope 'frontend' for this session"
"All my commits should have scope 'api'"
Optional: Link to Issue Tracker
If your branch name includes issue numbers:
# Branch: feature/USER-123-add-profile
Generated message will include:
#
feat(user-profile): add user profile component
#
Closes USER-123
Best Practices
For Best Results
1. Stage related changes together: Don't mix features and fixes in one commit 2. Review the generated message: Claude generates smart defaults, but you can refine 3. Add context if needed: Mention "this fixes a race condition" for better descriptions 4. Use meaningful branch names: Branch names help Claude understand context 5. Keep commits atomic: One logical change per commit works best
Tips for Teams
conventional-changelog to automate release notessemantic-release to version from commitsConventional Commit Format Reference
Structure
[optional scope][optional !]: [optional body]
[optional footer(s)]
Types
feat: - New feature for users (triggers MINOR version)fix: - Bug fix for users (triggers PATCH version)docs: - Documentation only changesstyle: - Formatting, missing semicolons, etc. (no code change)refactor: - Code change that neither fixes a bug nor adds a featureperf: - Performance improvementtest: - Adding or updating testsbuild: - Changes to build system or dependenciesci: - Changes to CI configuration files and scriptschore: - Other changes that don't modify src or test filesrevert: - Reverts a previous commitBreaking Changes
Add ! after type/scope OR include BREAKING CHANGE: in footer:
feat(api)!: remove deprecated endpointsBREAKING CHANGE: The /v1/users endpoint has been removed.
Use /v2/users instead.
Troubleshooting
Issue: "No staged changes found"
Cause: You haven't run git add yet.
Solution:
# Stage your changes first
git add .Or stage specific files
git add src/components/Button.tsxThen ask for commit message
Issue: Generated message is too generic
Cause: Changes are ambiguous or too broad.
Solution: Provide more context:
"Generate a commit message - this change fixes a memory leak in the cache"
"Create a commit - this adds JWT authentication support"
Issue: Wrong change type detected
Cause: File patterns don't clearly indicate intent.
Solution: Specify the type:
"Generate a 'fix' commit message"
"Create a 'refactor' commit for these changes"
Issue: Scope is incorrect
Cause: File path doesn't match your project structure.
Solution: Specify the scope:
"Generate commit with scope 'auth'"
"Create commit message for the API module"
Issue: Want to include co-authors
Solution: Ask Claude to add co-author footer:
"Generate commit and add co-author: Jane Doe "
Result:
feat(user): add profile pageCo-authored-by: Jane Doe
Integration with Tools
Commitlint
Validate generated messages:
npm install -g @commitlint/cli @commitlint/config-conventional.commitlintrc.json
{
"extends": ["@commitlint/config-conventional"]
}
Husky
Enforce validation on commit:
npm install -g husky.husky/commit-msg
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"npx --no -- commitlint --edit "$1"
Semantic Release
Automate versioning and changelog:
npm install -g semantic-releaseAutomatically generates:
- Version numbers from commit types
- CHANGELOG.md from commit messages
- Git tags
- GitHub releases
Conventional Changelog
Generate changelog manually:
npm install -g conventional-changelog-cliconventional-changelog -p angular -i CHANGELOG.md -s
Examples of Good vs Bad Commits
β Bad (Before this skill)
update stuff
fix bug
wip
changes
asdf
updated component
β Good (With this skill)
feat(auth): implement JWT token refresh mechanismAdds automatic token refresh before expiration to prevent
session interruptions. Includes retry logic and error handling.
fix(api): prevent race condition in user data fetch
Adds mutex lock to ensure sequential processing of concurrent
user data requests. Fixes issue where stale data could overwrite
fresh data.
docs(readme): add installation instructions for Windows
Includes PowerShell-specific commands and troubleshooting
section for common Windows installation issues.
Advanced Usage
Multi-file Commits
When you stage multiple files:
git add src/components/Button.tsx src/components/Input.tsx src/styles/forms.css
Claude will:
1. Identify the common scope (e.g., forms or components)
2. List major changes in the body
3. Keep the subject line focused on the primary change
Monorepo Support
For monorepos, specify the workspace:
"Generate commit for the @myapp/frontend package"
"Create commit scoped to the api workspace"
Result:
feat(frontend): add dark mode toggleor
feat(api): add rate limiting middleware
Branch Name Context
Claude uses your branch name for additional context:
feature/USER-123 β Adds "Closes USER-123" footerfix/login-error β Prefers fix typedocs/api-reference β Prefers docs typeWhy Conventional Commits Matter
For Your Team
For Automation
For You
Related Resources
Real-World Examples
Linux Kernel Style (Adapted)
fix(mm): prevent use-after-free in page cacheThe page cache could reference freed memory under heavy load.
Add proper reference counting to prevent the issue.
Fixes: abc1234 ("mm: optimize page cache")
Reported-by: security@kernel.org
React Repository Style
feat(hooks): add useTransition hookAdds new concurrent rendering hook for deferring state updates.
Includes TypeScript types and comprehensive test coverage.
Related: #18796
Your Projects
This skill adapts to your project's style while maintaining conventional commits structure.
Pro Tip: After using this skill for a week, you'll start writing better commit messages naturally - it's a great learning tool!
License: MIT-0 (Public Domain)
βοΈ Configuration
Optional: Customize Commit Style
While this skill uses Conventional Commits by default, you can customize the style in your conversation:
"Generate a commit message following Angular style"
"Create a commit using Gitmoji format with emojis"
"Write a detailed commit message with bullet points in the body"
Optional: Set Default Scope
If you're working in a monorepo or specific module:
"Generate commit messages with scope 'frontend' for this session"
"All my commits should have scope 'api'"
Optional: Link to Issue Tracker
If your branch name includes issue numbers:
# Branch: feature/USER-123-add-profile
Generated message will include:
#
feat(user-profile): add user profile component
#
Closes USER-123
π Tips & Best Practices
For Best Results
1. Stage related changes together: Don't mix features and fixes in one commit 2. Review the generated message: Claude generates smart defaults, but you can refine 3. Add context if needed: Mention "this fixes a race condition" for better descriptions 4. Use meaningful branch names: Branch names help Claude understand context 5. Keep commits atomic: One logical change per commit works best
Tips for Teams
conventional-changelog to automate release notessemantic-release to version from commits