Skip to main content

Generate Git commit messages using LLMs (OpenAI or Google Gemini)

Project description

🧠 cmitai

cmitai is a modern CLI tool that generates helpful and concise Git commit messages based on staged changes, using LLMs like OpenAI or Google Gemini.


✨ Features

  • 🔍 Analyzes git diff --cached to understand your staged changes
  • 🤖 Supports OpenAI (GPT-3.5, GPT-4) and Google Gemini (e.g., Gemini 1.5 Flash)
  • ⚡ Fast and simple CLI built with Typer
  • ✅ Supports .commitai.json configuration per project
  • 📦 Modern Python packaging with pyproject.toml and src/ layout

📦 Installation

From PyPI (when published):

pip install cmitai

For local development:

uv pip install -e .

🚀 Usage

First, stage your changes:

git add .

Then run:

cmitai generate commit

This will analyze the diff of staged files and return a suggested commit message.


🔐 Configuration

Create a .commitai.json file at the root of your Git project:

Example for OpenAI:

{
  "agent_type": "openai",
  "api_key": "sk-..."
}

Example for Google Gemini:

{
  "agent_type": "gemini",
  "api_key": "your-gemini-api-key"
}

✅ Recommended Gemini model for free tier: "models/gemini-1.5-flash"


🧪 Example Output

 git add main.py
❯ cmitai generate commit

Suggested commit message:
Improve error handling in main.py for API failures

🛠 Developer workflow

Use the included Makefile for common tasks:

make lint     # Run Ruff linter with auto-fix
make format   # Format code with Ruff
make test     # Run tests with Pytest
make check    # Lint + format

📁 Project structure

cmitai/
├── src/
│   └── cmitai/
│       ├── cli/
│       ├── configs/
│       ├── git_ops/
│       ├── llm/
│       ├── main.py
├── pyproject.toml
├── README.md
├── Makefile
├── LICENSE
└── .commitai.json  # not versioned

📄 License

MIT © [Your Name]

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

cmitai-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

cmitai-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for cmitai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df6e311b09fe3ba0ece9c6c4ebb1135708b9352f8b1701266c21667c69529e71
MD5 294aa2d0f98279aa73eab12f4d3662a7
BLAKE2b-256 8a1579b834fde952ee3c4abc9c26d266063134751248596ae18c4338a1e8e87d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cmitai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b00173d798c35af9584153d6d207234e91623fb7fc1c6e3e3b02eb63054cc17
MD5 45922227768bc6b14e33472337729e59
BLAKE2b-256 f58c9236cb0363448bf94d822d1a207ef26db5e8a7cfd47b2594f7bad0d9d40b

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