git-msg
git-msg reads your staged diff, current branch, and recent commit log, sends them to an LLM via a
prompt template, and drops the generated message into an interactive TUI where you can confirm, edit
inline, open $EDITOR, or abort — before anything is committed. It supports Anthropic, OpenAI,
Gemini, and Ollama, and can install itself as a prepare-commit-msg git hook.
main. The build-time version is
shown by git-msg --version.git add .
git-msg generate Generated commit message:
> Use as-is
Edit inline
Open $EDITOR
Abort
feat(config): add XDG-compliant path resolution via internal/dirsInstall
brew tap madstone-tech/tap
brew install git-msgOr with Go:
go install github.com/madstone-tech/git-msg@latestOr download a binary from GitHub Releases.
First run
The first time you run any git-msg command, a setup wizard launches automatically:
git-msg — first-run setup
Select LLM provider
> Anthropic (Claude)
OpenAI (GPT)
Google Gemini
Ollama (local)For cloud providers you choose a model and enter an API key. Keys are stored in the system keychain
(service git-msg), never in config files. For Ollama, git-msg queries ollama list and presents
a model picker.
Providers
| Provider | Default model | API key required | Key env-var fallback |
|---|---|---|---|
anthropic | claude-haiku-4-5 | Yes | GIT_MSG_ANTHROPIC_API_KEY |
openai | gpt-4o-mini | Yes | GIT_MSG_OPENAI_API_KEY |
gemini | gemini-1.5-flash | Yes | GIT_MSG_GEMINI_API_KEY |
ollama | llama3 | No | — |
If no key is found in the keychain, git-msg falls back to the matching GIT_MSG_<PROVIDER>_API_KEY
environment variable. Override the provider for a single run:
git-msg generate --provider ollamaGit hook integration
Install as a prepare-commit-msg hook so generation happens automatically on git commit:
git-msg hook install # local repo
git-msg hook install --global # globally via git core.hooksPathUninstall:
git-msg hook uninstall
git-msg hook uninstall --globalConfiguration
Config file: ~/.config/mdstn/git-msg/config.toml (XDG path on all OSes; override the base with
XDG_CONFIG_HOME). User prompt templates live in ~/.config/mdstn/git-msg/prompts/.
[provider]
name = "anthropic"
model = "claude-haiku-4-5"
[ollama]
host = "http://localhost:11434"
[prompt]
default = "conventional"
[hook]
global = falseRead and set values via the CLI:
git-msg config show
git-msg config get provider.model
git-msg config set provider.name ollama
git-msg config set provider.model llama3Prompt templates
Templates use Jinja2-style syntax rendered by the ason
engine (not literal Jinja2). git-msg ships one embedded template, conventional, following the
Conventional Commits spec. Three variables are available:
{{ diff }}, {{ branch }}, and {{ log }}.
git-msg prompt list
git-msg prompt show conventional
git-msg prompt edit my-template # opens in $EDITOR
git-msg prompt reset conventional # restore the embedded defaultCLI reference
| Command | Description |
|---|---|
git-msg generate | Generate a commit message from the staged diff |
git-msg config show | Print the full resolved configuration |
git-msg config get <key> | Print one config value |
git-msg config set <key> <value> | Set a config value |
git-msg prompt list | List available prompt templates |
git-msg prompt show <name> | Print a template |
git-msg prompt edit <name> | Edit a template in $EDITOR |
git-msg prompt reset <name> | Reset a template to its embedded default |
git-msg hook install | Install the prepare-commit-msg hook (--global for git-wide) |
git-msg hook uninstall | Remove the git hook (--global for git-wide) |
git-msg completion <bash|zsh|fish> | Generate a shell completion script |
Global flag: --version prints the build-time version.
generate flags:
| Flag | Description |
|---|---|
--dry-run | Print the generated message and skip the review TUI / commit |
--provider <name> | Override the configured LLM provider for this run |
--template <name> | Use a specific prompt template for this run |