AI-powered git commit message generator that analyzes your changes and creates meaningful, conventional commit messages.
✨ Multi-Provider Support: Use Claude (Anthropic), GPT (OpenAI), or local models (Ollama)
📝 Multiple Styles: Conventional commits, semantic commits, or simple messages
🎨 Interactive Mode: Edit, refine, or regenerate messages before committing
⚡ Smart Analysis: Considers file changes, diff content, and recent commit history
🔧 Configurable: Customize commit types, formats, and preferences
💰 Cost Optimized: Optional TOON format integration for reduced API costs
pip install git-aigit clone https://github.com/ajujohn2009/git-ai.git
cd git-ai
pip install -e .Run the interactive setup wizard:
git-ai setupOr manually set your API key:
# For Anthropic (recommended)
export ANTHROPIC_API_KEY=your-key-here
# For OpenAI
export OPENAI_API_KEY=your-key-hereStage your changes and run:
git add .
git-ai commitThat's it! git-ai will:
- Analyze your staged changes
- Generate a meaningful commit message
- Let you review and edit if needed
- Create the commit
# Stage changes and commit
git add .
git-ai commit# Conventional commits (default)
git-ai commit --style conventional
# Semantic commits with emojis
git-ai commit --style semantic
# Simple, straightforward messages
git-ai commit --style simple# Generate without committing
git-ai commit --dry-run
# Skip interactive editing
git-ai commit --no-edit
# Use specific provider
git-ai commit --provider openai# View all config
git-ai config-get
# Set default provider
git-ai config-set provider anthropic
# Set default style
git-ai config-set default_style conventional
# Change model
git-ai config-set model.anthropic claude-sonnet-4-20250514# View staged changes
git-ai statusfeat(auth): add JWT authentication
Implement JWT-based authentication system with refresh tokens.
Includes middleware for protecting routes and token validation.
✨ feat: add JWT authentication
Implement JWT-based authentication with refresh token support
Add JWT authentication
Implement authentication system with JWT tokens and refresh mechanism
Configuration is stored in ~/.git-ai/config.yaml.
provider: anthropic
model:
anthropic: claude-sonnet-4-20250514
openai: gpt-4-turbo-preview
ollama: llama2
commit_types:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- chore
- ci
- build
max_diff_length: 4000
temperature: 0.3
use_toon: false# Add custom commit types
git-ai config-set commit_types "feat,fix,docs,custom"
# Adjust creativity (0.0 - 1.0)
git-ai config-set temperature 0.5
# Enable TOON format for cost optimization
git-ai config-set use_toon trueWhen you run git-ai commit, you'll see:
Generated commit message:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ feat(api): add user endpoints ┃
┃ ┃
┃ Add CRUD endpoints for user ┃
┃ management with authentication ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Options:
a - Accept and commit
r - Regenerate
e - Edit manually
f - Provide feedback for refinement
c - Cancel
Install Ollama and pull a model:
ollama pull llama2Configure git-ai:
git-ai config-set provider ollama
git-ai config-set model.ollama llama2git-ai uses smart strategies to minimize API costs:
- Diff Truncation: Limits diff size to essential content
- Context Pruning: Only includes relevant recent commits
- Temperature Control: Lower temperature for more focused output
- TOON Format (optional): Uses token-optimized format for additional savings
Enable TOON:
git-ai config-set use_toon truegit clone https://github.com/ajujohn2009/git-ai.git
cd git-ai
pip install -e ".[dev]"pytest
pytest --cov=git_ai# Format code
black git_ai tests
# Lint
ruff check git_ai tests- Analyzes Changes: Reads git diff and file changes
- Gathers Context: Checks recent commits and repository state
- Generates Message: Uses LLM to create appropriate commit message
- Interactive Review: Lets you refine before committing
- Creates Commit: Applies the message and commits
| Provider | Models | Setup |
|---|---|---|
| Anthropic | Claude 4.5 (Opus, Sonnet, Haiku) | ANTHROPIC_API_KEY |
| OpenAI | GPT-4, GPT-3.5 | OPENAI_API_KEY |
| Ollama | Llama2, Mistral, etc. | Local installation |
- Python 3.9+
- Git repository
- API key (Anthropic or OpenAI) or Ollama installation
Make sure you're in a git repository:
git init # Initialize if neededStage your changes first:
git add .
# or
git add specific-file.pyVerify your API key is set:
echo $ANTHROPIC_API_KEY
# or
echo $OPENAI_API_KEYIf you hit rate limits, try:
- Using a local model with Ollama
- Reducing diff size with selective staging
- Adding delays between commits
- GitHub Actions integration
- Pre-commit hook support
- VS Code extension
- Commit message templates
- Multi-language support
- Batch processing for multiple commits
- Git hook installer
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License - see LICENSE for details.
Aju John
- Website: ajujohn.me
- GitHub: @ajujohn2009
- Inspired by conventional commits specification
- Built with Claude 4.5 for AI generation
- Uses GitPython for git operations
⭐ If you find this useful, please star the repository!
💡 Have suggestions? Open an issue or PR!