AI-powered Git commit message generator. It reads your staged diff, asks an LLM through any OpenAI-compatible API, and prints clean commit message suggestions — one per line, ready to pipe into lazygit, fzf, or any TUI menu.
- Suggests a configurable number of commit messages from
git diff --cached - Suggests pull request titles from the merge-base diff against a target branch
- Works with any OpenAI-compatible endpoint: OpenAI, Ollama (local, keyless), OpenRouter, LM Studio, enterprise proxies
- Model fallback chain, request retry, and timeouts built in
- Any output language (English, Arabic, Korean, ...)
- Plain-line output designed for piping into TUI menus
go install github.com/m7medvision/lazycommit@latestOr build from source:
git clone https://github.com/m7medvision/lazycommit.git
cd lazycommit
make buildlazycommit config set # choose model, endpoint, key, language
git add .
lazycommit commitlazycommit commit— prints commit message suggestions for the staged diff, one per line.lazycommit pr <target-branch>— prints pull request title suggestions for the diff against<target-branch>.lazycommit config set— interactive setup (model, endpoint, API key, language).lazycommit config get— shows the active backend, model, and language; API keys are masked.
Exit behavior:
- No staged changes: prints
No staged changes to commit.and exits 0. - Configuration or backend errors: message on stderr, non-zero exit, stdout stays clean.
Two files, deliberately split:
API keys and endpoints. Do not commit this file. It is written with owner-only permissions.
active_backend: openai-compatible
backends:
openai-compatible:
model: gpt-4o-mini
api_key: "$OPENAI_API_KEY" # plain value or $ENV_VAR reference
# base_url: https://api.openai.com/v1 # optional, default is official OpenAI
# fallback_models: # tried in order when the model fails
# - gpt-4oShareable, safe for dotfiles:
language: English
num_suggestions: 10
# max_diff_chars: 40000 # size budget for the diff sent to the model
# system_message: ...
# commit_message_template: "... %s" # %s is replaced by the diff
# pr_title_template: "... %s"Any repository can override prompt settings with a lazycommit.prompts.yaml
in its root; unset fields fall through to the global file, then to built-in
defaults:
# my-korean-project/lazycommit.prompts.yaml
language: Korean
num_suggestions: 5Ollama (local, no key):
active_backend: openai-compatible
backends:
openai-compatible:
model: llama3.1:8b
base_url: http://localhost:11434/v1OpenRouter:
active_backend: openai-compatible
backends:
openai-compatible:
model: openai/gpt-4o-mini
api_key: "$OPENROUTER_API_KEY"
base_url: https://openrouter.ai/api/v1lazycommit commit prints plain lines, so it plugs directly into menu UIs.
git add .
lazycommit commit | fzf --prompt='Pick commit> ' | xargs -r -I {} git commit -m "{}"Add to ~/.config/lazygit/config.yml:
customCommands:
- key: "<c-a>"
description: "pick AI commit"
command: 'git commit -m "{{.Form.Msg}}"'
context: "files"
prompts:
- type: "menuFromCommand"
title: "AI commits"
key: "Msg"
command: "lazycommit commit"
filter: "^(?P<raw>.+)$"
valueFormat: "{{ .raw }}"
labelFormat: "{{ .raw | green }}"Variant that lets you edit the message before committing:
- key: "<c-b>"
description: "Pick AI commit (edit before committing)"
context: "files"
command: >
bash -c 'msg="{{.Form.Msg}}"; echo "$msg" > .git/COMMIT_EDITMSG && ${EDITOR:-nvim} .git/COMMIT_EDITMSG && if [ -s .git/COMMIT_EDITMSG ]; then
git commit -F .git/COMMIT_EDITMSG;
else
echo "Commit message is empty, commit aborted.";
fi'
prompts:
- type: "menuFromCommand"
title: "AI commits"
key: "Msg"
command: "lazycommit commit"
filter: "^(?P<raw>.+)$"
valueFormat: "{{ .raw }}"
labelFormat: "{{ .raw | green }}"
output: terminalNo staged changes to commit.— rungit addfirst.has no model configured— runlazycommit config set.environment variable X is not set— your config references$X; export it or store the key directly.- Large change sets: when the diff is longer than
max_diff_chars, lazycommit sends a list of the changed files with line counts plus as many file diffs as fit; a very long file list is itself cut short with a count of the remaining files. Lock files, minified files, and binary files are listed without their diffs. Lower the value if your model still rejects the request as too large.
MIT