A command-line tool that generates commit messages using Large Language Models (LLMs) from various API providers.
It uses Gemini API, Mistral API, or Ollama API to generate commit messages based on the changes made in your git repository.
- Python >= 3.8
- git
- uv (Python package manager)
- API Keys (depending on provider):
cd ~/projects
git clone https://github.com/trottomv/aicommitEdit ~/.bashrc or ~/.zshrc:
export GEMINI_API_KEY=<gemini-api-key>
export MISTRAL_API_KEY=<mistral-api-key>
export ANTHROPIC_API_KEY=<anthropic-api-key>
export OLLAMA_BASE_URL=http://localhost:11434 # Optional, for custom Ollama URL
alias aicommit='uv run --no-project ~/aicommit/aicommit.py'Remember to reload your shell configuration source ~/.bashrc or open a new terminal.
After setting up the alias, you can use aicommit in your project directory:
cd ~/projects/myproject
aicommit # Uses default model
aicommit mistral-small # Use specific model
aicommit llama3.2 # Use Ollama local model
aicommit sonnet # Use Anthropic Claude Sonnet 4Available models (defined in config.json):
| Argument | Provider | Model ID |
|---|---|---|
gemini |
gemini-2.5-flash |
|
gemini-2 |
gemini-2.0-flash |
|
mistral |
Mistral | mistral-large-latest |
mistral-small |
Mistral | mistral-small-latest |
llama3.2 |
Ollama | llama3.2 |
kimi |
Ollama | kimi-k2.5:cloud |
sonnet |
Anthropic | claude-sonnet-4-20250514 |
opus |
Anthropic | claude-opus-4-20250514 |
haiku |
Anthropic | claude-3-haiku-20240307 |
Edit config.json to customize:
- Default model: Set
default_modelvalue - Base URLs: Override provider URLs (useful for proxies)
- Custom prompt: Set
prompt_templatewith{git_diff}placeholder - Add models: Add entries under
providers.{provider}.models
Example custom config:
{
"default_model": "mistral-small",
"prompt_template": "Custom: {git_diff}",
"providers": {
"ollama": {
"base_url": "http://localhost:11434"
}
}
}Use --config or -c to specify a custom config file:
aicommit --config ~/.config/aicommit/config.jsonThe commit message generated by aicommit will be opened in your default text editor.
Using vim, you can see the generated commit message before saving and committing:
