AI-powered git commit message generator
Project description
cmtr
cmtr writes your git commit messages for you. It uses the OpenAI API (gpt-5.2), the staged diff, and recent commit history to match the repository's style.
Quick start (recommended)
- Install uv (if needed), then run:
uvx cmtr@latest
- Optional: add a shell alias:
alias cmtr="uvx cmtr@latest"
- Authenticate (preferred: Codex):
- Codex CLI (preferred): run
npx @openai/codex@latestand sign in (uses your ChatGPT account) - API key (alternative):
export OPENAI_API_KEY=...
- Codex CLI (preferred): run
- Stage changes and run:
git add -Acmtr
Codex mode is preferred because it uses your ChatGPT account usage (not separate
API billing) and requires no API key. If Codex isn't on your PATH, cmtr will run
it via npx @openai/codex@latest as long as you're signed in. If OPENAI_API_KEY
is not set and you are signed into Codex, cmtr will use Codex automatically.
Or install the git hook:
cmtr --hook- Installs a
prepare-commit-msghook that automatically generates a commit message right before the commit editor opens. If there is already a message or you're in a rebase/fixup/squash flow, it skips.
- Installs a
Usage
cmtr- Behaves like
git commit -v, but injects a generated commit message.
- Behaves like
cmtr --dry-run- Print the generated message without committing.
cmtr --print-prompt- Print the prompts used to generate the message.
cmtr --no-edit- Skip opening the editor after generating the message.
cmtr --hook- Install the
prepare-commit-msghook to auto-generate messages on every commit.
- Install the
cmtr --uninstall-hook- Remove the hook.
Extra git commit flags can be passed directly (for example, --no-verify). Avoid -m/-F/-C/-c because cmtr supplies the message.
How it builds context
- Uses staged files (
git diff --cached) for the actual changes. - Finds shared paths and samples recent
git logmessages on those paths to learn the repo's style.
Configuration
Configuration is loaded in this order (later overrides earlier):
- XDG config file (
~/.config/cmtr/config.tomlor$XDG_CONFIG_HOME/cmtr/config.toml) cmtr.tomlin the repo root (optional repo-specific overrides)- Environment variables
- CLI flags
Manage global config with:
cmtr config pathcmtr config listcmtr config get modelcmtr config set model gpt-5.2cmtr config unset model
Example config file:
model = "gpt-5.2"
max_diff_bytes = 12000
max_patch_lines = 400
max_log_entries = 20
max_log_paths = 4
max_log_body_lines = 6
timeout_seconds = 60
reasoning_effort = "none"
text_verbosity = "low"
prefer_codex = false
base_url = "https://api.openai.com/v1"
organization = "org_..."
Set prefer_codex = true to force Codex CLI (even if OPENAI_API_KEY is set).
Use cmtr auth status to see which mode will be selected and why.
Environment variables:
OPENAI_API_KEYOPENAI_BASE_URLOPENAI_ORGCMTR_MODELCMTR_MAX_DIFF_BYTESCMTR_MAX_PATCH_LINESCMTR_MAX_LOG_ENTRIESCMTR_MAX_LOG_PATHSCMTR_MAX_LOG_BODY_LINESCMTR_TIMEOUT_SECONDSCMTR_REASONING_EFFORTCMTR_TEXT_VERBOSITYCMTR_PREFER_CODEX
Development
Local development:
mise installmise run installmise run run
Type checking:
mise run typecheckuv run ty check
If you are installing manually, run uv sync --group dev first to install the ty tool.
Troubleshooting
- No staged changes: run
git addbefore cmtr. - Missing API key: set
OPENAI_API_KEYor install/login to Codex CLI. - Unsure which auth mode is active: run
cmtr auth status. - Hook failures: a
# cmtr failed: ...comment is appended to the commit message template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmtr-0.2.6.tar.gz.
File metadata
- Download URL: cmtr-0.2.6.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e904c4f7b4ccd5aaa64351713cc88b48fb0fe97913aaf55604ec7280460b79f
|
|
| MD5 |
962b9e23218001d2e9020ef941764f3c
|
|
| BLAKE2b-256 |
39fd5a8894c859cc8ed30c55ef4d40fd2e2c82058fe15b37fe1f0744f5845f8f
|
Provenance
The following attestation bundles were made for cmtr-0.2.6.tar.gz:
Publisher:
publish.yml on shayne/cmtr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cmtr-0.2.6.tar.gz -
Subject digest:
9e904c4f7b4ccd5aaa64351713cc88b48fb0fe97913aaf55604ec7280460b79f - Sigstore transparency entry: 779560759
- Sigstore integration time:
-
Permalink:
shayne/cmtr@892669539ff2f70cc0ea8c89b1bade247c513ea6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shayne
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@892669539ff2f70cc0ea8c89b1bade247c513ea6 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cmtr-0.2.6-py3-none-any.whl.
File metadata
- Download URL: cmtr-0.2.6-py3-none-any.whl
- Upload date:
- Size: 22.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e29055fe275065804ba66b0b0c83fc96240304ebb6d304093660759059910f2
|
|
| MD5 |
c4d3cec8a9c615a04c3391749f9457fc
|
|
| BLAKE2b-256 |
0b8f42e27c5027bb7d2cc41515581f686cd83deb7a8d3f5bf41aaf7d197ea3e2
|
Provenance
The following attestation bundles were made for cmtr-0.2.6-py3-none-any.whl:
Publisher:
publish.yml on shayne/cmtr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cmtr-0.2.6-py3-none-any.whl -
Subject digest:
2e29055fe275065804ba66b0b0c83fc96240304ebb6d304093660759059910f2 - Sigstore transparency entry: 779560762
- Sigstore integration time:
-
Permalink:
shayne/cmtr@892669539ff2f70cc0ea8c89b1bade247c513ea6 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/shayne
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@892669539ff2f70cc0ea8c89b1bade247c513ea6 -
Trigger Event:
workflow_dispatch
-
Statement type: