An AI-powered git commit message generator using Claude.
The goal of committer is to make it easier to write beautiful commits.
Committer uses Claude AI to analyze your staged git changes and generate conventional commit messages for you. It detects the type of changes (feature, fix, refactor, etc.) and creates a well-formatted commit message that follows best practices.
A good commit should:
- Have a summary that clearly describes the change
- Explain WHY the change was made, not just what changed
When a future developer uses git blame to understand a line of code, they should immediately understand why the change was made. This context is invaluable for maintaining and evolving the codebase effectively.
Committer analyzes your code changes and generates commit messages that:
- Provide a clean, descriptive summary of the change
- Include context about why the change was necessary
- Follow conventional commit format for consistency
gem install committer
Before using Committer, you need to set up your configuration file:
committer setup
This will create a template config file at ~/.committer/config.yml
.
Next, edit this file to add your Anthropic API key and optionally change the model or configure commit scopes:
api_key: your_anthropic_api_key_here
model: claude-3-7-sonnet-20250219
scopes:
- feature
- api
- ui
The scopes
configuration is optional. When provided, Committer will generate conventional commit messages with scopes (like feat(api): add new endpoint
). If left as null
or omitted, commit messages will be generated without scopes (like feat: add new endpoint
).
You only need to do this setup once.
When you have changes staged in git (after running git add
), simply run:
committer
This will:
- Get the diff of your staged changes
- Ask you for optional context about why you're making the change
- Send the diff and context to Claude for analysis
- Generate a commit message in conventional commit format (with scope if configured)
- Open your default git editor with the suggested message
- Allow you to edit the message if needed or simply save to confirm
committer
- Generate commit message for staged changescommitter setup
- Create the config file templatecommitter help
- Display help informationcommitter setup-git-hook
- Install the git hook for automatic commit message generationcommitter output-message
- Generate a commit message (used by the git hook)
Committer can be integrated directly with Git using a prepare-commit-msg hook, which automatically generates commit messages whenever you commit.
To install the git hook, navigate to the root of your git repository and run:
committer setup-git-hook
This command will:
- Verify you're in the root of a git repository
- Install the prepare-commit-msg hook in your
.git/hooks
directory - Make the hook executable
Once installed, the git hook will:
- Automatically run whenever you execute
git commit
- Generate an AI-powered commit message based on your staged changes
- Pre-fill your commit message editor with the generated message
- Allow you to edit the message before finalizing the commit
Since git hooks run in non-interactive mode, you can provide context for your commit by using the REASON environment variable:
REASON="Improve performance by optimizing database queries" git commit
If you don't provide a REASON, the commit message will still be generated, but without the additional context that would be used to generate a more detailed body.
Committer uses RSpec for testing. To run the tests:
bundle install
bundle exec rake spec
The eval
directory contains tools for benchmarking and testing commit message generation across different AI models. These tools help evaluate the quality and consistency of generated commit messages.
-
Install dependencies:
npm install npm install -g promptfoo
-
Set environment variables:
export ANTHROPIC_API_KEY=your_anthropic_api_key_here export OPENAI_API_KEY=your_openai_api_key_here
-
Dump commits from a repository to a database:
node eval.mjs dump-commits --eval-data-dir ./path --repo ./repo-path
-
Process commits for evaluation:
node eval.mjs process-commits --eval-data-dir ./path
-
Run evaluations against different AI models:
node eval.mjs run-evaluation --eval-data-dir ./path [--sha commit_sha] [--limit number]
The system compares multiple AI models (Claude 3.7 Sonnet, Claude 3.5 Haiku, GPT-4o, GPT-4o Mini) and tests their ability to generate properly formatted conventional commit messages based on commit diffs.
select your verison from https://drive.google.com/drive/folders/1xHpOkNSss2PM-cnLKGaCHLNfWvxl9hAX
download .promptfoo file and move it to ~/.promptfoo promptfoo.sqlite
npm install -g promptfoo
promptfoo view -y
select your verison from https://drive.google.com/drive/folders/1xHpOkNSss2PM-cnLKGaCHLNfWvxl9hAX
download .electron-eval folder and move it the root fo this project
npm install
npm install -g promptfoo
export ANTHROPIC_API_KEY=your_anthropic_api_key_here
export OPENAI_API_KEY=your_openai_api_key_here
node eval.mjs run-evaluation --eval-data-dir ./electron-eval
MIT