Skip to main content

AI-generated Conventional Commit messages from your staged Git diff. Local (Ollama) or cloud (OpenAI).

Project description

commit-msg-ai

CI PyPI version Python versions License: MIT

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

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

Features

  • Conventional Commitsfeat, 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

From PyPI (recommended)

pip install commit-msg-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)

  1. Install Ollama
  2. Pull a coding model: ollama pull qwen2.5-coder:7b
  3. Edit ~/.commit-msg-ai/config.yaml to use that model
  4. Stage changes and run:
git add .
commit-msg-ai

Usage

# Default: generate one commit message
commit-msg-ai

# With emoji
commit-msg-ai --emoji

# Pick from 3 options
commit-msg-ai --interactive

# In Russian
commit-msg-ai --lang ru

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

# Skip cache (always call the model)
commit-msg-ai --no-cache

# Subject line only, no body
commit-msg-ai --no-body

# Pipe straight into git
commit-msg-ai | git commit -F -

Git hook (automatic mode)

commit-msg-ai install-hook

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

To remove:

commit-msg-ai uninstall-hook

Commands

Command What it does
commit-msg-ai Generate a commit message
commit-msg-ai install-hook Install prepare-commit-msg hook
commit-msg-ai uninstall-hook Remove the hook
commit-msg-ai clear-cache Delete all cached messages
commit-msg-ai --version Show 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

Development

# Clone and install in dev mode
git clone https://github.com/Weretik18/commit-msg-ai.git
cd commit-msg-ai
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Lint
ruff check commit_msg_ai/ tests/

License

MIT — see LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitmsg_ai-0.2.2.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitmsg_ai-0.2.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file gitmsg_ai-0.2.2.tar.gz.

File metadata

  • Download URL: gitmsg_ai-0.2.2.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gitmsg_ai-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2ac2ac8eb585933558af6a7fe6cc82052babf037c11be0f361c944214a883976
MD5 80460419034057f253c399b631a80b03
BLAKE2b-256 8b7b58ad991580d391c1133ed757d3f627856072418dbc6b6a9f7f124db97ff8

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitmsg_ai-0.2.2.tar.gz:

Publisher: publish.yml on Weretik18/commit-msg-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gitmsg_ai-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: gitmsg_ai-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gitmsg_ai-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d2188fbeaa6eae36aac74cfd26945aebbea9217f48480d22cfe2fad15522ba44
MD5 6cdca45e21ed04c7dd30d891cb7acfac
BLAKE2b-256 d8f8641da8da58521c0666c6579a1d8e72d0ba36f12043ae65ee21b3b5a27acb

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitmsg_ai-0.2.2-py3-none-any.whl:

Publisher: publish.yml on Weretik18/commit-msg-ai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page