AI-powered Git commit message generator that analyzes your staged changes and outputs conventional commit messages.
lv_0_20251124193607.mp4
- Generates configurable number of commit message suggestions from your staged diff
- Generates 10 pull request titles based on the diff between the current branch and a target branch
- Providers: GitHub Copilot (default), OpenAI, Anthropic (Claude Code CLI)
- Multi-language support: Any language (English, Arabic, Korean, etc.)
- Interactive config to pick provider/model/language and set keys
- Simple output suitable for piping into TUI menus (one message per line)
go install github.com/m7medvision/lazycommit@latestOr build from source:
git clone https://github.com/m7medvision/lazycommit.git
cd lazycommit
go build -o lazycommit main.go- Root command:
lazycommit - Subcommands:
lazycommit commit— prints 10 suggested commit messages to stdout, one per line, based ongit diff --cached.lazycommit pr <target-branch>— prints 10 suggested pull request titles to stdout, one per line, based on diff between current branch and<target-branch>.lazycommit config get— prints the active provider, model and language.lazycommit config set— interactive setup for provider, API key, model, and language.
Exit behaviors:
- If no staged changes: prints "No staged changes to commit." and exits 0.
- On config/LLM errors: prints to stderr and exits non‑zero.
Generate suggestions after staging changes:
git add .
lazycommit commitPipe the first suggestion to commit (bash example):
MSG=$(lazycommit commit | sed -n '1p')
[ -n "$MSG" ] && git commit -m "$MSG"Pick interactively with fzf:
git add .
lazycommit commit | fzf --prompt='Pick commit> ' | xargs -r -I {} git commit -m "{}"Generate PR titles against main branch:
lazycommit pr mainlazycommit uses a two-file configuration system to separate sensitive provider settings from shareable prompt configurations:
Contains API keys, tokens, and provider-specific settings. Do not share this file.
active_provider: copilot # default if a GitHub token is found
providers:
copilot:
api_key: "$GITHUB_TOKEN" # Uses GitHub token; token is exchanged internally
model: "gpt-4o" # or "openai/gpt-4o"; both accepted
# endpoint_url: "https://api.githubcopilot.com" # Optional - uses default if not specified
openai:
api_key: "$OPENAI_API_KEY"
model: "gpt-4o"
# endpoint_url: "https://api.openai.com/v1" # Optional - uses default if not specified
anthropic:
model: "claude-haiku-4-5" # Uses Claude Code CLI - no API key needed
num_suggestions: 10 # Number of commit suggestions to generateNote
.lazycommit.yaml: language is removed and please use .lazycommit.prompts.yaml instead.
Contains prompt templates and message configurations. Safe to share in dotfiles and Git.
language: English # commit message language (e.g., "English", "Arabic", "Korean")
system_message: "You are a helpful assistant that generates git commit messages, and pull request titles."
commit_message_template: "Based on the following git diff, generate 10 conventional commit messages. Each message should be on a new line, without any numbering or bullet points:\n\n%s"
pr_title_template: "Based on the following git diff, generate 10 pull request title suggestions. Each title should be on a new line, without any numbering or bullet points:\n\n%s"You can override the prompt configuration on a per-repository basis by creating a .lazycommit.prompts.yaml file in the root of your git repository. This is useful for projects that require different languages or commit message formats.
If a field is missing in your repository-local configuration, the value from the global configuration will be used.
Example .lazycommit.prompts.yaml for a Korean project:
language: Korean
commit_message_template: "Based on the following git diff, generate 5 conventional commit messages:\n\n%s"This file is automatically created on first run in the global config directory with sensible defaults:
system_message: "You are a helpful assistant that generates git commit messages, and pull request titles."
commit_message_template: "Based on the following git diff, generate 10 conventional commit messages. Each message should be on a new line, without any numbering or bullet points:\n\n%s"
pr_title_template: "Based on the following git diff, generate 10 pull request title suggestions. Each title should be on a new line, without any numbering or bullet points:\n\n%s"You can configure custom API endpoints for any provider, which is useful for:
- Local AI models: Ollama, LM Studio, or other local inference servers
- Enterprise proxies: Internal API gateways or proxy servers
- Alternative providers: Any OpenAI-compatible API endpoint
The endpoint_url field is optional. If not specified, the official endpoint for that provider will be used.
Ollama (local):
active_provider: openai # Use openai provider for Ollama compatibility
providers:
openai:
api_key: "ollama" # Ollama doesn't require real API keys
model: "llama3.1:8b"
endpoint_url: "http://localhost:11434/v1"lazycommit supports generating commit messages in any language. Set the language field in your prompt config (.lazycommit.prompts.yaml):
language: Spanish
# or
language: Arabic
# or
language: English # (default)You can also configure it interactively:
lazycommit config set # Select language in the interactive menuThe language setting automatically instructs the AI to generate commit messages in the specified language, regardless of the provider used.
Because lazycommit commit prints plain lines, it plugs nicely into menu UIs.
Add this to ~/.config/lazygit/config.yml:
customCommands:
- key: "<c-a>" # ctrl + 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 }}"This config will allows you to edit the commit message after picking from lazycommit suggestions.
- key: "<c-b>" # ctrl + 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: terminalFirst, install the Commitizen plugin:
pip install cz-lazycommit
# or if you are using Arch Linux:
uv tool install commitizen --with cz-lazycommitThen use the plugin with the following command:
git cz --name cz_lazycommit commitIf you are using Commitizen with Lazygit, you can add this custom command:
- key: "C"
command: "git cz --name cz_lazycommit commit"
description: "Commit with Commitizen"
context: "files"
loadingText: "Opening Commitizen commit tool"
output: terminal- "No staged changes to commit." — run
git addfirst. - "API key not set" — set the appropriate key in
.lazycommit.yamlor env var and rerun. - Copilot errors about token exchange — ensure your GitHub token has models scope or is valid; try setting
GITHUB_TOKEN.
MIT