Skip to main content

AI-powered git commit message generator using local LLMs

Project description

๐Ÿค– komit

AI-powered git commit message generator using local LLMs via Ollama. No API keys, no internet required โ€” runs completely locally and privately.


PyPI Python License Downloads CI codecov


Buy Me a Coffee


Features

  • ๐Ÿง  Local LLM โ€” uses Ollama, no API keys needed
  • ๐ŸŒฟ Branch-Aware Context โ€” infers conventional types and scopes directly from your active git branch
  • ๐Ÿ“ Multiple commit styles โ€” conventional, simple, detailed
  • ๐Ÿ” Smart diff allocation โ€” per-file context budget, code files prioritized over docs
  • ๐Ÿ”Ž Deep mode โ€” summarize each file separately for better messages on large changesets
  • ๐Ÿ’ก Explain mode โ€” summarize what changed without committing
  • ๐Ÿ• Recent commits context โ€” last 3 commits included in the prompt for better inference
  • ๐Ÿ”„ Regenerate โ€” not happy? generate a new message instantly
  • โœ๏ธ Edit before commit โ€” open your editor to tweak the message
  • โš™๏ธ CLI flags โ€” control style, model, and more from the command line
  • ๐Ÿ“ Config file โ€” persist your preferences with komit init
  • ๐ŸŒ Universal โ€” works via pip, binary, or shell script
  • ๐ŸชŸ Cross-platform โ€” Linux, macOS, Windows
  • โšก Fast โ€” runs on your machine, no network calls to external APIs
  • ๐Ÿ”’ Ollama validation โ€” checks if Ollama is running and model exists before generating
  • ๐Ÿ” Smart updates โ€” detects pip vs binary install and updates accordingly

Requirements

  • Ollama installed and running
  • A local model pulled (e.g. ollama pull qwen2.5:7b)

Recommended Models

Model Size Best for
qwen2.5:7b 4.7GB Best quality
mistral:7b 4.1GB Good balance
llama3.2:3b 2.0GB Fastest
ollama pull qwen2.5:7b

Installation

Option 1 โ€” One line install (Linux/macOS, no Python required)

curl -fsSL https://raw.githubusercontent.com/glemiu6/komit/master/scripts/install.sh | bash

Option 2 โ€” Windows PowerShell

irm https://raw.githubusercontent.com/glemiu6/komit/master/scripts/install.ps1 | iex

Option 3 โ€” pip

pip install komit

Option 4 โ€” pipx (recommended for CLI tools)

pipx install komit

Option 5 โ€” Download binary

Download the binary for your platform from GitHub Releases:

Platform Binary
Linux x86_64 komit-linux-x86_64
macOS Apple Silicon komit-macos-arm64
Windows komit-windows-x86_64.exe

Intel Mac users: use pip install komit instead.

# Linux/macOS
chmod +x komit-*
sudo mv komit-* /usr/local/bin/komit

Setup

Git alias (recommended)

git config --global alias.ai '!komit'

Now you can use git ai as a shortcut.

Shell completion

# bash
echo 'eval "$(register-python-argcomplete komit)"' >> ~/.bashrc
source ~/.bashrc

# zsh
echo 'eval "$(register-python-argcomplete komit)"' >> ~/.zshrc
source ~/.zshrc

Usage

# stage your changes
git add .

# generate commit message
komit

# or via git alias
git ai

Subcommands & Maintenance

komit init       # create or overwrite your config file
komit update     # update to the latest version
komit uninstall  # remove komit from your system

CLI flags

Flag Short Type Default Description
--style -s conventional, simple, detailed config Commit message format
--model -m String config Ollama model to use
--ollama-url -u URL config Ollama API endpoint
--max_diff โ€” Integer config Max diff length in characters
--timeout โ€” Integer config LLM request timeout in seconds
--include_branch_name -ib Bool config Append branch name to commit message
--dry-run -dr Flag False Preview message without committing
--explain โ€” Flag False Explain staged changes without committing
--deep โ€” Flag False Summarize each file separately (slower, better on large diffs)
--config โ€” Path โ€” Path to a custom config file

Examples

# simple style
komit --style simple

# use a faster model
komit --model llama3.2:3b

# preview without committing
komit --dry-run

# explain what changed without committing
komit --explain

# better messages on large diffs (slower)
komit --deep

# include branch name in the message
komit --include_branch_name True

# remote Ollama instance
komit --ollama-url http://192.168.1.10:11434

Interactive Experience

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Staged files (3) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚  โ€ข src/auth.py                                                    โ”‚
โ”‚  โ€ข tests/test_auth.py                                             โ”‚
โ”‚  โ€ข README.md                                                      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
Branch name: feat/auth-tokens
Model: qwen2.5:7b ยท Style: conventional

โ ‹ Generating commit message...

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ Suggested commit message โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ feat: add JWT authentication token engine [feat/auth-tokens]      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

ยป Choose an action: (y)es, (n)o, (e)dit, (r)egenerate (y):
Option Key Behavior
Yes y Commit with the generated message
No n Cancel without committing
Edit e Open your editor to modify the message
Regenerate r Generate a new message

Deep Mode

For large changesets with many files, --deep summarizes each file individually before generating the final commit message. More accurate, but slower since it makes one LLM call per file.

komit --deep

Explain Mode

Explains your staged changes in plain English without committing โ€” useful for code review prep or PR descriptions.

komit --explain

Branch Name Parsing

When --include_branch_name is enabled, komit reads your branch name to infer the commit type and scope automatically.

Branch Inferred type Inferred scope
feat/auth-login feat auth
fix/ui_button fix ui_button
refactor/api-layer refactor api

Supported types: feat, fix, chore, docs, style, refactor, test, ci, perf.


Configuration

Run komit init to create your config file at ~/.config/komit/config.toml:

model = "qwen2.5:7b"
style = "conventional"
ollama_url = "http://localhost:11434"
max_diff_length = 4000
timeout = 60
include_branch_name = false

CLI flags always override config file values.


Commit Style Outputs

Conventional (default)

feat: add user authentication
fix: resolve null pointer in response pipeline

Simple

Add user authentication
Fix null pointer in response pipeline

Detailed

feat: add user authentication

- Add JWT token generation pipeline
- Implement password hashing with bcrypt
- Add login and logout endpoints

Maintenance

komit update     # update to latest version
komit uninstall  # remove komit completely

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feat/my-cool-feature)
  3. Commit your changes (komit ๐Ÿ˜‰)
  4. Push to the branch (git push origin feat/my-cool-feature)
  5. Open a Pull Request

License

Apache License 2.0

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

komit-0.5.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

komit-0.5.1-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file komit-0.5.1.tar.gz.

File metadata

  • Download URL: komit-0.5.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for komit-0.5.1.tar.gz
Algorithm Hash digest
SHA256 a5fa15e696bcca1b1dcad90715aa49c18d0498fe18e61616a46f29ce6389644f
MD5 daf86079d0aaf40b6449a4acfa84d9d7
BLAKE2b-256 31bf0b2d17f92b0e938d5d4c1475b583f00f3b739b91afc55007e6f0b9195518

See more details on using hashes here.

File details

Details for the file komit-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: komit-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for komit-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 269ed6d16ce8653871bb56e7e69df590cd76e2848a777f30a3cad70c72de4ecb
MD5 bd7b0827ff55bfcbab13014706e76416
BLAKE2b-256 cabf5936239ba1bfbbde62bd12bf2dfd178f315d9bbc4770bc38cb0e2cc34b9d

See more details on using hashes here.

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