Never write a git commit message again. Stage your changes, run
ai-commit, and let AI write a Conventional Commit message from your diff.
$ git add src/auth.py tests/test_auth.py
$ ai-commit
Staged: src/auth.py, tests/test_auth.py +47 -12
╭─ Suggested commit message ─────────────────────────────────────╮
│ feat(auth): add JWT refresh token rotation with Redis backing │
│ │
│ Implements sliding window refresh tokens. Old tokens are │
│ invalidated on use to prevent replay attacks. │
╰──────────────────────────────────────────────────────────────────╯
Action [commit/edit/abort]: commit
✓ Committed!
- Conventional Commits format —
feat,fix,refactor,chore, etc. — automatically - Multiple backends — OpenAI GPT-4o-mini, Anthropic Claude, local Ollama (no API key)
- Git hook support — auto-generates message on every
git commit, opens editor to review - Generate alternatives — ask for N options and pick your favourite
- Edit before commit — drop into
$EDITORif you want to tweak - Per-project config — set default backend/model in
.ai-commit - Dry run mode — see the message without committing
pip install ai-commit
# With OpenAI backend (default)
pip install "ai-commit[openai]"
# With Anthropic backend
pip install "ai-commit[anthropic]"
# Everything
pip install "ai-commit[all]"cp .env.example .env
# Add your API key(s)Or set env vars directly:
export OPENAI_API_KEY=sk-...git add .
ai-commitai-commit --backend anthropic
ai-commit --backend ollama --model llama3.2 # no API key needed
ai-commit --backend openai --model gpt-4oai-commit --count 3ai-commit --dry-runai-commit --yes# Install in current repo
ai-commit hook install
# Uninstall
ai-commit hook uninstallAfter installing the hook, every git commit automatically generates an AI message. Your $EDITOR opens so you can review and edit it before the commit finalises.
# Per-project
ai-commit config --backend anthropic --model claude-3-haiku-20240307
# Global
ai-commit config --backend ollama --model llama3.2 --global~/.ai-commit or .ai-commit in your project root:
{
"backend": "openai",
"model": "gpt-4o-mini"
}| Backend | Model | Requires |
|---|---|---|
openai |
gpt-4o-mini (default), gpt-4o | OPENAI_API_KEY |
anthropic |
claude-3-haiku (default), claude-3-5-sonnet | ANTHROPIC_API_KEY |
ollama |
llama3.2 (default), mistral, phi3… | Local Ollama running |
ai-commit/
├── ai_commit/
│ ├── cli.py # Click CLI (generate / hook / config)
│ ├── diff.py # Git staged diff extraction
│ ├── generator.py # OpenAI / Anthropic / Ollama backends
│ └── hook.py # Git prepare-commit-msg hook installer
├── requirements.txt
└── setup.py
PRs welcome! Adding a new LLM provider is as simple as adding a class in generator.py.
MIT © bhupendra05