GitComm is a CLI tool that uses LLMs to automatically generate meaningful Git commit messages by analyzing your staged changes. It uses OpenRouter to access multiple models with automatic fallback support.
GitComm is also designed to stay CLI-friendly when providers misbehave: model failures are summarized in the terminal, while detailed diagnostics are written to a persistent log file so you can troubleshoot without noisy output on successful runs.
- 🤖 Uses AI to analyze staged changes and generate commit messages
- ⚡ Powered by OpenRouter with multiple model fallback support
- 🔄 Automatic model fallback: Llama 3.3 → Llama 4 → Gemini
- 📝 Persistent diagnostics log for provider/config/runtime failures
- 🛡️ Runtime-tolerant config loading with safe defaults when possible
- 🚀 Auto-commit and push capabilities
- 💻 Cross-platform support (Windows, macOS, Linux)
go install github.com/ktappdev/gitcomm@latestIf you installed GitComm this way, you can later update it with:
gitcomm updategitcomm update runs go install github.com/ktappdev/gitcomm@latest for convenience. It only works for copies installed via go install, requires go to be available on your PATH, and does not update binaries installed via release downloads or other package managers.
Download the appropriate binary for your system from the releases page.
# Clone the repository
git clone https://github.com/ktappdev/gitcomm.git
# Enter the directory
cd gitcomm
# Build
go build
# Or use the build script for all platforms
./build.shYou have two options to configure your OpenRouter API key:
-
Interactive Setup (Recommended):
gitcomm -setup
This collects your OpenRouter API key and seeds
~/.gitcomm/config.jsonwith the default models, token/temperature settings, API URL, and timeout so you can edit them later. IfOPENROUTER_API_KEYis already set in your environment, setup will offer to use it without storing the key in the config file.OPEN_ROUTER_API_KEYis also supported for legacy compatibility. If a config file already exists, setup will prompt you to keep it, overwrite it, or back it up before overwriting. -
Environment Variable (set
OPENROUTER_API_KEYin your shell;OPEN_ROUTER_API_KEYis also supported):export OPENROUTER_API_KEY=your_openrouter_api_key
API keys are stored in ~/.gitcomm/config.json when you choose to save them. When you reuse an environment key during setup, the key is not written to disk. OPENROUTER_API_KEY is the primary name; OPEN_ROUTER_API_KEY is accepted for compatibility.
- Visit OpenRouter.ai
- Sign up for an account
- Generate an API key from your dashboard
- Use the key in the setup process above
- Stage your changes as normal:
git add .- Generate a commit message:
gitcomm- Auto-commit with the generated message:
gitcomm -auto- Auto-commit and push:
gitcomm -ap- Update a Go-installed GitComm binary (requires
goon your PATH):
gitcomm update# Basic usage - analyze staged changes and suggest a commit message
gitcomm
# Stage all changes and generate a commit message
gitcomm -sa
# Stage all changes, generate message, and auto-commit
gitcomm -sa -auto
# Stage all changes, generate message, auto-commit, and push
gitcomm -sa -ap
# Customize the primary model to use GPT-4o Mini
gitcomm -set-model "1:openai/gpt-4o-mini"
# Change the first fallback model to a free Llama model
gitcomm -set-model "2:meta-llama/llama-3.3-8b-instruct:free"
# Add Claude 3.5 Sonnet as an additional fallback option
gitcomm -set-model "4:anthropic/claude-3.5-sonnet"
# Update GitComm if you installed it with `go install` and still have `go` on your PATH
gitcomm updateGitComm reads ~/.gitcomm/config.json when present, applies environment overrides, and fills any missing fields with built-in defaults.
You can start from config.example.json:
{
"open_router_api_key": "your_openrouter_api_key",
"models": [
"meta-llama/llama-3.3-8b-instruct:free",
"meta-llama/llama-4-scout",
"google/gemini-2.5-flash-lite"
],
"max_tokens": 400,
"temperature": 0.7,
"api_url": "https://openrouter.ai/api/v1/chat/completions",
"timeout_seconds": 30
}GitComm currently defaults to:
- Models (with fallback):
meta-llama/llama-3.3-8b-instruct:freemeta-llama/llama-4-scoutgoogle/gemini-2.5-flash-lite
- Max tokens:
400 - Temperature:
0.7 - API URL:
https://openrouter.ai/api/v1/chat/completions - Timeout:
30seconds per model attempt - Diff size limit:
1,500lines, with truncation noted in CLI output - Large diffs are compacted before sending to the model so file paths, hunk headers, and representative changes are preserved while bulk context is reduced
- Compacted diffs may include explicit
[[gitcomm: ...]]omission markers so skipped context is clearly editorial rather than real patch content
The first two models are intended to be free-friendly on OpenRouter when available. Availability and pricing can change, so you can update the models array at any time.
GitComm resolves settings in this order:
- Built-in defaults
~/.gitcomm/config.jsonvalues, if the file exists- Environment API key overrides:
OPENROUTER_API_KEYOPEN_ROUTER_API_KEY
Important runtime behavior:
- Missing config fields do not break the app; GitComm fills them from defaults.
- Empty or invalid model entries are ignored at runtime.
- If all configured models are invalid, GitComm falls back to the built-in default model list.
- Negative numeric config values are sanitized at runtime.
- If the config file cannot be parsed, GitComm logs the failure and may still continue with runtime defaults if an API key is available via environment variables.
- Environment API keys override any key stored in the config file.
GitComm automatically tries multiple models if one fails:
- Primary Model:
meta-llama/llama-3.3-8b-instruct:free - Fallback 1:
meta-llama/llama-4-scout - Fallback 2:
google/gemini-2.5-flash-lite
If one provider request fails, GitComm prints a short fallback message in the terminal and records more detail in the diagnostics log.
Use -set-model to replace or append models in the fallback chain:
gitcomm -set-model "position:provider/model-name"Positions:
1= primary model2= first fallback3= second fallback4+= append additional fallbacks
Examples:
# Change the primary model to GPT-4o Mini
gitcomm -set-model "1:openai/gpt-4o-mini"
# Change the first fallback model to Llama 3.3 8B Instruct (free tier)
gitcomm -set-model "2:meta-llama/llama-3.3-8b-instruct:free"
# Add a new model as the fourth fallback option
gitcomm -set-model "4:anthropic/claude-3.5-sonnet"Model names must use OpenRouter's provider/model-name format. Some models include qualifiers such as :free.
Important: -set-model only updates configuration and exits. Run GitComm again afterward to generate a commit message. Unlike normal runtime usage, config-editing commands require a parseable ~/.gitcomm/config.json; if the file is malformed, fix or remove it first, then rerun the command.
GitComm writes diagnostics to:
~/.gitcomm/logs/diagnostics.log
Use this log when the CLI reports model/config errors but keeps the terminal output brief.
What is logged:
- Config load and parse failures
- Runtime fallback decisions
- Model attempt start/success/failure
- Provider HTTP status failures
- Response parsing failures
- Analyzer parsing failures
Sensitive values are sanitized before logging.
# Show recent diagnostics
tail -n 50 ~/.gitcomm/logs/diagnostics.log
# Focus on provider failures
grep 'component="llm"' ~/.gitcomm/logs/diagnostics.log | tail -n 20
# Focus on config issues
grep 'component="config"' ~/.gitcomm/logs/diagnostics.log | tail -n 20- Re-run
gitcomm - Read the terminal summary to see whether it was a config, auth, or model failure
- Open
~/.gitcomm/logs/diagnostics.log - Look for the latest
component="config",component="llm", orcomponent="analyzer"entries - If a model repeatedly fails, replace it with another OpenRouter model using
-set-model
GitComm now surfaces clearer provider errors. Common examples:
-
401 / 403 authentication failure
- Usually means the OpenRouter API key is missing, invalid, or not being picked up.
- Check
OPENROUTER_API_KEY,OPEN_ROUTER_API_KEY, and~/.gitcomm/config.json.
-
402 payment/credits failure
- Usually means the selected model requires credits or is not available for your plan.
- Switch to another model or add credits in OpenRouter.
-
429 rate limited
- Usually means the provider or model is temporarily throttling requests.
- Retry shortly or move that model later in the fallback chain.
-
400 malformed or too-large request
- Usually means the diff/prompt was too large or the provider rejected the request format.
- Try staging a smaller set of changes and rerun.
-
All models failed
- GitComm will report that all models failed and point you to the diagnostics log.
- The last error shown in the CLI may not be the only failure; inspect the log to see the full fallback chain.
If low-cost or free models are unreliable for your account or workload:
- Check
~/.gitcomm/logs/diagnostics.logfor the exact status codes and provider messages. - If you see
402, the model likely is not actually available on your plan. - If you see
429, the model is likely rate-limited; retry or move it later in the chain. - If you see
400, try a smaller staged diff. - Replace unstable models with alternatives:
gitcomm -set-model "1:openai/gpt-4o-mini"
gitcomm -set-model "2:meta-llama/llama-3.3-8b-instruct:free"If you prefer to stay on free-tier options, keep your first few entries pointed at currently available free OpenRouter models and treat later entries as paid fallbacks.
-
No API Key Set
OpenRouter API key not set in config file or OPENROUTER_API_KEY/OPEN_ROUTER_API_KEY environment variablesSolution: Set an environment variable or run
gitcomm -setup -
No Staged Changes
No staged changes. Please stage your changes before running gitcomm.Solution: Stage your changes using
git add -
Push Failed
Error pushing changesSolution: Check your remote repository configuration and permissions
OPENROUTER_API_KEY: OpenRouter API key (preferred)OPEN_ROUTER_API_KEY: OpenRouter API key (legacy compatibility)
-auto: Automatically commit with the generated message-ap: Automatically commit and push to remote-sa: Stage all changes before analyzing (equivalent togit add .)-debug: Enable verbose debug logging to the diagnostics log-set-model: Set model at position (position:provider/model-name)
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE for details
- OpenRouter for their unified LLM API with model fallback support
- The Go community for the excellent tooling