Skip to main content

Generate Git commit messages using local or remote AI models.

Project description

🧠 CommitBro

CommitBro is a privacy-first, local-friendly Git commit message generator that uses modern LLMs like Mistral, Starling, or TinyLlama — all running locally via Ollama, or optionally via a hosted FastAPI backend.


✨ Features

  • 🔐 100% privacy-first — no data leaves your machine
  • 🤖 Generates commit messages from git diff --cached
  • 🎯 Instruction-tuned LLMs: Mistral, TinyLlama, Starling, Gemma, etc.
  • 🧠 Optional training from your own commit history
  • 🧰 FastAPI backend included (for training and expansion)
  • 🌍 Supports multi-language commit messages
  • 🐳 Docker-ready for container lovers

📦 Installation

1. Clone and Install (Dev Mode)

git clone https://github.com/yourusername/commitbro.git
cd commitbro
pip install -e .

Requires Python 3.12+, Ollama, and git.

2. Run Setup

commitbro-setup

Choose:

  • Your preferred language (e.g. English, Spanish, Hindi)
  • Whether to train models (locally, remotely, or skip)
  • Your preferred model (mistral, tinyllama, etc.)

🚀 Usage

  1. Stage your changes:

    git add .
    
  2. Generate commit message:

    commitbro
    
  3. Accept, regenerate, or cancel:

    Suggested Commit Message:
    > Fix user login state handling on timeout
    
    ✅ Accept this? [y/n/r]: 
    
  4. If accepted, CommitBro will automatically commit your changes.


⚙️ Configuration

CommitBro stores user settings in:

~/.commitgen/config.json

Sample config:

{
  "language": "English",
  "training": "none",
  "remote_training_url": "",
  "model": "mistral"
}

You can change the model, language, or training config anytime by rerunning:

commitbro-setup

🧠 Model Support (via Ollama)

Run any local model supported by Ollama:

Model Size Speed Notes
tinyllama ~1.1B ⚡⚡⚡ Very fast, small commits
mistral 7B General purpose, accurate
starling 7B Optimized for dialogue
phi 2.7B ⚡⚡ Compact + reasoning
gemma:2b 2B ⚡⚡ Google’s latest compact model

To pull models:

ollama pull mistral
ollama run mistral

🛠️ Training

Extract commit history and send to remote training server:

commitbro-train

Only enabled if you selected remote or both training during setup.

You can use the included FastAPI server for training endpoints (see below).


🌐 FastAPI Backend (Optional)

A minimal FastAPI server is included for collecting commit training data.

Run it locally:

cd fastapi_server
uvicorn main:app --reload

Available Endpoint:

  • POST /train — Accepts commit history for training
{
  "commits": [
    {
      "hash": "abc123",
      "message": "Fix bug in login flow",
      "body": "Adjusted redirect logic in session manager"
    }
  ]
}

🐳 Docker Support

Run CommitBro inside a container (CLI mode):

docker build -t commitbro .
docker run --rm -v $(pwd):/app commitbro

Or to expose FastAPI:

docker run -p 8000:8000 commitbro uvicorn fastapi_server.main:app --host 0.0.0.0 --port 8000

📁 Project Structure

commitbro/
  ├── cli.py              # Main CLI logic
  ├── core.py             # Git diff + model API
  ├── train.py            # Training script
  ├── setup_config.py     # First-time setup wizard

fastapi_server/
  └── main.py             # Remote training API

pyproject.toml            # Modern packaging config
Dockerfile                # Optional container setup
README.md                 # You're reading it!

🧰 Packaging & Build

Uses hatchling and pyproject.toml (PEP 621).

Install locally:

pip install -e .

🧪 Roadmap

  • CLI with diff-based message generation
  • Language + training setup wizard
  • Remote FastAPI training backend
  • VS Code extension
  • Frontend (Next.js + ShadCN UI)
  • Auth + analytics-free SaaS version

🧑‍💻 Author

Built with 💚 by @aidataguy


📜 License

MIT License — do whatever you want, just keep it open.

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

commitbro-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

commitbro-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: commitbro-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for commitbro-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a90b59d447867510cfc0e548ad97c07e7fdbce1c4f15587bcbee47114ec679c
MD5 44934a8bc201f2376e18306a55ef35a5
BLAKE2b-256 90cfcd9ab98c2b6cd5d222e99e7c16a0d52b4635596bd0b79dfc92f232aa0f88

See more details on using hashes here.

File details

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

File metadata

  • Download URL: commitbro-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for commitbro-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 04a7b68f10a6818cbb951a8db974673c927489e27a151b9bc03cb300d8a0f4ce
MD5 674815350ea52b745d574ac5c9c36e90
BLAKE2b-256 a2487ddac71d7e627e1c8d47f26ff71f81df6d1b4c12d6c47c2a7fa97ab606a2

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