Nutlope/aicommits

A CLI that writes your git commit messages for you with AI

aicommits — AI-generated git commit messages

What it is: A command-line tool that writes your git commit messages for you using AI. You stage your changes, run aicommits, and it analyzes the staged diff and proposes a commit message.

Why it exists: Writing commit messages is tedious. This tool automates it, and in v5 it can use AI subscriptions you already pay for (Claude, ChatGPT via Codex, OpenCode Go) instead of requiring a separate API key.


Core workflow

  1. Install: npm install -g aicommits (requires Node.js v22 or newer)
  2. Set up: Run aicommits setup to choose your AI provider. It detects subscriptions already logged in on your machine (Claude CLI, Codex CLI, OpenCode Go key) and lists them first. For providers that need one, it walks you through getting an API key.
  3. Use: git add <files> then run aicommits. It generates a message, shows it to you, and commits when you confirm.

Key features

  • Use subscriptions you already have: If you're logged into Claude Code or Codex, or have an OpenCode Go plan, no API key is needed. aicommits runs your installed CLI (Claude or Codex) through its SDK — read-only, no tools, no shell access, no saved sessions. It never reads or copies your credentials; login always happens in the vendor's own CLI.
  • Many providers: Together AI (recommended default), Claude Agent, Codex, OpenCode Go, OpenAI, Anthropic, Groq, xAI, OpenRouter, Ollama (local), LM Studio (local), or any custom OpenAI-compatible endpoint.
  • Multiple commit message formats: plain (default), conventional (Conventional Commits), conventional+body, gitmoji (emoji-based), or subject+body.
  • Generate multiple options: --generate <n> produces several messages to pick from (costs more tokens).
  • Custom prompts: --prompt lets you steer the AI, e.g., "Write commit messages in Italian" or "Focus on performance implications."
  • Git hook integration: aicommits hook install adds a prepare-commit-msg hook so git commit automatically generates a message you can edit before committing. Uninstall with aicommits hook uninstall.
  • CI/CD support: Set config via commands like aicommits config set OPENAI_API_KEY="..." instead of interactive setup.
  • Clipboard mode: --clipboard copies the message instead of committing.

Configuration

  • View: aicommits config shows non-default settings (API keys masked).
  • Get/set: aicommits config get <key> and aicommits config set <key>=<value> (multiple keys at once allowed).
  • Change model: aicommits model interactively fetches available models from your provider and lets you pick one.
  • Update: aicommits update auto-detects your package manager (npm, pnpm, yarn, bun) and updates.

Notable config options:

Key Default Purpose
provider set during setup Which AI provider to use
subscription-detection on Whether setup looks for Claude/Codex/OpenCode Go logins (only in interactive terminals, never in Git hooks or CI)
locale en Language for generated messages (ISO 639-1 codes)
generate 1 Number of messages to generate
timeout 10000 ms (hosted), 60000 ms (Together AI/local) Network request timeout
max-length 72 Preferred character length of the commit subject
max-output-tokens unset Cap on tokens the model may generate; raise it (e.g., 4096) if a reasoning model burns its budget on thinking and never outputs a message
thinking enabled Set to disabled for faster/cheaper responses on compatible providers (not official OpenAI or Together AI)
type plain Commit message format
claude-path / codex-path — Path to the CLI if it's not on your PATH

Precedence: command-line arguments > environment variables > config file > defaults.


How it works under the hood

The model receives the list of staged files, requests the staged diffs it needs, and returns a validated commit subject (plus optional description). It can only read Git's staged snapshot — unstaged edits are never sent to the AI.


Maintainers

Hassan El Mghari (@Nutlope), Riccardo Giorato (@riccardogiorato), Hiroki Osame (@privatenumber).

Contributing

See the CONTRIBUTING.md guide for setup and testing instructions; bugs and feature requests live in the GitHub Issues.

Related

  • Project
  • Project
  • Project
  • Project
  • Project