Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-commit

Generate meaningful git commit messages from your staged diff using OpenAI GPT. Supports interactive edit, dry-run mode, and CI pipelines.

Install

pip install openai
curl -o /usr/local/bin/ai-commit https://raw.githubusercontent.com/breitzer/ai-commit/main/ai_commit.py
chmod +x /usr/local/bin/ai-commit

Or clone:

git clone https://github.com/breitzer/ai-commit.git
cd ai-commit && bash install.sh

Setup

export OPENAI_API_KEY=sk-...
# Add to ~/.bashrc or ~/.zshrc to persist

Usage

# Stage your changes first, then:
ai-commit

# Stage all tracked changes automatically
ai-commit --all

# Print message without committing
ai-commit --dry-run

# Add context (ticket number, PR description)
ai-commit --context "closes #42, refactors auth middleware"

# Use a specific model
ai-commit --model gpt-4o

Demo

$ git add app/Http/Middleware/AuthMiddleware.php
$ ai-commit

Generating commit message with gpt-4.1-mini...

────────────────────────────────────────────────────────────
Proposed commit message:

refactor(auth): extract token validation into AuthMiddleware

- Moves JWT decode logic out of controllers for single responsibility
- Adds early return on missing Authorization header
- Fixes edge case where expired tokens returned 500 instead of 401
────────────────────────────────────────────────────────────

[c]ommit / [e]dit / [a]bort? c

[main a3f91c2] refactor(auth): extract token validation into AuthMiddleware
Committed.

Options

Flag Description
--all, -a Run git add -u before generating
--dry-run, -n Print message without committing
--context, -c Extra hint for the model
--model, -m OpenAI model (default: gpt-4.1-mini)
--no-verify Skip pre-commit hooks

Requirements

  • Python 3.8+
  • openai package
  • OPENAI_API_KEY environment variable

License

MIT

About

Generate meaningful git commit messages using OpenAI GPT from staged diffs

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages