Skip to content

trottomv/aicommit

Repository files navigation

aicommit

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.

Requirements

Installation

Clone the repository

cd ~/projects
git clone https://github.com/trottomv/aicommit

Create an alias and set up environment variables.

Edit ~/.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.

Usage

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 4

Model Selection

Available models (defined in config.json):

Argument Provider Model ID
gemini Google gemini-2.5-flash
gemini-2 Google 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

Configuration

Edit config.json to customize:

  • Default model: Set default_model value
  • Base URLs: Override provider URLs (useful for proxies)
  • Custom prompt: Set prompt_template with {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"
    }
  }
}

Custom Config File

Use --config or -c to specify a custom config file:

aicommit --config ~/.config/aicommit/config.json

Example output

The 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:

example.png

About

A command-line tool that generates commit messages using Large Language Models (LLMs) from various API providers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors