aicommit2
v2.5.11
Published
A Reactive CLI that generates commit messages for Git and Jujutsu with various AI
Maintainers
Keywords
Readme
Table of Contents
- Quick start
- Introduction
- Key features
- Supported providers
- Setup
- How it works
- Version Control Systems
- Usage
- Integrations
- Configuration
- General Settings
- Logging
- Custom Prompt Template
- Code Review
- Watch Commit Mode
- Upgrading
- Contributing
Quick start
# Install via Homebrew (macOS/Linux)
brew install aicommit2
# Or install via npm
npm install -g aicommit2
# Set up AI providers (interactive wizard)
aicommit2 setup
# Or configure manually
aicommit2 config set OPENAI.key=<your-key>
# Use in your Git repository
git add .
aicommit2
# Also works with YADM and Jujutsu repositories (auto-detected)
yadm add <file>
aicommit2Introduction
aicommit2 automatically generates commit messages using AI. It supports Git, YADM (Yet Another Dotfiles Manager), and Jujutsu (jj) repositories with automatic detection. AICommits inspired the core functionalities and architecture of this project.
Key features
- VCS Support: Works with Git, YADM, and Jujutsu repositories
- Multi-AI Support: Integrates with OpenAI, Anthropic Claude, Google Gemini, Mistral AI, Cohere, Groq, Ollama and more
- OpenAI API Compatibility: Support for any service that implements the OpenAI API specification
- Reactive CLI: Enables simultaneous requests to multiple AIs and selection of the best commit message
- Code Review: AI-powered structured code review with severity levels before committing
- Git Hook Integration: Can be used as a prepare-commit-msg hook
- Custom Prompt: Supports user-defined system prompt templates
Supported Providers
| Provider | Default Model | Documentation |
|----------|---------------|---------------|
| OpenAI | gpt-4o-mini | Guide |
| Copilot SDK (Preview) | gpt-4.1 | Guide |
| OpenRouter | openrouter/auto | Guide |
| Anthropic | claude-sonnet-4-20250514 | Guide |
| Gemini | gemini-3-flash-preview | Guide |
| Mistral | mistral-small-latest | Guide |
| Codestral | codestral-latest | Guide |
| Cohere | command-a-03-2025 | Guide |
| Groq | llama-3.3-70b-versatile | Guide |
| Perplexity | sonar | Guide |
| DeepSeek | deepseek-chat | Guide |
| GitHub Models | openai/gpt-4o-mini | Guide |
| Bedrock | anthropic.claude-haiku-4-5-20251001-v1:0 | Guide |
| Ollama | (user configured) | Guide |
📘 For OpenAI-compatible APIs, see Compatibility Guide
📘 GitHub note:
COPILOT_SDKuses Copilot CLI authentication (Copilot Requestspermission), whileGITHUB_MODELSuses GitHub Models API tokens (models: read).📘 Copilot SDK stable setup example (
config.ini+ env): Copilot SDK Guide.
Setup
- Install aicommit2:
Via Homebrew (recommended for macOS/Linux):
brew install aicommit2Via npm:
npm install -g aicommit2⚠️ For npm installation, the minimum supported version of Node.js is v18. Check your Node.js version with
node --version.
- Configure your AI provider(s) (at least ONE provider must be configured):
Option A: Interactive setup wizard (recommended)
aicommit2 setup👉 The setup wizard guides you through provider selection, API key entry, and model configuration in one step.
Option B: Manual configuration
aicommit2 config set OPENAI.key=<your key>
aicommit2 config set ANTHROPIC.key=<your key>
# ... (similar commands for other providers)- Run aicommit2 in your Git or Jujutsu repository:
# For Git repositories
git add <files...>
aicommit2
# Works with Jujutsu too (auto-detected, no staging needed)
aicommit2👉 Tip: Use the
aic2alias ifaicommit2is too long for you.
Alternative Installation Methods
Nix Installation
If you use the Nix package manager, aicommit2 can be installed directly using the provided flake:
# Install temporarily in your current shell
nix run github:tak-bro/aicommit2
# Install permanently to your profile
nix profile install github:tak-bro/aicommit2
# Use the shorter alias
nix run github:tak-bro/aic2 -- --helpUsing in a Flake-based Project
Add aicommit2 to your flake inputs:
{
# flake.nix configuration file
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
aicommit2.url = "github:tak-bro/aicommit2";
};
# Rest of your flake.nix file
}# Somewhere where you define your packages
{pkgs, inputs, ...}:{
environment.systemPackages = [inputs.aicommit2.packages.x86_64-linux.default];
# Or home packages
home.packages = [inputs.aicommit2.packages.x86_64-linux.default];
}Development Environment
To enter a development shell with all dependencies:
nix develop github:tak-bro/aicommit2After setting up with Nix, you'll still need to configure API keys as described in the Setup section.
From Source
git clone https://github.com/tak-bro/aicommit2.git
cd aicommit2
npm run build
npm install -g .Via VSCode Devcontainer
Add feature to
your devcontainer.json file:
"features": {
"ghcr.io/kvokka/features/aicommit2:1": {}
}How it works
This CLI tool runs git diff to grab all your latest code changes, sends them to configured AI, then returns the AI generated commit message.
If the diff becomes too large, AI will not function properly. If you encounter an error saying the message is too long or it's not a valid commit message, try reducing the commit unit.
Version Control Systems
Git (Primary)
# Standard Git workflow
git add <files>
aicommit2- Uses
git diff --cachedfor staged changes - Supports all Git features and hooks
- Requires staging changes before commit
YADM Support
aicommit2 supports YADM (Yet Another Dotfiles Manager) for managing dotfiles:
# Standard YADM workflow
yadm add <files>
aicommit2Features:
- Automatic detection of YADM repositories (prioritized before Git)
- Uses
yadmcommands instead ofgitfor all operations - Supports all YADM features including encryption and alternate files
- Works with dotfiles in
$HOMEdirectory - Hook installation:
aicommit2 hook install(installs to~/.config/yadm/hooks/) - Note: Watch mode (
--watch-commit) is not supported for YADM repositories
Installation:
# macOS
brew install yadm
# Linux
apt-get install yadm # Debian/Ubuntu
dnf install yadm # Fedora
# Initialize repository
yadm init
# or clone existing dotfiles
yadm clone <url>Jujutsu Support
aicommit2 also supports Jujutsu (jj) repositories:
# Automatic jj detection (no staging needed)
aicommit2
# Force Git when both .jj and .git exist (for colocated repos)
FORCE_GIT=true aicommit2
# or
aicommit2 config set forceGit=trueFeatures:
- Automatic detection of
.jjrepositories (prioritized over Git since jj v0.34.0+ uses colocated repos) - Uses
jj describeto set commit message (does NOT runjj newby default) - Supports Jujutsu's fileset syntax for file exclusions
- Works seamlessly with colocated Git repositories
jj new Behavior:
By default, aicommit2 only runs jj describe to set the commit message, without creating a new changeset. This matches the workflow of many Jujutsu users who prefer to manually control when to run jj new.
To automatically run jj new after describing (mimics jj commit behavior):
# Via CLI flag
aicommit2 --jj-auto-new
# Or via config (persistent)
aicommit2 config set jjAutoNew=trueInstallation:
# macOS
brew install jj
# Linux/Windows
cargo install jj-cli
# Initialize repository
jj initDetection Priority
- CLI flags (highest priority - overrides everything):
--git: Force use Git--yadm: Force use YADM--jj: Force use Jujutsu
- Environment variables:
FORCE_GIT=true: Forces GitFORCE_YADM=true: Forces YADMFORCE_JJ=true: Forces Jujutsu
- Config:
aicommit2 config set forceGit=true(forces Git) - Auto-detection:
- Jujutsu repository (checked first - since jj v0.34.0+, repos are colocated with .git)
- Git repository (checked for .git directories - regular Git repos)
- YADM repository (checked last - for dotfiles in $HOME without .git directory)
Force VCS Selection
Sometimes you may want to use a specific VCS even when multiple are available:
# Use YADM in a directory that has both .git and YADM tracking
cd ~/my-project # Has .git directory
aicommit2 --yadm # Forces YADM usage instead of Git
# Use Git explicitly
aicommit2 --git
# Use Jujutsu explicitly
aicommit2 --jjUsage
CLI mode
You can call aicommit2 directly to generate a commit message for your staged changes:
git add <files...>
aicommit2aicommit2 passes down unknown flags to git commit, so you can pass in commit flags.
For example, you can stage all changes in tracked files as you commit:
aicommit2 --all # or -aCLI Options
Run aicommit2 --help to see all available options grouped by category.
Message Options
--localeor-l: Locale to use for the generated commit messages (default: en)--generateor-g: Number of messages to generate (default: 1)- Warning: This uses more tokens, meaning it costs more.
--typeor-t: Git commit message format (default: conventional). It supportsconventionalandgitmoji--promptor-p: Custom prompt to fine-tune the AI generation--include-bodyor-i: Force include commit body in all generated messages (default: false)
Behavior
--allor-a: Automatically stage changes in tracked files for the commit (default: false)--confirmor-y: Skip confirmation when committing after message generation (default: false)--auto-selector-s: Automatically select when only one message is generated (default: false)--editor-e: Open the AI-generated commit message in your default editor (default: false)--clipboardor-c: Copy the selected message to clipboard and exit without committing (default: false)--dry-runor-d: Generate commit message without committing (default: false)- Useful for reviewing messages before manual commit (e.g., with GitHub Desktop)
--outputor-o: Output format for non-interactive mode (default: none)- Use
--output jsonfor LazyGit integration
- Use
VCS Selection
--git: Force use Git (overrides auto-detection)--yadm: Force use YADM (overrides auto-detection)--jj: Force use Jujutsu (overrides auto-detection)--jj-auto-new: Runjj newafterjj describe(default: false)
Hook Integration
--hook-mode: Run as a Git hook withprepare-commit-msg(default: false)--pre-commit: Run in pre-commit framework mode (default: false)
Formatting & Debug
--excludeor-x: Files to exclude from AI analysis--disable-lowercase: Preserve original casing of commit messages (default: false)--verboseor-v: Enable verbose logging for debugging (default: false)
Examples:
# Generate multiple commit messages with clipboard and file exclusions
aicommit2 --locale "jp" --all --type "conventional" --generate 3 --clipboard --exclude "*.json" --exclude "*.ts"
# Generate and edit a commit message
aicommit2 --edit --type conventional # or gitmoji
# Generate message without committing (dry-run)
aicommit2 --dry-run # or -d
# Dry-run with clipboard (generate, select, then copy)
aicommit2 -d -c
# Enable verbose logging for debugging
aicommit2 --verbose # or -vCommands
In addition to the main commit message generation, aicommit2 provides several utility commands:
| Command | Description |
|---------|-------------|
| aicommit2 setup | Interactive setup wizard for configuring AI providers |
| aicommit2 config | Manage configuration (get, set, list, del) |
| aicommit2 doctor | Check health status of AI providers |
| aicommit2 stats | View usage statistics and performance metrics |
| aicommit2 hook | Install/uninstall Git prepare-commit-msg hook |
| aicommit2 log | Manage log files |
| aicommit2 github-login | Login to GitHub for GitHub Models access |
# Interactive setup wizard
aicommit2 setup
# Configuration management
aicommit2 config set OPENAI.key=<your-key>
aicommit2 config get OPENAI
aicommit2 config list
# Health check
aicommit2 doctor
# Statistics
aicommit2 stats
aicommit2 stats -d 7 # Last 7 days
aicommit2 stats clear # Clear all stats
# Git hook
aicommit2 hook install
aicommit2 hook uninstallGitHub Models tip: use
aicommit2 github-loginand setGITHUB_MODELS.modelinpublisher/modelformat (for example,openai/gpt-5).
Integrations
LazyGit
aicommit2 supports non-interactive JSON output mode for seamless integration with LazyGit.
Setup
Use the --output json flag to get AI-generated commit messages in JSON Lines format:
aicommit2 --output json
# Output: {"subject":"feat: add user authentication","body":""}
# Output: {"subject":"fix: resolve login bug","body":"Fixes issue with session handling"}Each line is a separate JSON object with subject and body fields, compatible with LazyGit's menuFromCommand prompt type.
LazyGit Configuration
Add the following to your LazyGit config file (~/.config/lazygit/config.yml or ~/Library/Application Support/lazygit/config.yml on macOS):
customCommands:
# Quick commit with AI-generated subject (c in files panel)
- key: "c"
context: "files"
description: "Generate commit message with aicommit2"
prompts:
- type: "menuFromCommand"
title: "Select commit message"
key: "Commit"
command: "aicommit2 --output json"
filter: '"subject":"(?P<subject>[^"]+)","body":"(?P<body>[^"]*)"'
valueFormat: '{{ .subject }}<SEP>{{ .body }}'
labelFormat: '{{ .subject }}'
output: "terminal"
command: bash -c 'MSG="{{ .Form.Commit }}" && SUBJ="${MSG%%<SEP>*}" && BODY="${MSG#*<SEP>}" && git commit -e -m "$SUBJ" ${BODY:+-m "$BODY"}'Note: This overrides LazyGit's default
c(commit) key. You can change the key to another value (e.g.,<c-a>) if you prefer to keep the default behavior.
Usage in LazyGit
- Stage your changes in LazyGit
- Press
cto generate AI commit messages and select one - The editor opens with the selected message for final review
Advanced: fzf Preview with Body
For detailed commit messages with subject + body, use the fzf-based approach. This uses --include-body (-i) flag to generate detailed body content and shows a preview window before committing.
Requirements: jq and fzf must be installed (brew install jq fzf).
First, create the script file at ~/.config/lazygit/scripts/aicommit_fzf.sh (or ~/Library/Application Support/lazygit/scripts/ on macOS):
#!/usr/bin/env bash
set -euo pipefail
for cmd in aicommit2 jq fzf; do
if ! command -v "$cmd" >/dev/null 2>&1; then
echo "$cmd is required"
exit 1
fi
done
results_file="$(mktemp -t lazygit-aicommit-results.XXXXXX)"
trap 'rm -f "$results_file"' EXIT INT TERM
selected="$(
echo | fzf \
--prompt="AI commit> " \
--header="Select a message" \
--height=100% \
--layout=reverse \
--info=inline \
--with-nth=2.. \
--delimiter=$'\t' \
--with-shell="bash --noprofile --norc -c" \
--preview-window="right:60%:wrap" \
--preview "jq -r '.[ {1} ] | \"\(.subject)\n\n\(.body)\"' $results_file" \
--bind "load:unbind(load)+reload-sync#aicommit2 -i --output json 2>/dev/null | jq -s '.' > $results_file && jq -r 'to_entries[] | \"\\(.key)\\t\\(.value.subject)\"' $results_file#"
)" || exit 0
[ -n "$selected" ] || exit 0
index="${selected%%$'\t'*}"
subject="$(jq -r ".[$index].subject" "$results_file")"
body="$(jq -r ".[$index].body" "$results_file")"
git commit -e -m "$subject" -m "$body"Make it executable: chmod +x ~/.config/lazygit/scripts/aicommit_fzf.sh
Then add this to your LazyGit config:
customCommands:
# Long commit with fzf preview (Shift+C in files panel)
- key: "C"
context: "files"
description: "Generate commit message (long) with aicommit2"
output: "terminal"
command: "/path/to/aicommit_fzf.sh" # Update with your script pathThanks to @peinan for this configuration! See the original discussion and dotfiles (config.yml, aicommit_fzf.sh) for reference.
Git Hooks
You can integrate aicommit2 with Git via the prepare-commit-msg hook. This lets you use Git like you normally would, and edit the commit message before committing.
Automatic Installation
In the Git repository you want to install the hook in:
aicommit2 hook installManual Installation
If you prefer to set up the hook manually, create or edit the .git/hooks/prepare-commit-msg file:
#!/bin/sh
# your-other-hook "$@"
aicommit2 --hook-mode "$@"Make the hook executable:
chmod +x .git/hooks/prepare-commit-msgUse with a custom core.hooksPath
If you are using husky or have configured a custom core.hooksPath, update the corresponding hooks file instead. For Husky users, this file is .husky/prepare-commit-message.
Integration with pre-commit Framework
If you're using the pre-commit framework, you can add aicommit2 to your .pre-commit-config.yaml:
repos:
- repo: local
hooks:
- id: aicommit2
name: AI Commit Message Generator
entry: aicommit2 --pre-commit
language: node
stages: [prepare-commit-msg]
always_run: trueMake sure you have:
- Installed pre-commit:
brew install pre-commit - Installed aicommit2 globally:
npm install -g aicommit2 - Run
pre-commit install --hook-type prepare-commit-msgto set up the hook
Note: The
--pre-commitflag is specifically designed for use with the pre-commit framework and ensures proper integration with other pre-commit hooks.
Uninstall
In the Git repository you want to uninstall the hook from:
aicommit2 hook uninstallOr manually delete the .git/hooks/prepare-commit-msg file.
Health Check
Use the doctor command to check the status of your configured AI providers:
aicommit2 doctorExample output:
🩺 aicommit2 Health Check
Providers:
✅ OPENAI API key configured
✅ OLLAMA Running (Host: http://localhost:11434)
⏭️ ANTHROPIC Not configured
⚠️ GEMINI API key configured
Summary: 2 healthy, 0 error, 1 warning, 1 skippedStatus icons:
- ✅ Healthy: Provider is properly configured
- ⚠️ Warning: Provider has issues (e.g., Ollama not running)
- ❌ Error: Provider configuration has errors
- ⏭️ Skipped: Provider is not configured
Statistics
Use the stats command to view AI request statistics and performance metrics:
aicommit2 statsExample output:
📊 aicommit2 Statistics
Period: 3/16/2026 - 3/17/2026
Overview:
Total requests: 144
Success rate: 60.4%
Avg response time: 1.3s
Provider Usage:
Provider Rate Bar Cnt Selected Time
GROQ 100% ████████████████████ 48 1 (2.1%) 732ms
OPENAI 0% ░░░░░░░░░░░░░░░░░░░░ 46 0 514ms
GITHUB_MODELS 96% ███████████████████░ 25 0 2.0s
GEMINI 29% ██████░░░░░░░░░░░░░░ 14 0 2.8sColumns:
- Rate: Success rate (bar color: 🟢 ≥80%, 🟡 50-79%, 🔴 <50%)
- Cnt: Total request count
- Selected: How many times you chose this provider's message
Options:
aicommit2 stats -d 7- Show statistics for the last 7 daysaicommit2 stats clear- Clear all statistics
Statistics are stored locally at ~/.config/aicommit2/stats.json. Use aicommit2 stats clear to reset.
Configuration
aicommit2 supports configuration via command-line arguments, environment variables, and a configuration file. Settings are resolved in the following order of precedence:
- Command-line arguments
- Environment variables
- Configuration file
- Default values
Configuration File Location
aicommit2 follows the XDG Base Directory Specification for its configuration file. The configuration file is named config.ini and is in INI format. It is resolved in the following order of precedence:
AICOMMIT_CONFIG_PATHenvironment variable: If this environment variable is set, its value is used as the direct path to the configuration file.$XDG_CONFIG_HOME/aicommit2/config.ini: This is the primary XDG-compliant location. If$XDG_CONFIG_HOMEis not set, it defaults to~/.config/aicommit2/config.ini.~/.aicommit2: This is a legacy location maintained for backward compatibility.
The first existing file found in this order will be used. If no configuration file is found, aicommit2 will default to creating a new config.ini file in the $XDG_CONFIG_HOME/aicommit2/ directory.
You can find the path of the currently loaded configuration file using the config path command:
aicommit2 config pathEnvironment Variable Expansion in Config File
You can use environment variables in your configuration file values. Both $VAR and ${VAR} syntax are supported.
Example config.ini:
[OPENAI]
key=$OPENAI_API_KEY
url=${CUSTOM_API_URL}/v1OpenRouter example:
logging=true
generate=1
locale=ru
maxTokens=4096
temperature=0.2
[OPENROUTER]
envKey=OPENROUTER_BASE_TOKEN
model=stepfun/step-3.5-flash:free
url=https://openrouter.ai
path=/api/v1/chat/completions
systemPromptPath=prompts/aicommit_prompt.txt
responseFormat.type=json_object
provider.allow_fallbacks=true
provider.require_parameters=falseIf systemPromptPath is relative, it is resolved relative to the config file
location.
Nested OpenRouter objects such as responseFormat and provider can be written
directly in config.ini using dotted keys, or set with JSON via aicommit2 config set.
Reading and Setting Configuration
- READ:
aicommit2 config get [<key> [<key> ...]] - SET:
aicommit2 config set <key>=<value> - DELETE:
aicommit2 config del <config-name>
Example:
# Get all configurations
aicommit2 config get
# Get specific configuration
aicommit2 config get OPENAI
aicommit2 config get GEMINI.key
# Set configurations
aicommit2 config set OPENAI.generate=3 GEMINI.temperature=0.5
# Delete a configuration setting or section
aicommit2 config del OPENAI.key
aicommit2 config del GEMINI
aicommit2 config del timeoutEnvironment Variables
You can configure API keys using environment variables. This is particularly useful for CI/CD environments or when you don't want to store keys in the configuration file.
# OpenAI
OPENAI_API_KEY="your-openai-key"
# Anthropic
ANTHROPIC_API_KEY="your-anthropic-key"
# Google
GEMINI_API_KEY="your-gemini-key"
# Mistral AI
MISTRAL_API_KEY="your-mistral-key"
CODESTRAL_API_KEY="your-codestral-key"
# Other Providers
COHERE_API_KEY="your-cohere-key"
GROQ_API_KEY="your-groq-key"
PERPLEXITY_API_KEY="your-perplexity-key"
DEEPSEEK_API_KEY="your-deepseek-key"Note: You can customize the environment variable name used for the API key with the
envKeyconfiguration property for each service.
Usage Example:
OPENAI_API_KEY="your-openai-key" ANTHROPIC_API_KEY="your-anthropic-key" aicommit2Note: Environment variables take precedence over configuration file settings.
How to Configure in detail
aicommit2 offers flexible configuration options for all AI services, including support for specifying multiple models. You can configure settings via command-line arguments, environment variables, or a configuration file.
Command-line arguments: Use the format
--[Model].[Key]=value. To specify multiple models, use the--[Model].model=model1,model2format.aicommit2 --OPENAI.locale="jp" --GEMINI.temperature="0.5" --OPENAI.model="gpt-4o-mini,gpt-3.5-turbo"Configuration file: Refer to Configuration File Location or use the
setcommand. For array-like values likemodel, you can use either themodel=model1,model2comma-separated syntax or themodel[]=syntax for multiple entries. This applies to all AI services.# General Settings logging=true generate=2 temperature=1.0 # Model-Specific Settings [OPENAI] key="<your-api-key>" temperature=0.8 generate=1 model="gpt-4o-mini,gpt-3.5-turbo" systemPromptPath="<your-prompt-path>" [GEMINI] key="<your-api-key>" generate=5 includeBody=true model="gemini-3-flash-preview,gemini-3.1-pro-preview" [OLLAMA] temperature=0.7 model[]=llama3.2 model[]=codestral
The priority of settings is: Command-line Arguments > Environment Variables > Model-Specific Settings > General Settings > Default Values.
Configuration Examples
aicommit2 config set \
generate=2 \
topP=0.8 \
maxTokens=1024 \
temperature=0.7 \
OPENAI.key="sk-..." OPENAI.model="gpt-4o-mini" OPENAI.temperature=0.5 \
ANTHROPIC.key="sk-..." ANTHROPIC.model="claude-sonnet-4-20250514" ANTHROPIC.maxTokens=2000 \
MISTRAL.key="your-key" MISTRAL.model="mistral-small-latest" \
OLLAMA.model="llama3.2" OLLAMA.numCtx=4096 OLLAMA.watchMode=true🔍 Detailed Support Info: Check each provider's documentation for specific limits and behaviors:
General Settings
For detailed information about all available settings, see the General Settings documentation.
| Setting | Description | Default |
| ---------------------- | ------------------------------------------------------------------- | ------------ |
| locale | Locale for the generated commit messages | en |
| generate | Number of commit messages to generate | 1 |
| type | Type of commit message (conventional / gitmoji) | conventional |
| maxLength | Maximum character length of the commit subject | 50 |
| timeout | Request timeout (milliseconds) | 10000 |
| temperature | Model's creativity (0.0 - 2.0) | 0.7 |
| maxTokens | Maximum number of tokens to generate | 1024 |
| includeBody | Whether the commit message includes body | false |
| codeReview | Enable automated code review before commit | false |
| codeReviewPromptPath | Path to custom code review prompt file | - |
| autoCopy | Auto-copy commit message to clipboard (commits normally) | false |
| useStats | Enable usage statistics tracking | true |
| statsDays | Days to retain statistics data (auto-cleanup) | 30 |
| systemPromptPath | Path to custom system prompt file | - |
| stream | Experimental. Enable streaming for real-time commit message generation | false |
# Example: Set settings for a specific model
aicommit2 config set OPENAI.locale="jp"
aicommit2 config set GEMINI.temperature=0.5
aicommit2 config set ANTHROPIC.includeBody=true👉 For all settings and detailed explanations, see docs/settings.md
Available Settings by Model
| | timeout | temperature | maxTokens | topP | stream | | :-----------------------: | :-----: | :---------: | :-------: | :--: | :----: | | OpenAI | ✓ | ✓ | ✓ | ✓ | ✓ | | Anthropic Claude | ✓ | ✓ | ✓ | ✓ | ✓ | | Gemini | | ✓ | ✓ | ✓ | ✓ | | Mistral AI | ✓ | ✓ | ✓ | ✓ | | | Codestral | ✓ | ✓ | ✓ | ✓ | | | Cohere | ✓ | ✓ | ✓ | ✓ | | | Groq | ✓ | ✓ | ✓ | ✓ | ✓ | | Perplexity | ✓ | ✓ | ✓ | ✓ | | | DeepSeek | ✓ | ✓ | ✓ | ✓ | ✓ | | Github Models | ✓ | ✓ | ✓ | ✓ | | | Ollama | ✓ | ✓ | | ✓ | ✓ | | OpenAI API-Compatible | ✓ | ✓ | ✓ | ✓ | ✓ |
Logging
The application utilizes two distinct logging systems to provide comprehensive insights into its operations:
1. Application Logging (Winston)
This system handles general application logs and exceptions. Its behavior can be configured through the following settings in your config.ini file:
logLevel:- Description: Specifies the minimum level for logs to be recorded. Messages with a level equal to or higher than the configured
logLevelwill be captured. - Default:
info - Supported Levels:
error,warn,info,http,verbose,debug,silly
- Description: Specifies the minimum level for logs to be recorded. Messages with a level equal to or higher than the configured
logFilePath:- Description: Defines the path to the main application log file. This setting supports date patterns (e.g.,
%DATE%) to automatically rotate log files daily. - Default:
logs/aicommit2-%DATE%.log(relative to the application's state directory, typically~/.local/state/aicommit2/logson Linux or~/Library/Application Support/aicommit2/logson macOS).
- Description: Defines the path to the main application log file. This setting supports date patterns (e.g.,
exceptionLogFilePath:- Description: Specifies the path to a dedicated log file for recording exceptions. Similar to
logFilePath, it supports date patterns for daily rotation. - Default:
logs/exceptions-%DATE%.log(relative to the application's state directory, typically~/.local/state/aicommit2/logson Linux or~/Library/Application Support/aicommit2/logson macOS).
- Description: Specifies the path to a dedicated log file for recording exceptions. Similar to
2. AI Request/Response Logging
This system is specifically designed to log the prompts and responses exchanged with AI models for review and commit generation. These logs are stored in the application's dedicated logs directory.
- Log Location: These logs are stored in the same base directory as the application logs, which is determined by the system's state directory (e.g.,
~/.local/state/aicommit2/logson Linux or~/Library/Application Support/aicommit2/logson macOS). - File Naming: Each AI log file is uniquely named using a combination of the date (
YYYY-MM-DD_HH-MM-SS) and a hash of the git diff content, ensuring easy identification and chronological order.
Enable/Disable Logging
The logging setting controls whether log files are generated. It can be configured both globally and for individual AI services:
- Global
loggingsetting: When set in the general configuration, it controls the overall application logging (handled by Winston) and acts as a default for AI request/response logging. - Service-specific
loggingsetting: You can override the globalloggingsetting for a particular AI service. Ifloggingis set tofalsefor a specific service, AI request/response logs will not be generated for that service, regardless of the global setting.
Log Management
aicommit2 generates detailed logs for debugging and tracking AI requests. You can manage these log files using the built-in log commands:
View Log Files
# List all log files with details
aicommit2 log list
# Show logs directory path
aicommit2 log pathOpen Log Directory
# Open logs directory in your file manager
aicommit2 log openClean Up Logs
# Remove all log files
aicommit2 log removeAllLog File Information
- Location: Logs are stored in your system's state directory (usually
~/.local/state/aicommit2/logson Linux/macOS) - Content: Each log file contains the git diff, system prompt, AI response, and metadata
- Naming: Files are named with timestamp and hash for easy identification
- Size: File sizes are displayed in human-readable format (B, KB, MB, GB)
Custom Prompt Template
aicommit2 supports custom prompt templates through the systemPromptPath option. This feature allows you to define your own prompt structure, giving you more control over the commit message generation process.
Using the systemPromptPath Option
To use a custom prompt template, specify the path to your template file when running the tool:
aicommit2 config set systemPromptPath="/path/to/user/prompt.txt"
aicommit2 config set OPENAI.systemPromptPath="/path/to/another-prompt.txt"For the above command, OpenAI uses the prompt in the another-prompt.txt file, and the rest of the model uses prompt.txt.
NOTE: For the
systemPromptPathoption, set the template path, not the template content
Template Format
Your custom template can include placeholders for various commit options.
Use curly braces {} to denote these placeholders for options. The following placeholders are supported:
{locale}: The language for the commit message (default: en){maxLength}: The maximum length for the commit message (default: 50){type}: The type of the commit message (conventional or gitmoji){generate}: The number of commit messages to generate (default: 1)
Example Template
Here's an example of how your custom template might look:
Generate a {type} commit message in {locale}.
The message should not exceed {maxLength} characters.
Please provide {generate} messages.
Remember to follow these guidelines:
1. Use the imperative mood
2. Be concise and clear
3. Explain the 'why' behind the changeAppended Text
Please note that the following text will ALWAYS be appended to the end of your custom prompt:
Lastly, Provide your response as a JSON array containing exactly {generate} object, each with the following keys:
- "subject": The main commit message using the {type} style. It should be a concise summary of the changes.
- "body": An optional detailed explanation of the changes. If not needed, use an empty string.
- "footer": An optional footer for metadata like BREAKING CHANGES. If not needed, use an empty string.
The array must always contain {generate} element, no more and no less.
Example response format:
[
{
"subject": "fix: fix bug in user authentication process",
"body": "- Update login function to handle edge cases\n- Add additional error logging for debugging",
"footer": ""
}
]
Ensure you generate exactly {generate} commit message, even if it requires creating slightly varied versions for similar changes.
The response should be valid JSON that can be parsed without errors.This ensures that the output is consistently formatted as a JSON array, regardless of the custom template used.
Code Review
aicommit2 includes an AI-powered code review feature that analyzes your staged changes before generating commit messages. When enabled, it provides structured feedback with severity levels and actionable suggestions.
Enable Code Review
# Enable globally
aicommit2 config set codeReview=true
# Or enable for specific providers only
aicommit2 config set OPENAI.codeReview=true
aicommit2 config set ANTHROPIC.codeReview=trueHow It Works
When codeReview is enabled, the commit flow becomes:
- Stage changes (
git add) - Run aicommit2 — code review runs automatically before commit message generation
- Review results — AI analyzes the diff and returns structured feedback
- Confirm or abort — choose to continue with the commit or fix issues first
- Generate commit messages — proceeds as normal after confirmation
Structured Review Output
Reviews are organized by severity and category:
- Severity levels:
critical,warning,suggestion,praise - Categories:
bug,security,performance,style,maintainability,other
Each review item includes a title, description, file reference, and concrete suggestion for improvement. When critical issues are found, the confirmation prompt defaults to "No" to encourage fixing before committing.
Custom Review Prompt
You can customize the code review prompt using a template file:
aicommit2 config set codeReviewPromptPath="/path/to/review-prompt.txt"
aicommit2 config set OPENAI.codeReviewPromptPath="/path/to/another-prompt.txt"The template supports the same {locale}, {type}, {generate}, {maxLength} placeholders as the commit prompt.
NOTE: When using a custom review prompt, the response format is plain text (not structured JSON). The structured severity/category output is only available with the default prompt.
WARNING: Code review runs in addition to commit message generation, which means API token usage roughly doubles per commit. If multiple providers have
codeReviewenabled, each provider performs its own review. Monitor your token usage carefully, especially with large diffs.
Watch Commit Mode

Watch Commit mode allows you to monitor Git commits in real-time and automatically perform AI code reviews using the --watch-commit flag.
aicommit2 --watch-commitThis feature only works within Git repository directories and automatically triggers whenever a commit event occurs. When a new commit is detected, it automatically:
- Analyzes commit changes
- Performs AI code review
- Displays results in real-time
For detailed configuration of the code review feature, please refer to the codeReview section. The settings in that section are shared with this feature.
⚠️ CAUTION
- The Watch Commit feature is currently experimental
- This feature performs AI analysis for each commit, which consumes a significant number of API tokens
- API costs can increase substantially if there are many commits
- It is recommended to carefully monitor your token usage when using this feature
- To use this feature, you must enable watch mode for at least one AI model:
aicommit2 config set [MODEL].watchMode="true"Upgrading
Check the installed version with:
aicommit2 --versionIf it's not the latest version, run:
# Via Homebrew
brew upgrade aicommit2
# Via npm
npm update -g aicommit2Disclaimer and Risks
This project uses functionalities from external APIs but is not officially affiliated with or endorsed by their providers. Users are responsible for complying with API terms, rate limits, and policies.
Contributing
For bug fixes or feature implementations, please check the Contribution Guide.
Contributors ✨
Thanks goes to these wonderful people (emoji key):
If this project has been helpful, please consider giving it a Star ⭐️!
Maintainer: @tak-bro
