Generate Git commit messages from staged diffs using your preferred LLM CLI.
git-ai-commit does not talk to LLM APIs directly. Instead, it delegates generation to existing LLM CLIs such as Claude Code, Gemini, or Codex, so no API keys, SDKs, or vendor-specific integrations are required.
Package managers:
Homebrew:
brew install takai/tap/git-ai-commitmise:
mise use -g github:takai/git-ai-commit@latestBuild from source (outputs to bin/):
make buildPut bin/git-ai-commit on your PATH to enable git ai-commit.
git ai-commit [options]Common options:
--context VALUEAdditional context for the commit message--context-file VALUEFile containing additional context--prompt VALUEBundled prompt preset:default,conventional,gitmoji,karma--prompt-file VALUEPath to a custom prompt file--engine VALUEOverride engine name--amendAmend the previous commit-d,--diffShow staged diff in the editor (implies--edit)-e,--editOpen the generated commit message in an editor before committing-a,--allStage modified and deleted files before generating the message-i,--include VALUEStage specific files before generating the message-x,--exclude VALUEHide specific files from the diff for message generation--debug-promptPrint the prompt before executing the engine--debug-commandPrint the engine command before execution-h,--helpShow help
Configuration is layered. Later layers override earlier ones:
| Priority | Source |
|---|---|
| 1 (lowest) | System git config (/etc/gitconfig) |
| 2 | Global git config (~/.gitconfig) |
| 3 | User TOML (~/.config/git-ai-commit/config.toml) |
| 4 | Repo TOML (git-ai-commit.toml or .git-ai-commit.toml at repo root) |
| 5 | Local git config (.git/config) |
| 6 | Worktree git config |
| 7 (highest) | Command-line flags |
Repository TOML config is applied only after an initial trust prompt, since it is a tracked file that could be set by a repo maintainer.
~/.config/git-ai-commit/config.toml for user-wide defaults, git-ai-commit.toml (or .git-ai-commit.toml) at the repo root for project defaults.
Example: Use Codex with Conventional Commits by default
engine = "codex"
prompt = "conventional"Supported settings:
engineDefault engine name (string)promptBundled prompt preset:default,conventional,gitmoji,karmaprompt_filePath to a custom prompt file (relative to the config file; must be within the repo root for repo TOML)engines.<name>.argsArgument list for the engine command (array of strings)filter.max_file_linesMaximum lines per file in diff (default: 100)filter.exclude_patternsAdditional glob patterns to exclude from difffilter.default_exclude_patternsOverride built-in exclude patterns
All settings except engines.<name>.args can also be set via git config using the ai-commit section. This is useful for per-repository preferences in repositories you do not own, since .git/config is never committed or pushed.
# Set for the current repository only
git config --local ai-commit.engine claude
git config --local ai-commit.prompt conventional
# Or apply user-wide defaults
git config --global ai-commit.engine claude
git config --global ai-commit.prompt conventionalSupported keys:
| git config key | Equivalent TOML setting |
|---|---|
ai-commit.engine |
engine |
ai-commit.prompt |
prompt |
ai-commit.promptFile |
prompt_file |
ai-commit.maxFileLines |
filter.max_file_lines |
ai-commit.excludePatterns |
filter.exclude_patterns |
ai-commit.defaultExcludePatterns |
filter.default_exclude_patterns |
excludePatterns and defaultExcludePatterns support multiple values via git config --add:
git config --add ai-commit.excludePatterns '*.pb.go'
git config --add ai-commit.excludePatterns 'vendor/**'Relative promptFile paths are resolved from the repo root for --local/--worktree scope, and from $HOME for --global scope. No path containment restriction applies — unlike repo TOML, git config cannot be set by a repository maintainer via push.
prompt and promptFile cannot both be set within the same scope. Setting both returns an error.
git-ai-commit treats LLMs as external commands, not as APIs. This design avoids direct network calls and API key management, and lets you reuse your existing LLM CLI setup.
Supported engines:
claudegeminicodex
Built-in defaults are applied when engines.<name>.args is not set.
For claude, defaults include:
-p --model haiku--settings "{\"attribution\":{\"commit\":\"\",\"pr\":\"\"}}"(prevents automaticCo-authored-bymetadata)
If no engine is configured, auto-detection tries commands in this order: claude → gemini → codex. The first available command is used.
Any other engine name is treated as a direct command and executed with the prompt on stdin.
Example: Use ollama with gemma3:4b
engine = "ollama"
[engines.ollama]
args = ["run", "gemma3:4b"]Bundled presets:
default– Commit messages aligned with the recommendations in Pro Gitconventional– Conventional Commits formatgitmoji– gitmoji-based commit messageskarma– Karma-style commit messages
Point to a custom prompt file in TOML config:
engine = "claude"
prompt_file = "prompts/commit.md"Or via git config (useful for repos you do not own):
git config --local ai-commit.promptFile /path/to/prompt.mdprompt and prompt_file (or promptFile in git config) are mutually exclusive within the same config layer. When they come from different layers, the higher-priority layer wins.
When the staged diff is large, it can exceed LLM context limits or degrade commit message quality. git-ai-commit automatically filters the diff to help LLMs focus on meaningful changes.
Default behavior:
- Each file is limited to 100 lines (configurable via
filter.max_file_lines) - Lock files and generated files are excluded by default
Default exclude patterns:
**/*.lock,**/*-lock.json,**/*.lock.yaml,**/*-lock.yaml,**/*.lockfile**/*.min.js,**/*.min.css,**/*.map**/go.sum
Example: Customize filtering
[filter]
max_file_lines = 300
# Add patterns to exclude (merged with defaults)
exclude_patterns = [
"**/vendor/**",
"**/*.generated.go",
"**/dist/**"
]
# Or replace defaults entirely
# default_exclude_patterns = ["**/my-lock.json"]If you use Claude Code, you can integrate git-ai-commit as a plugin for a more convenient workflow.
/plugin marketplace add takai/git-ai-commit
/plugin install ai-commit@git-ai-commit-plugins
/ai-commit:staged- Commits only the currently staged changes/ai-commit:all- Stages all pending changes and commits as a single commit/ai-commit:organize- Organizes pending changes into multiple atomic commits
This tool was inspired by how @negipo used a tool like this in his workflow to make his work much more efficient.