<img src="https://github.com/Nutlope/aicommits/raw/v3.4.0/github/screenshot.png" alt="AI Commits"/>
<img src="https://github.com/Nutlope/aicommits/raw/v3.4.0/aic.png" width="50" alt="AI Commits"/>
<h1 align="center">AI Commits</h1>
A CLI that writes your git commit messages for you with AI. Never write a commit message again.
The minimum supported version of Node.js is v22. Check your Node.js version with
node --version.
sh
npm install -g aicommits
sh
aicommits setup
This will guide you through:
provider config)Supported providers include:
For CI/CD environments, you can also set up configuration via the config file:
bash
aicommits config set OPENAI_API_KEY="your_api_key_here"
aicommits config set OPENAI_BASE_URL="your_api_endpoint" # Optional, for custom endpoints
aicommits config set OPENAI_MODEL="your_model_choice" # Optional, defaults to provider default
Note: When using environment variables, ensure all related variables (e.g.,
OPENAI_API_KEYandOPENAI_BASE_URL) are set consistently to avoid configuration mismatches with the config file.
This will create a .aicommits file in your home directory.
Check the installed version with:
aicommits --version
To update to the latest version, run:
aicommits update
This will automatically detect your package manager (npm, pnpm, yarn, or bun) and update using the correct command.
Alternatively, you can manually update:
npm install -g aicommits
You can call aicommits directly to generate a commit message for your staged changes:
git add <files...>
aicommits
aicommits passes down unknown flags to git commit, so you can pass in commit flags.
For example, you can stage all changes in tracked files with as you commit:
aicommits --all # or -a
👉 Tip: Use the
aicalias ifaicommitsis too long for you.
--all or -a: Automatically stage changes in tracked files for the commit (default: false)--clipboard or -c: Copy the selected message to the clipboard instead of committing (default: false)--generate or -g: Number of messages to generate (default: 1)--exclude or -x: Files to exclude from AI analysis--type or -t: Git commit message format (default: plain). Supports plain, conventional, conventional+body, gitmoji, and subject+body--prompt or -p: Custom prompt to guide the LLM behavior (e.g., specific language, style instructions)--no-verify or -n: Bypass pre-commit hooks while committing (default: false)--yes or -y: Skip confirmation when committing after message generation (default: false)Sometimes the recommended commit message isn't the best so you want it to generate a few to pick from. You can generate multiple commit messages at once by passing in the --generate <i> flag, where 'i' is the number of generated messages:
aicommits --generate <i> # or -g <i>
Warning: this uses more tokens, meaning it costs more.
You can choose from five different commit message formats:
Use the --type flag to specify the format:
aicommits --type conventional # or -t conventional
aicommits --type conventional+body # or -t conventional+body (conventional subject + body)
aicommits --type gitmoji # or -t gitmoji
aicommits --type plain # or -t plain (default)
aicommits --type subject+body # or -t subject+body (subject + body)
This feature is useful if your project follows a specific commit message standard or if you're using tools that rely on these commit formats.
You can customize the LLM's behavior with the --prompt flag to guide commit message generation:
# Write commit messages in a specific language
aicommits -p "Write commit messages in Italian"
# Focus on specific aspects of the changes
aicommits -p "Focus on performance implications of changes"
# Use a specific style or tone
aicommits -p "Use technical jargon suitable for senior developers"
# Include specific details in the message
aicommits -p "Always mention the specific function names and file paths changed"
You can also integrate aicommits with Git via the prepare-commit-msg hook. This lets you use Git like you normally would, and edit the commit message before committing.
In the Git repository you want to install the hook in:
aicommits hook install
In the Git repository you want to uninstall the hook from:
aicommits hook uninstall
sh
git add <files...>
git commit # Only generates a message when it's not passed in
If you ever want to write your own message instead of generating one, you can simply pass one in:
git commit -m "My message"
Aicommits will generate the commit message for you and pass it back to Git. Git will open it with the configured editor for you to review/edit it.
Save and close the editor to commit!
You can also configure aicommits using environment variables instead of the config file.
Example:
export OPENAI_API_KEY="sk-..."
export OPENAI_BASE_URL="https://api.example.com"
export OPENAI_MODEL="gpt-4"
aicommits # Uses environment variables
Configuration settings are resolved in the following order of precedence:
To view all current configuration options that differ from defaults, run:
aicommits config
This will display only non-default configuration values with API keys masked for security. If no custom configuration is set, it will show "(using all default values)".
To interactively select or change your AI model, run:
aicommits model
This will:
To update to the latest version, run:
aicommits update
This will:
To retrieve a configuration option, use the command:
aicommits config get <key>
For example, to retrieve the API key, you can use:
aicommits config get OPENAI_API_KEY
You can also retrieve multiple configuration options at once by separating them with spaces:
aicommits config get OPENAI_API_KEY generate
To set a configuration option, use the command:
aicommits config set <key>=<value>
For example, to set the API key, you can use:
aicommits config set OPENAI_API_KEY=<your-api-key>
You can also set multiple configuration options at once by separating them with spaces, like
aicommits config set OPENAI_API_KEY=<your-api-key> generate=3 locale=en
Your OpenAI API key or custom provider API Key
Custom OpenAI-compatible API endpoint URL.
Model to use for OpenAI-compatible providers.
The selected AI provider. Set automatically during aicommits setup. Valid values: openai, togetherai, groq, xai, openrouter, ollama, lmstudio, custom.
Default: en
The locale to use for the generated commit messages. Consult the list of codes in: https://wikipedia.org/wiki/List_of_ISO_639-1_codes.
Default: 1
The number of commit messages to generate to pick from.
Note, this will use more tokens as it generates more results.
The timeout for network requests to the OpenAI API in milliseconds.
Default: 10000 (10 seconds)
aicommits config set timeout=20000 # 20s
The maximum character length of the generated commit message.
Default: 72
aicommits config set max-length=100
Default: plain
The type of commit message to generate. Available options:
plain: Simple, unstructured commit messagesconventional: Conventional Commits format with type and scopeconventional+body: Conventional commit subject plus a body generated from the diffgitmoji: Emoji-based commit messagessubject+body: Git-style subject line plus a body generated from the diffExamples:
aicommits config set type=conventional
aicommits config set type=conventional+body
aicommits config set type=gitmoji
aicommits config set type=plain
aicommits config set type=subject+body
This CLI tool runs git diff to grab all your latest code changes, sends them to the configured AI provider (TogetherAI by default), then returns the AI generated commit message.
Video coming soon where I rebuild it from scratch to show you how to easily build your own CLI tools powered by AI.
Hassan El Mghari: @Nutlope
Riccardo Giorato: @riccardogiorato
Hiroki Osame: @privatenumber
If you want to help fix a bug or implement a feature in Issues, checkout the Contribution Guide to learn how to setup and test the project
$ claude mcp add aicommits \
-- python -m otcore.mcp_server <graph>