Skip to main content

ai-commit

Write good git commit messages with any AI provider.

$ ai-commit
Generating commit message...

--- Generated message ---
feat(parser): add JSON schema validation for config files

- Validate config against JSON Schema on load
- Return clear error messages for invalid config
- Add test coverage for schema validation

Create this commit? [Y/n]: y
Commit created.

Why this exists

Every other AI commit tool locks you into one provider. OpenAI only. Anthropic only. A local Ollama thing. If you switch providers, you switch tools.

ai-commit works with any provider. Same CLI, same workflow, swap the model in a config line.

Install

pip install aigitmsg

Or from source:

git clone https://github.com/Morad37/ai-commit
cd ai-commit
pip install .

Setup

Quick start (OpenAI / any OpenAI-compatible API)

export AI_COMMIT_API_KEY="sk-..."
ai-commit --setup

Other providers

export AI_COMMIT_PROVIDER="anthropic"
export AI_COMMIT_API_KEY="sk-ant-..."
export AI_COMMIT_MODEL="claude-sonnet-4-20250514"

export AI_COMMIT_PROVIDER="ollama"
export AI_COMMIT_MODEL="llama3.2"
# Ollama defaults to http://localhost:11434

export AI_COMMIT_PROVIDER="groq"
export AI_COMMIT_BASE_URL="https://api.groq.com/openai/v1"
export AI_COMMIT_MODEL="llama3-70b-8192"

Usage

# Stage all changes and generate commit
ai-commit

# Just generate a message for staged changes (no auto-stage)
ai-commit --no-stage

# Regenerate the last commit message
ai-commit --amend

# Auto-install as a git hook (runs before every commit)
ai-commit --install-hook

# Use a specific style
ai-commit --style conventional
ai-commit --style short
ai-commit --style detailed

# Generate 3 candidates and pick one
ai-commit -n 3

# Skip confirmation prompts (CI/headless)
ai-commit --yes

With -n (or --num), ai-commit generates that many distinct message candidates and lets you pick:

$ ai-commit -n 3
Generating 3 commit message candidates...
[1] feat(parser): add JSON schema validation for config files
[2] feat(config): validate config against JSON Schema on load
[3] refactor(config): surface clear errors for invalid config files

Pick a message [1]: 2

Git hook

ai-commit --install-hook

This installs a prepare-commit-msg hook that auto-generates the commit message before your editor opens. You can still edit it. If you already wrote a message, the hook leaves it alone.

Configuration

Config file at ~/.config/ai-commit/config.json:

{
  "provider": "openai",
  "model": "gpt-4o-mini",
  "api_key": "",
  "base_url": "",
  "style": "conventional",
  "max_diff_lines": 200,
  "language": "en"
}

All fields can be overridden via environment variables:

Variable Overrides
AI_COMMIT_API_KEY api_key
AI_COMMIT_MODEL model
AI_COMMIT_BASE_URL base_url
AI_COMMIT_PROVIDER provider

Supported providers

  • OpenAI (and any OpenAI-compatible API -- Groq, Together, Fireworks, OpenRouter, local vLLM, etc.)
  • Anthropic (Claude)
  • Ollama (local models)
  • Custom -- set base_url to any OpenAI-compatible endpoint

Commit styles

Style Example
conventional feat(parser): add JSON schema validation
imperative Add JSON schema validation to the config parser
short Add config validation
detailed Multi-line with bullet points explaining each change

How it works

  1. Reads the staged diff (git diff --cached)
  2. Sends it to your configured AI provider with a prompt tuned for commit messages
  3. Returns a structured commit message
  4. Either creates the commit or writes it to your editor via the hook

Only works in git repos. Only generates messages for staged changes (by default).

License

MIT

Metadata

Release files for aigitmsg 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aigitmsg 0.3.0
File Size Uploaded Provenance
aigitmsg-0.3.0.tar.gz 10.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aigitmsg 0.3.0
File Interpreter ABI Platform
aigitmsg-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.9 kB

Release files / aigitmsg-0.3.0.tar.gz

Download URL aigitmsg-0.3.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
692ef4de581d1fa33ae34bc340cfc3ca0ace8257263563e05964c571fae5aa2e
BLAKE2b-256 checksum
How to use checksums
47ad0b0862e4da6d77ab4f8e2d4df4b7f259acf4976d3264cc886c4dba3ee2a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / aigitmsg-0.3.0-py3-none-any.whl

Download URL aigitmsg-0.3.0-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68f041ab2a9df5697168dc9c5dcbe7946b51e85bda25ce4801dff0b383c787e5
BLAKE2b-256 checksum
How to use checksums
aa0b803a4c8777408ac3044c7dee779756f01777f4e606876cc8ee280b95896c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for aigitmsg 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page