@thankarezos/git-ai-commit
v0.1.5
Published
Generate editable git commit messages using a configurable AI CLI
Downloads
743
Maintainers
Readme
git-aic
Generate a git commit message from your staged diff using any AI CLI you already have on your machine (Claude Code, Antigravity CLI, Codex, llm, Ollama, or a custom command). The message opens in your editor — save to commit, quit without saving to abort.
$ git aic -ap "mention the migration"
# (AI runs against your staged diff, message opens in nano)
# Save -> commit. Quit without saving -> abort.Install
npm install -g @thankarezos/git-ai-commitRequires Node 18+. Because the binary is named git-aic, git resolves git aic automatically.
Install from source
git clone https://github.com/thankarezos/git-ai-commit.git
cd git-ai-commit
npm linkQuick start
git add <files>
git aic # generate, edit, commit
git aic -a # stage everything first (git add -A)
git aic -p "be terse" # add hints to the prompt
git aic -ap "be terse" # combine -a and -p
git aic --no-commit # generate + edit only, don't commitFirst run launches an interactive wizard that asks you to pick a provider, editor, and behavior flags, and writes the result to ~/.config/git-aic/config.json. You can re-run it any time with git aic --init.
Flags
| Flag | Meaning |
|---|---|
| -a, --add | Run git add -A before generating |
| -p "...", --prompt "..." | Append extra instructions to the AI prompt |
| -ap "...", -pa "..." | Combine -a and -p |
| --provider <name>, -P <name> | One-off provider override. <name> matches a preset command (claude, agy, codex, opencode, llm, ollama). |
| --no-commit | Generate and edit, but skip the git commit |
| --commit | Force commit (overrides commit: false in config) |
| --require-edit | Refuse to commit if the saved message is byte-identical to what the AI produced |
| --no-require-edit | Allow committing the AI message unchanged |
| --init | Run the interactive setup wizard |
| --config | Print the active config path and contents |
| -v, --version | Print the package version |
| -h | Show usage. (--help is intercepted by git, so use -h.) |
How it decides to commit
After the AI generates a message, the file opens in your editor:
- Save (
Ctrl+X→Yin nano,:wqin vim) → commits. - Quit without saving (
Ctrl+X→N,:q!) → aborts withFile not saved. Aborted. - With
requireEdit: true, the saved content must additionally differ from the AI's output, otherwise it aborts withNo edit detected. Aborted.
Configuration
Stored at ~/.config/git-aic/config.json (override with GIT_AIC_CONFIG=/path/to/config.json):
{
"provider": {
"command": "claude",
"args": ["-p", "{prompt}"]
},
"editor": "nano",
"commit": true,
"requireEdit": false
}provider.command— the binary to invoke.provider.args— argv passed to that binary.{prompt}and{diff}are placeholders. If neither{prompt}nor{diff}appear in the args, the prompt is appended as the last arg and the diff is piped on stdin.editor— the editor command (overridden by$EDITORif set).commit— whether to actuallygit commitafter editing.requireEdit— require the saved message to differ from the AI output.
Overriding prompts and cleanup patterns
The wizard (git aic --init) writes the full defaults into your config so you can see and edit everything in one place. Any of these fields can be removed, changed, or extended:
prompt— array of lines sent to the AI. Include{extraPrompt}somewhere if you want-p "..."to keep working.commitMessageTag— the XML tag the AI is told to wrap the message in.removeLinesMatching— case-insensitive regex strings; matching lines are stripped from the AI's output.stopLinesMatching— case-insensitive regex strings; lines from the first match onward are dropped (used to cut off AI rambling).
Each field in your user config replaces the default if present. If you delete a field entirely, the built-in default from bin/prompts.json is used instead.
Providers
The wizard ships with presets for:
- Claude Code —
claude -p "{prompt}"(reads diff from stdin) - Antigravity CLI —
agy -p "{prompt}" - Codex CLI —
codex exec --skip-git-repo-check "{prompt}" - OpenCode —
opencode run "{prompt}" - llm (Simon Willison) —
llm "{prompt}" - Ollama —
ollama run llama3 "{prompt}" - Custom — type your own
commandandargs
You can edit provider in the config file at any time, or rerun git aic --init.
Windows note
Most CLIs work the same on Windows. The exception is a CLI that renders its output to the console instead of stdout (like agy): to capture it, git-aic must spawn it with no console, which briefly flashes a console window. A provider can opt into this with a windows field carrying extra spawn options:
"provider": {
"command": "agy",
"args": ["-p", "{prompt}"],
"windows": { "detached": true }
}CLIs that write to stdout (e.g. claude) don't need this and run without any window.
Customizing the prompt
git aic --init copies the prompt template, the <commit_message> tag, and the cleanup patterns into your config file (run git aic --config to see its path and contents). Edit the config file to customize them — these values override the built-in defaults:
- Change tone, rules, or allowed Conventional Commit types in
prompt. - Add line patterns to
removeLinesMatchingto strip more AI boilerplate. - Add line patterns to
stopLinesMatchingto cut off output when the AI starts rambling.
Patterns are case-insensitive JS regex strings.
The built-in defaults live in bin/prompts.json; editing that only changes the fallback for fields your config doesn't set, and is overwritten on reinstall — so prefer the config file.
Tests
npm testUses Node's built-in test runner (no external dependencies). Tests cover cleanCommitMessage, extractCommitMessage, and the config merge logic.
License
MIT
