Write good git commit messages with any AI provider
Project description
ai-commit
Write good git commit messages with any AI provider.
$ ai-commit
Generating commit message...
--- Generated message ---
feat(parser): add JSON schema validation for config files
- Validate config against JSON Schema on load
- Return clear error messages for invalid config
- Add test coverage for schema validation
Create this commit? [Y/n]: y
Commit created.
Why this exists
Every other AI commit tool locks you into one provider. OpenAI only. Anthropic only. A local Ollama thing. If you switch providers, you switch tools.
ai-commit works with any provider. Same CLI, same workflow, swap the model in a config line.
Install
pip install aigitmsg
Or from source:
git clone https://github.com/Morad37/ai-commit
cd ai-commit
pip install .
Setup
Quick start (OpenAI / any OpenAI-compatible API)
export AI_COMMIT_API_KEY="sk-..."
ai-commit --setup
Other providers
export AI_COMMIT_PROVIDER="anthropic"
export AI_COMMIT_API_KEY="sk-ant-..."
export AI_COMMIT_MODEL="claude-sonnet-4-20250514"
export AI_COMMIT_PROVIDER="ollama"
export AI_COMMIT_MODEL="llama3.2"
# Ollama defaults to http://localhost:11434
export AI_COMMIT_PROVIDER="groq"
export AI_COMMIT_BASE_URL="https://api.groq.com/openai/v1"
export AI_COMMIT_MODEL="llama3-70b-8192"
Usage
# Stage all changes and generate commit
ai-commit
# Just generate a message for staged changes (no auto-stage)
ai-commit --no-stage
# Regenerate the last commit message
ai-commit --amend
# Auto-install as a git hook (runs before every commit)
ai-commit --install-hook
# Use a specific style
ai-commit --style conventional
ai-commit --style short
ai-commit --style detailed
Git hook
ai-commit --install-hook
This installs a prepare-commit-msg hook that auto-generates the commit message before your editor opens. You can still edit it. If you already wrote a message, the hook leaves it alone.
Configuration
Config file at ~/.config/ai-commit/config.json:
{
"provider": "openai",
"model": "gpt-4o-mini",
"api_key": "",
"base_url": "",
"style": "conventional",
"max_diff_lines": 200,
"language": "en"
}
All fields can be overridden via environment variables:
| Variable | Overrides |
|---|---|
AI_COMMIT_API_KEY |
api_key |
AI_COMMIT_MODEL |
model |
AI_COMMIT_BASE_URL |
base_url |
AI_COMMIT_PROVIDER |
provider |
Supported providers
- OpenAI (and any OpenAI-compatible API -- Groq, Together, Fireworks, OpenRouter, local vLLM, etc.)
- Anthropic (Claude)
- Ollama (local models)
- Custom -- set
base_urlto any OpenAI-compatible endpoint
Commit styles
| Style | Example |
|---|---|
conventional |
feat(parser): add JSON schema validation |
imperative |
Add JSON schema validation to the config parser |
short |
Add config validation |
detailed |
Multi-line with bullet points explaining each change |
How it works
- Reads the staged diff (
git diff --cached) - Sends it to your configured AI provider with a prompt tuned for commit messages
- Returns a structured commit message
- Either creates the commit or writes it to your editor via the hook
Only works in git repos. Only generates messages for staged changes (by default).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aigitmsg-0.2.0.tar.gz.
File metadata
- Download URL: aigitmsg-0.2.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b24981fffb185f46ccb3698ef112a16bb84bc55cff11e46f3f1474ba65403632
|
|
| MD5 |
04253d5fc31800fe079fcdbcf641eb94
|
|
| BLAKE2b-256 |
0bdcbbc45f6b085234f5b822626551c0dae450dbcaeb86d788dcaead48b21bf1
|
File details
Details for the file aigitmsg-0.2.0-py3-none-any.whl.
File metadata
- Download URL: aigitmsg-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29ef84411c0b06a588886b5503d45c4b38a5a501737d02baee7aff2b29f35e33
|
|
| MD5 |
93cbc055be36e19f1f0b46c8ad9f3c12
|
|
| BLAKE2b-256 |
4430217f5e932d8c57ca0f83854ce3cc1b88f4f7f6101bc5fda6e3506237e076
|