A humble but powerful Universal AI-powered git commit generator written in Go. One tool to rule all your favorite AI providers: OpenAI, Anthropic, Google Gemini, and Local LLMs (Ollama).
ai-commit helps you write consistent, high-quality commit messages by leveraging Large Language Models (LLMs) to analyze your staged changes. It supports multiple providers and offers a flexible configuration system.
- Install:
make install(orgo build -o ai-commit ./cmd/ai-commit) - Setup:
ai-commit --configure(Interactive setup wizard) - Run:
git add . && ai-commit
- Universal Provider Support: Works with OpenAI, Anthropic (Claude), Google Gemini, and Ollama (Local LLMs).
- Interactive Configuration: Easy setup wizard (
--configure) to switch providers and keys instantly. - OpenAI Compatible: Supports any API that follows OpenAI's format (Groq, DeepSeek, OpenRouter, Mistral, etc.).
- Zero-Config: Automatically generates a default configuration file.
- Custom Modes: Support for different prompt styles (e.g.,
pro,conventional). - Interactive TUI: Review, edit in your preferred editor, or regenerate the message instantly.
- Smart Filtering: Automatically ignores binaries and large lockfiles to optimize token usage.
You can easily switch providers or update your API key using the built-in wizard:
ai-commit --configureThe tool creates a config file at ~/.config/ai-commit/config.json.
1. OpenAI (or Groq, DeepSeek, OpenRouter)
{
"provider": "openai",
"api_url": "https://api.openai.com/v1/chat/completions",
"api_key": "YOUR_API_KEY",
"model_name": "gpt-4o"
}2. Anthropic (Claude)
{
"provider": "anthropic",
"api_url": "https://api.anthropic.com/v1/messages",
"api_key": "YOUR_ANTHROPIC_KEY",
"model_name": "claude-3-5-sonnet-20240620"
}3. Google Gemini
{
"provider": "gemini",
"api_key": "YOUR_GEMINI_KEY",
"model_name": "gemini-1.5-flash"
}4. Ollama (Local LLM)
{
"provider": "ollama",
"api_url": "http://localhost:11434/api/chat",
"model_name": "llama3"
}system_prompt: Override the default system instructions globally.max_diff_length: Set the maximum number of characters for the diff (default: 50,000).exclude_files: List of glob patterns to ignore (e.g.,["*.lock", "*.svg"]).
{
"system_prompt": "You are a senior developer. Write commit messages using Conventional Commits.",
"max_diff_length": 50000
}You can place a .ai-commit.json file in your project root to override global settings. This is useful for team-wide configuration (e.g., specific models or exclude patterns).
Example .ai-commit.json:
{
"model_name": "gpt-4o",
"max_diff_length": 50000,
"exclude_files": [
"package-lock.json",
"yarn.lock",
"go.sum"
],
"default_mode": "pro"
}Note: Sensitive keys (like api_key) should generally be kept in your global user config or environment variables, not committed to the repository.
- Stage your changes:
git add . - Run the tool:
ai-commit - Review the AI's suggestion:
- Press y to accept and commit.
- Press e to edit the message first.
- Press r to try generating a new one.
-m "context": Give the AI a hint (e.g.,ai-commit -m "fix UI bug").--configure: Run the interactive configuration wizard.--mode: Change the style (e.g.,ai-commit --mode troll).--install-hook: Setup a git hook to runai-commitautomatically ongit commit.--uninstall-hook: Remove the git hook.-v, --version: Show the version.
You can set up ai-commit to run automatically whenever you execute git commit (without the -m flag).
- Install the hook:
ai-commit --install-hook
- Usage:
Stage your changes (
git add .) and then simply run:git commit
ai-commitwill be triggered to generate a message for you.
Note: If you provide a message manually (e.g., git commit -m "my message"), the hook will be skipped automatically.
- Multi-backend support (OpenAI, Ollama, Anthropic, Gemini)
- Custom System Prompts via config file
- Interactive Configuration Wizard (
--configure) - Git Hook Integration (Run automatically on
git commit) - Project-specific Configuration (
.ai-commit.jsonin repository root) - Conventional Commits (Better support and automatic scope detection)
- Multi-language Support (Generate commit messages in your preferred language)
- Dry Run Mode (
--dry-runflag) - Shell Autocompletion (Bash, Zsh, Fish)
- Enhanced TUI (Polished UI experience using
bubbletea)
Contributions are welcome! Please feel free to open an issue or submit a pull request for any bugs or feature requests.
This project is licensed under the MIT License - see the LICENSE file for details.