Skip to main content

gitmsg-ai

CI PyPI version Python versions Downloads License: MIT

AI-generated Conventional Commit messages from your staged Git diff.

Works with local models via Ollama (free, private) or OpenAI (paid).

📦 Previously published as commit-msg-ai. Both CLI commands (gitmsg-ai and commit-msg-ai) work for backwards compatibility.

Features

  • ✨ Conventional Commits — feat, fix, docs, refactor, etc.
  • 🎨 Gitmoji support — ✨ feat:, 🐛 fix:, 📝 docs: with --emoji
  • 🎲 Interactive mode — generate 3 options, pick the best with --interactive
  • 💾 Smart caching — re-running on the same diff is instant
  • 📊 Amend support — regenerate message for last commit with --amend
  • 🌍 Multi-language — --lang ru, --lang en, 16+ languages
  • 🪝 Git hook — auto-generate on every git commit
  • 🔌 Two providers — Ollama (local) or OpenAI (API)

Install

pip install gitmsg-ai
From source

git clone https://github.com/Weretik18/commit-msg-ai.git

cd commit-msg-ai

pip install -e .
Then create a config:


mkdir -p ~/.commit-msg-ai

cp config.example.yaml ~/.commit-msg-ai/config.yaml
Quick start (Ollama, recommended)
Install Ollama
Pull a coding model: ollama pull qwen2.5-coder:7b
Edit ~/.commit-msg-ai/config.yaml to use that model
Stage changes and run:

git add .

gitmsg-ai
Usage
undefined
Default: generate one commit message
gitmsg-ai

With emoji
gitmsg-ai --emoji

Pick from 3 options
gitmsg-ai --interactive

In Russian
gitmsg-ai --lang ru

Regenerate for last commit (use with git commit --amend)
gitmsg-ai --amend

Skip cache (always call the model)
gitmsg-ai --no-cache

Subject line only, no body
gitmsg-ai --no-body

Pipe straight into git
gitmsg-ai | git commit -F -


## Git hook (automatic mode)

```bash

gitmsg-ai install-hook
Now every git commit will pre-fill the commit message editor with an AI-generated one.

To remove:


gitmsg-ai uninstall-hook
Commands
CommandWhat it does
gitmsg-aiGenerate a commit message
gitmsg-ai install-hookInstall prepare-commit-msg hook
gitmsg-ai uninstall-hookRemove the hook
gitmsg-ai clear-cacheDelete all cached messages
gitmsg-ai --versionShow version
Config
~/.commit-msg-ai/config.yaml:


provider: ollama  # or "openai"



ollama:

  host: http://localhost:11434

  model: qwen2.5-coder:7b



openai:

  api_key: ""  # or set OPENAI_API_KEY env var

  model: gpt-4o-mini



options:

  max_length: 72

  include_body: true

  language: en
Contributing
Pull requests are welcome. To set up your dev environment:

undefined
Clone and install in dev mode
git clone https://github.com/Weretik18/commit-msg-ai.git

cd commit-msg-ai

pip install -e ".[dev]"

Install pre-commit hooks (runs ruff, format, encoding checks before each commit)
pip install pre-commit

pre-commit install

Run all hooks against all files (sanity check)
pre-commit run --all-files

Run tests
pytest tests/ -v

Lint manually
ruff check commit_msg_ai/ tests/


The `pre-commit` hooks run automatically on every `git commit` and check:
- Code formatting (`ruff-format`)
- Linting (`ruff`)
- Trailing whitespace and missing newlines
- TOML/YAML syntax
- Line endings (forces LF)

CI runs the same checks, so passing pre-commit locally means CI will pass too.

## License

MIT — see [LICENSE](LICENSE) for details.

Metadata

Release files for gitmsg-ai 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitmsg-ai 0.2.7
File Size Uploaded
gitmsg_ai-0.2.7.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitmsg-ai 0.2.7
File Interpreter ABI Platform
gitmsg_ai-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / gitmsg_ai-0.2.7.tar.gz

Download URL gitmsg_ai-0.2.7.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0a066fb7d554806028927097f23d10c2ede985e86fd87ea7a5143412b547c2c5
BLAKE2b-256 checksum
How to use checksums
a7289cf0360c70d8569cc50a7984368daa23f589c17b57fbabfa316cd5f6edd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

Release files / gitmsg_ai-0.2.7-py3-none-any.whl

Download URL gitmsg_ai-0.2.7-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29af0942dbcde03527d6c1426c83f139e3af55f7cc420387d99d328e0a6eb924
BLAKE2b-256 checksum
How to use checksums
dce62819a969d05131d1aa080af0abdbe995b5f200f3b818cf7df6cb8d659aeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page