Skip to content

kasimmj/ai-commit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Stop writing fix stuff commits. ai-commit reads your staged diff and generates a clean, conventional commit message in under a second.

$ git add .
$ ai-commit
✨ Generated commit message:

  feat(auth): add refresh-token rotation with audit log

  - Rotate refresh tokens on every use
  - Persist token family for compromise detection
  - Log all rotations to security_audit table

Accept this message? [Y/n/edit/regen]

InstallUsageConfigurationWhy?


⚡ Install

Via pip (recommended)

pip install ai-commit

Via curl

curl -fsSL https://raw.githubusercontent.com/kasimmj/ai-commit/main/install.sh | bash

Via git clone

git clone https://github.com/kasimmj/ai-commit
cd ai-commit && pip install -e .

🚀 Usage

Basic

git add .
ai-commit

Choose a model

ai-commit --model gpt-4o-mini       # OpenAI
ai-commit --model claude-haiku-4    # Anthropic
ai-commit --model llama3.2          # Local via Ollama

Commit in Arabic

ai-commit --lang ar
# → "feat(auth): إضافة دورة تجديد رموز التحديث"

Generate without committing

ai-commit --dry-run

Auto-accept (CI / scripts)

ai-commit --yes

Install as a pre-commit hook

ai-commit --install-hook

Now git commit (without -m) opens with the AI message pre-filled in your editor.


⚙️ Configuration

Create ~/.ai-commit.toml:

[default]
model = "gpt-4o-mini"
language = "en"
emoji = true
max_diff_lines = 500

[providers.openai]
api_key_env = "OPENAI_API_KEY"
base_url = "https://api.openai.com/v1"

[providers.anthropic]
api_key_env = "ANTHROPIC_API_KEY"

[providers.ollama]
base_url = "http://localhost:11434"

[prompts]
# Customize the system prompt
style = "conventional"   # conventional | gitmoji | plain
length = "concise"       # concise | detailed

Env vars override:

AI_COMMIT_MODEL=claude-haiku-4 ai-commit

💡 Why ai-commit?

Without ai-commit With ai-commit
fix stuff fix(api): handle 429 from upstream gracefully
wip wip(dashboard): export CSV partial — handle pagination next
updates chore(deps): bump axios 1.6.0 → 1.7.2 for ReDoS fix
asdfasdf refactor(payments): extract Stripe client into adapter

You spend 3 seconds instead of 90 seconds, and your git log actually tells the story of your project.


🧠 How it works

  1. Reads git diff --cached (your staged changes)
  2. Detects the most-changed file types and scope
  3. Sends a focused prompt to the chosen model
  4. Parses the response into a conventional commit format
  5. Shows you the result, lets you accept / edit / regenerate / cancel

The prompt is designed for fast, cheap models (Haiku, GPT-4o-mini, llama3.2:3b). You don't need GPT-4 for a commit message.


🔒 Privacy

  • Diffs are sent to the model you choose
  • Use a local model (Ollama) for zero data leaving your machine
  • Secrets in the diff are auto-redacted (regex patterns: API keys, tokens, passwords) before sending

📜 License

MIT © 2026 Kasim Mohammed


Star ⭐ if you've ever committed fix bug and regretted it.

About

✨ AI-powered git commit message generator — Conventional Commits, multi-language (English/Arabic), blazing fast.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors