AI-powered Git commit message generator using Google Gemini. Analyzes staged changes, understands project context, and creates Conventional Commits-compliant messages.
# Install
go install github.com/in-jun/ai-commit@latest
# Configure API key
ai-commit init # Enter your Google AI Studio API key
# Use
git add .
ai-commit
- Go 1.21+
- Git 2.0+
- Google AI Studio API key
# Install Go (if needed)
brew install go # macOS
sudo apt install golang-go # Ubuntu
# Install ai-commit
go install github.com/in-jun/ai-commit@latest
# Add to PATH
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.zshrc # macOS
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> ~/.bashrc # Linux
# Install Go from https://go.dev/dl/
# Install ai-commit
go install github.com/in-jun/ai-commit@latest
# Add to PATH
$env:Path += ";$(go env GOPATH)\bin"
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$(go env GOPATH)\bin", [EnvironmentVariableTarget]::User)
Configure via ~/.ai-commit/config.yaml
:
api_key: "your-gemini-api-key"
model: "gemini-1.5-flash" # Available: flash, pro, 2.0-flash, 2.0-flash-lite
max_diff_size: 10000 # Maximum diff size in bytes
history_depth: 5 # Previous commits to analyze
color_enabled: true # Colored output
templates:
- prefix: "feat"
description: "New feature"
- prefix: "fix"
description: "Bug fix"
- prefix: "docs"
description: "Documentation"
- prefix: "refactor"
description: "Code refactoring"
# Add custom types as needed
git add <files>
ai-commit
# Review generated message
# Y/Enter: Accept and commit
# E: Edit message
# N: Cancel
Command | Description |
---|---|
ai-commit |
Generate commit message |
ai-commit init |
Initialize configuration |
ai-commit -v |
Show version |
ai-commit -h |
Show help |
Choose models based on your needs:
Model | Performance | Accuracy | Daily Limit | Use Case |
---|---|---|---|---|
gemini-1.5-flash |
⚡⚡⚡ | ★★★ | 1,500 | Default, balanced |
gemini-1.5-pro |
⚡ | ★★★★★ | 50 | Complex changes |
gemini-2.0-flash |
⚡⚡ | ★★★★ | 1,500 | Latest features |
gemini-2.0-flash-lite |
⚡⚡⚡⚡ | ★★ | 1,500 | Simple commits |
Update model in config:
model: "gemini-1.5-pro" # For complex analysis
- Context-aware: Analyzes previous commits for consistent style
- Multi-model support: Choose from 4 Gemini models
- Interactive editing: Review and modify messages before committing
- Conventional Commits: Follows industry standards
- Language detection: Adapts to project's commit language
- Customizable templates: Define project-specific commit types
=== Generated Commit Message ===
feat: implement JWT authentication middleware
Add token-based authentication system for API endpoints
- Create token validation middleware
- Implement protected route handling
- Add 401/403 error responses
- Include token refresh mechanism
What would you like to do?
[Y]es: Commit with this message
[E]dit: Edit the message
[N]o: Cancel commit
Choice [Y/e/n]:
templates:
- prefix: "security"
description: "Security updates"
- prefix: "perf"
description: "Performance improvements"
- prefix: "deploy"
description: "Deployment changes"
# Set preferred editor
export EDITOR="vim" # Linux/macOS
$env:EDITOR="code --wait" # Windows PowerShell
# Verify installation
go version
ls $(go env GOPATH)/bin/ai-commit
# Fix PATH
export PATH=$PATH:$(go env GOPATH)/bin
# Check configuration
cat ~/.ai-commit/config.yaml
# Reinitialize
ai-commit init
# Use environment variable
export API_KEY="your-key"
- Rate limit exceeded: Switch to
gemini-2.0-flash-lite
for higher limits - Complex changes failing: Use
gemini-1.5-pro
for better analysis - Timeout issues: Check network connection and API status
- Atomic commits: Stage related changes together
- Review messages: Always verify AI-generated content
- Model selection: Use appropriate model for change complexity
- Custom templates: Align with team conventions
For issues and updates: github.com/in-jun/ai-commit