Skip to main content

AI-powered git commit message generator supporting multiple providers (Gemini, Claude, OpenAI Codex)

Project description

Commit with AI

AI-powered git commit message generator supporting multiple AI providers (Gemini API, Claude CLI, Codex OAuth).

What It Does

Analyzes your staged git changes and generates 5 Conventional Commits-compliant commit message suggestions using AI. Select one or enter your own.

Installation

Via PyPI (Recommended)

# Use uvx (no installation required)
uvx commit-with-ai

# Or install globally
pip install commit-with-ai

From Source

git clone https://github.com/chenwei791129/commit-with-ai.git
cd commit-with-ai
uv run -m commit_with_ai

Setup

Provider Selection

Choose your AI provider via --provider flag or COMMIT_AI_PROVIDER environment variable:

# Use Gemini (default)
commit-with-ai

# Use Claude CLI
commit-with-ai --provider claude-cli

# Use Codex OAuth (reuses your codex ChatGPT login)
commit-with-ai --provider codex-oauth

# Or set via environment variable
export COMMIT_AI_PROVIDER="claude-cli"

Priority: --provider flag > COMMIT_AI_PROVIDER env > default (gemini)

Model Selection

Override the default model via --model flag or COMMIT_AI_MODEL environment variable:

# Use a specific model
commit-with-ai --provider claude-cli --model sonnet

# Or set via environment variable
export COMMIT_AI_MODEL="sonnet"

Priority: --model flag > COMMIT_AI_MODEL env > provider default

Gemini Provider (Default)

Set your Gemini API key:

export GEMINI_API_KEY="your-api-key-here"

Get your API key from Google AI Studio.

Setting Default
Model gemini-3-flash-preview

Claude CLI Provider

Requires Claude Code installed and authenticated locally. No API key needed — uses your existing Claude CLI credentials.

# Install Claude Code (if not already installed)
npm install -g @anthropic-ai/claude-code

# Authenticate
claude login
Setting Default
Model haiku

Codex OAuth Provider

Reuses the OAuth credentials that codex stores locally after you log in with a ChatGPT account. No API key needed — it reads the existing access token from ~/.codex/auth.json and calls the same backend codex uses.

Prerequisites: codex must be installed and logged in with a ChatGPT account (auth_mode must be chatgpt).

# Install codex (if not already installed)
npm install -g @openai/codex

# Log in with your ChatGPT account
codex login

When the stored access token has expired, this provider does not refresh it automatically. Run codex once to refresh the login, then retry commit-with-ai.

Note: This provider talks to codex's non-public backend interface (https://chatgpt.com/backend-api/codex). That interface is undocumented and may change without notice, which could break this provider until it is updated.

Setting Default
Model gpt-5.4-mini

Configure Git Alias

# If installed via pip
git config --global alias.ac '!commit-with-ai'

# Or if using uvx (no installation)
git config --global alias.ac '!uvx commit-with-ai'

Usage

git add <files>
git ac

# Or with provider/model options
git add <files>
commit-with-ai --provider claude-cli --model sonnet

Environment Variables

Variable Description Default
COMMIT_AI_PROVIDER AI provider (gemini, claude-cli, codex-oauth) gemini
COMMIT_AI_MODEL AI model name Provider-specific
GEMINI_API_KEY Gemini API key (for gemini provider)
GOOGLE_API_KEY Alternative Gemini API key

Example

Analyzing staged changes...
Generating commit message options with claude-cli (haiku)...

======================================================================
Select a commit message:
======================================================================
1. feat(auth): add user authentication system
2. feat: implement login and registration flow
3. chore(deps): add authentication dependencies
4. docs: update README with auth setup instructions
5. refactor(auth): restructure authentication module
6. Enter custom message
7. Cancel
======================================================================

Enter selection [1-7]:

Resources

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

commit_with_ai-1.3.0.tar.gz (180.4 kB view details)

Uploaded Source

Built Distribution

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

commit_with_ai-1.3.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file commit_with_ai-1.3.0.tar.gz.

File metadata

  • Download URL: commit_with_ai-1.3.0.tar.gz
  • Upload date:
  • Size: 180.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for commit_with_ai-1.3.0.tar.gz
Algorithm Hash digest
SHA256 bbbf584f6b2104abf29b85a4182d085a4f57ba810ad186072cf4d9e88b3f81b3
MD5 f81e951f18b9a8d449fcd29b8ec4b59b
BLAKE2b-256 e908af09952a7bb548b983aeff08f7fa13a2f9f842dd167ad72c9eafb0b70f59

See more details on using hashes here.

File details

Details for the file commit_with_ai-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: commit_with_ai-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for commit_with_ai-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75f701f779a04014a787bf52a7d0cee757165d2a5a12f079f9f207fecb63eaca
MD5 4e0b4f6933c42d92fe4388c1e5b33017
BLAKE2b-256 02e59b5bfb64d47e01a708f41478fd92ec8faea2cebac08747614c4cd6a7565f

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