Skip to main content

AI-powered commit message generator (CLI + git hook) with delightful terminal UX

Project description

DiffMind

Human‑quality commit messages. Zero hassle.

PyPI Python License: MIT

AI‑assisted commit message generator with a delightful terminal UX and a one‑command Git hook. Works offline (heuristics) and gets even better with OpenAI.


Highlights

  • Polished commit messages for your staged changes
  • Beautiful terminal UI (emoji‑friendly, powered by Rich)
  • One‑liner Git hook to auto‑fill commit messages
  • Works offline by default; seamlessly upgrades to OpenAI when available
  • Simple config with sane defaults; interactive refine/edit session

Install

Requires Python 3.8+.

PyPI

  • pipx (recommended, isolated CLI)
pipx install diffmind
  • pipx with OpenAI extras
pipx install "diffmind[ai]"
  • pip (core, offline)
pip install -U diffmind
  • pip with OpenAI extras
pip install -U "diffmind[ai]"

Upgrade / uninstall:

  • pipx upgrade
pipx upgrade diffmind
  • pip upgrade
pip install -U diffmind
  • pipx uninstall
pipx uninstall diffmind
  • pip uninstall
pip uninstall diffmind

From Source

Option A — editable install (pip):

  • Clone
git clone https://github.com/dirusanov/DiffMind.git
  • Enter directory
cd DiffMind
  • Install (editable) with OpenAI extras
pip install -e ".[ai]"
  • Or install (editable) core only
pip install -e .

Option B — development setup (Poetry):

  • Clone
git clone https://github.com/dirusanov/DiffMind.git
  • Enter directory
cd DiffMind
  • Install dependencies
poetry install
  • Verify CLI in venv
poetry run diffmind --help

Quickstart

# One-time setup (detects OpenAI automatically if OPENAI_API_KEY is set)
diffmind init

# Suggest a message for staged changes
diffmind suggest

# Commit with the generated message (and stage all changes)
diffmind commit -a

# Interactive refinement session (arrows + free text)
diffmind session

Add the Git hook (if you skipped it during init):

diffmind hook install

What It Looks Like

┌──────────────────────────── Commit Message Suggestion ────────────────────────────┐
│ ✨ feat: add login form and validation (auth)                                     │
│                                                                                  │
│ - app/auth/LoginForm.tsx: +182 -0                                                │
│ - app/auth/validators.ts: +64 -0                                                 │
│ - i18n/en.json: +12 -0                                                           │
└──────────────────────────────────────────────────────────────────────────────────┘
💡 Use `diffmind commit` to commit with this message.

Interactive actions:

✅ Commit   🔁 Regenerate   ✏️ Edit subject/body   📝 Open in $EDITOR   ➕ Add bullet

Providers

  • simple (default) — Fast, offline heuristics based on your staged diff and file paths
  • openai (optional) — OpenAI chat completion for highly polished messages

Enable OpenAI:

  • Set API key
export OPENAI_API_KEY=sk-...
  • Install with extras (pip)
pip install -U "diffmind[ai]"
  • Or install provider only (pip)
pip install -U openai

Or run the guided setup:

diffmind config wizard

Configuration

DiffMind reads configuration from the first existing file:

  • .diffmind.toml (repo)
  • ~/.config/diffmind/config.toml (user)

Example .diffmind.toml:

provider = "auto"        # auto | simple | openai
conventional = true       # Conventional Commit types
emojis = true             # emoji prefix in subject
max_subject_length = 72
scope_strategy = "topdir" # topdir | none
language = "auto"         # auto | en | ru

# OpenAI (optional)
openai_model = "gpt-4o-mini"
# openai_base_url = "https://api.openai.com/v1"

Environment overrides:

  • DIFFMIND_PROVIDER
  • DIFFMIND_EMOJIS (1/0, true/false)
  • DIFFMIND_CONVENTIONAL (1/0, true/false)
  • OPENAI_API_KEY (for the OpenAI provider)

Git Hook

  • Installs prepare-commit-msg that pre-fills an empty message using DiffMind
  • Respects existing messages (never overwrites non‑comment content)

Commands:

diffmind hook install
# ... later
diffmind hook uninstall

Troubleshooting

  • OpenAI not detected? Ensure the openai package is installed and OPENAI_API_KEY is set. Run diffmind doctor.
  • No staged changes? DiffMind only considers staged files. git add -A first or use diffmind commit -a.
  • Prefer manual edits? Use diffmind session and choose “Open in $EDITOR”.

Security & Privacy

  • The simple provider never sends code anywhere and runs locally.
  • The OpenAI provider sends only the staged diff and prompt context to your configured OpenAI endpoint.
  • You control when OpenAI is used (auto/explicit) and can disable it any time.

Contributing

Contributions are welcome! If you plan to add a provider or improve heuristics, please keep the UX consistent and simple. Open an issue to discuss ideas.

License

MIT

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

diffmind-0.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

diffmind-0.1.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file diffmind-0.1.0.tar.gz.

File metadata

  • Download URL: diffmind-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for diffmind-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e2dffb1656c9371e679749f4ec32a0989fa8bcc583001d9fd500539dcd4a567c
MD5 2bedbabd452e15c91729227c69543919
BLAKE2b-256 7975659e795c240611ddfabea383c20cf5f70e40cbb614c2bede2eb3ee3ab2eb

See more details on using hashes here.

File details

Details for the file diffmind-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: diffmind-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for diffmind-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 533106f9bb864fa5c70b12afd6db35dbb318afc3d9cbee8f78b894fe4fedbae8
MD5 470aea2e4c27909c9d4cd27ffe8d0f0d
BLAKE2b-256 47c2936945bfae2c3bfdc2142e13efdce5313d0e27d7d10b6422e149732f2a19

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