Skip to content

CLI tool that generates conventional commit messages using AI. Supports OpenAI, Anthropic, Google Gemini, DeepSeek, Ollama, and any OpenAI-compatible API. Built with Java 25 & GraalVM for instant startup. Works everywhere, terminal, any IDE, any platform. 100% local option available.

License

Notifications You must be signed in to change notification settings

kxng0109/ai-commit-cli

Repository files navigation

AI Commit CLI

img.png

Generate conventional commit messages using AI. It supports OpenAI, Anthropic Claude, Google Gemini, DeepSeek, Ollama, and any OpenAI-compatible API.

Release Release CI License: MIT

Why This Exists

I was tired of writing vague commit messages like "fix stuff" and "updates", even using sentences like "added ..." or "made ...". I wanted AI to analyze my git diffs and generate proper commit messages, so I started searching for solutions.

What I found:

  • Tools that didn't work or were too complicated to set up
  • Solutions that didn't integrate well with IntelliJ IDEA (my main IDE)
  • The JetBrains AI Assistant plugin, which was almost perfect

The JetBrains AI Assistant Problem:

The plugin works great and integrates seamlessly with IntelliJ. It can generate commit messages using local models (Ollama, LM Studio) or cloud models, and even do wayyy more things. The free tier is generous, and it gives you access to tons of models. Basically Google's full lineup, Anthropic's Claude, OpenAI (even GPT-5.1).

But here's where I hit a wall:

  • No custom API endpoints - I couldn't use OpenRouter to access multiple providers with one key
  • No DeepSeek - What if I wanted to use their cost-effective API directly?
  • IDE-locked - Only works in JetBrains IDEs (requires IntelliJ IDEA Ultimate license)
  • Not portable - What if I switch to VSCode, Sublime Text, or just use the terminal?

I wanted freedom:

  • Use models from anywhere - OpenRouter, DeepSeek, local Ollama, custom endpoints
  • Work with any editor/IDE
  • Run from the terminal on any platform
  • Own my workflow completely

So I built this. A standalone CLI that works everywhere, supports any OpenAI-compatible API, you determine the cost (you can use free or paid providers, the choice is yours), and never locks you into a specific IDE or subscription.

Features

  • True Multi-Provider Support - OpenAI, Anthropic, Google Gemini, DeepSeek, Ollama, or any OpenAI-compatible API (OpenRouter, Together AI, etc.)
  • Use Any API - Not limited to specific providers. Bring your own endpoint
  • Conventional Commits - Follows specification automatically
  • Interactive Mode - Review, regenerate, edit, or cancel before committing
  • Auto-Commit & Auto-Push - Flexible automation options (work independently for maximum flexibility)
  • Native Binary - No runtime dependencies, starts in <50ms
  • Cross-Platform - Linux, macOS, Windows
  • Privacy Option - Use Ollama for 100% local processing (but be sure that you're using a model that your system can handle)
  • IDE-Agnostic - Works from any terminal, any editor
  • Cost Control - Use free providers or choose your own pricing tier

Installation

Option 1: One-Line Installer (Easiest)

Linux/macOS:

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

Windows (PowerShell as Administrator not required):

irm https://raw.githubusercontent.com/kxng0109/ai-commit-cli/main/install.ps1 | iex

Option 2: Download Binary Manually

Download the pre-built binary for your platform from Releases.

Linux:

curl -L https://github.com/kxng0109/ai-commit-cli/releases/latest/download/ai-commit-linux-amd64 -o ai-commit
chmod +x ai-commit
sudo mv ai-commit /usr/local/bin/
ai-commit --version

macOS:

curl -L https://github.com/kxng0109/ai-commit-cli/releases/latest/download/ai-commit-macos-amd64 -o ai-commit
chmod +x ai-commit
sudo mv ai-commit /usr/local/bin/
ai-commit --version

Windows (PowerShell):

Invoke-WebRequest -Uri "https://github.com/kxng0109/ai-commit-cli/releases/latest/download/ai-commit-windows-amd64.exe" -OutFile "ai-commit.exe"
# Move to a directory in your PATH, e.g., C:\
Move-Item ai-commit.exe C:\
ai-commit --version

Build from Source

Requirements:

  • GraalVM 25 (with native-image)
  • Apache Maven 3.9.11
  • Java 25

Steps:

git clone https://github.com/kxng0109/ai-commit-cli.git
cd ai-commit-cli

mvn clean package -Pnative

# Binary location: target/ai-commit (or ai-commit.exe on Windows)
sudo cp target/ai-commit /usr/local/bin/  # Linux/macOS
# or add to PATH on Windows

ai-commit --version

Development build (JAR, faster):

mvn clean package
java -jar target/ai-commit-cli-1.0.0.jar --version

Quick Start

1. Configure AI Provider (choose one):

# OpenAI
export OPENAI_API_KEY="sk-..."

# Anthropic Claude
export ANTHROPIC_API_KEY="sk-ant-..."

# Google Gemini
export GOOGLE_API_KEY="AIza..."

# DeepSeek
export DEEPSEEK_API_KEY="..."

# Ollama (local)
export OLLAMA_MODEL="llama3.2"

2. Use:

cd your-git-repo
git add .
ai-commit

Configuration

AI Providers

Provider Required Optional
OpenAI OPENAI_API_KEY OPENAI_MODEL (default: gpt-4o-mini)
OPENAI_BASE_URL (default: https://api.openai.com)
Anthropic ANTHROPIC_API_KEY ANTHROPIC_MODEL (default: claude-sonnet-4-0)
Google GOOGLE_API_KEY GOOGLE_MODEL (default: gemini-2.0-flash)
DeepSeek DEEPSEEK_API_KEY -
Ollama OLLAMA_MODEL OLLAMA_BASE_URL (default: http://localhost:11434)

Priority: OpenAI → Anthropic → Google → DeepSeek → Ollama

Optional Settings

Variable Default Range
AI_TEMPERATURE 0.1 0.0 - 2.0
AI_COMMAND_TIMEOUT 30 1 - 3600 seconds
AI_LOG_LEVEL WARN ERROR, WARN, INFO, DEBUG

User Preferences (Persistent)

Configure workflow automation that persists across restarts:

# View current settings
ai-commit config --show

# Enable auto-commit (skip interactive prompts)
ai-commit config --auto-commit on

# Enable auto-push (push after committing)
ai-commit config --auto-push on

# Disable automation
ai-commit config --auto-commit off
ai-commit config --auto-push off

# Reset all settings
ai-commit config --reset

# Show config help
ai-commit config --help

Usage Modes

Interactive Mode (Default)

Review and control every commit:

git add .
ai-commit

Output:

AI generated commit message:
────────────────────────────────────────────────────────────
feat(auth): add OAuth2 authentication flow

Implement Google OAuth2 integration with JWT token handling
and secure session management.
────────────────────────────────────────────────────────────

Commit with this message? (y)es / (r)egenerate / (e)dit / (c)ancel [y]:

Options:

  • y (yes) - Commit with the AI-generated message (default, just press Enter)
  • r (regenerate) - Generate a new message with different wording
  • e (edit) - Manually edit the message before committing
  • c (cancel) - Cancel and don't commit

Auto-Commit Mode

Skip prompts and commit immediately:

# One-time setup
ai-commit config --auto-commit on

# Fast workflow
git add .
ai-commit  # Commits automatically, no prompts

⚠️ Warning: When auto-commit is enabled:

  • You cannot regenerate the message
  • You cannot edit the message
  • You cannot cancel the commit
  • If AI generation fails, nothing is committed

Auto-Push Mode

Automatically push after committing:

# One-time setup
ai-commit config --auto-push on

# Super fast workflow
git add feature.js
ai-commit  # If auto-commit is enabled, it commits instantly AND pushes instantly!
# Note: auto-push does not require auto-commit to work

Examples

OpenAI:

export OPENAI_API_KEY="sk-..."
git add .
ai-commit

OpenRouter (multiple providers):

export OPENAI_API_KEY="sk-or-..."
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_MODEL="openai/gpt-oss-20b:free"
git add .
ai-commit

Ollama (100% local):

ollama serve &
export OLLAMA_MODEL="llama3.2"
git add .
ai-commit

Rapid Development Workflow:

# One-time setup
ai-commit config --auto-commit on
ai-commit config --auto-push on

# Daily usage
git add src/
ai-commit  # Committed and pushed
git add tests/
ai-commit  # Committed and pushed

Careful Review Workflow:

# Ensure interactive mode
ai-commit config --auto-commit off

# Review each commit
git add feature.js
ai-commit

How It Works

  1. Stage your changes: git add .
  2. Run ai-commit: Analyzes the git diff
  3. AI generates message: Sends to your configured provider (OpenAI, OpenRouter, Ollama, etc.)
  4. Alerts user: Shows the commit message with some options for the user to decide if they are satisfied with the generated commit message.
Staged diff → AI analysis → Commit message → [Interactive/Auto] → Git commit → [Optional push]

Real-World Comparison

JetBrains AI Assistant (what I was using):

✅ Great IDE integration
✅ Generous free tier
✅ Many models (Google, Anthropic, OpenAI)
❌ Can't use OpenRouter/DeepSeek/custom APIs
❌ Requires IntelliJ IDEA Ultimate
❌ IDE-locked (no terminal/other editors)

AI Commit CLI (what I built):

✅ Use ANY provider (OpenRouter, DeepSeek, custom endpoints)
✅ Works anywhere (any IDE, terminal, SSH sessions)
✅ Auto-commit & auto-push for rapid workflows
✅ Free and open source
✅ Full control over API costs
✅ 100% local option with Ollama
✅ ~99MB binary, no dependencies

Example Output

Before:

git commit -m "updated auth stuff"

After (Interactive Mode):

$ ai-commit

AI generated commit message:
────────────────────────────────────────────────────────────
feat(auth): add OAuth2 authentication flow

Implement Google OAuth2 integration with JWT token handling,
refresh token rotation, and secure session management.

BREAKING CHANGE: API now requires OAuth2 tokens
────────────────────────────────────────────────────────────

Commit with this message? (y)es / (r)egenerate / (e)dit / (c)ancel [y]: y

[main abc1234] feat(auth): add OAuth2 authentication flow
 3 files changed, 145 insertions(+), 12 deletions(-)

After (Auto-Commit Mode):

$ ai-commit

AI generated commit message:
────────────────────────────────────────────────────────────
feat(auth): add OAuth2 authentication flow

Implement Google OAuth2 integration with JWT token handling,
refresh token rotation, and secure session management.
────────────────────────────────────────────────────────────

Auto-committing...

[main abc1234] feat(auth): add OAuth2 authentication flow
 3 files changed, 145 insertions(+), 12 deletions(-)

Auto-pushing...

To github.com:user/repo.git
   def5678..abc1234  main -> main

Advanced Configuration

Using OpenRouter (Multiple Models via One API)

Access Claude, GPT-4, Llama, and more through OpenRouter:

export OPENAI_API_KEY="sk-or-v1-..."
export OPENAI_BASE_URL="https://openrouter.ai/api/v1"
export OPENAI_MODEL="qwen/qwen3-coder"
# or: "openai/gpt-4o", etc.
git add .
ai-commit

Temperature Control

Higher = more creative, lower = more deterministic:

export AI_TEMPERATURE="0.0"  # Very consistent
export AI_TEMPERATURE="0.5"  # Balanced (recommended for variety)
export AI_TEMPERATURE="1.5"  # More creative descriptions

Debugging

export AI_LOG_LEVEL="DEBUG"
ai-commit

Long-running Git Operations

export AI_COMMAND_TIMEOUT="120"  # 2 minutes (default: 30)

Workflow Customization

# Maximum speed. Auto-commit + auto-push
ai-commit config --auto-commit on
ai-commit config --auto-push on

# Fast commits, manual pushes. Review before pushing
ai-commit config --auto-commit on
ai-commit config --auto-push off

# Full control. Review every message
ai-commit config --auto-commit off

Technical Details

Built With:

  • Java 25
  • Apache Maven 3.9.11
  • GraalVM 25 (native-image)
  • Spring AI 1.1.0

Binary Size: ~99MB (includes all 5 AI providers)

Startup Time: <50ms (native binary)

Supported Platforms:

  • Linux x86_64 (glibc 2.17+)
  • macOS x86_64 (10.13+)
  • Windows x86_64 (10+)

Troubleshooting

"No staged changes found"

git status  # Verify you're in a git repo
git add .   # Stage your changes first

"Cannot connect to AI provider"

# Verify API key is set
echo $OPENAI_API_KEY

# Test with debug logging
export AI_LOG_LEVEL=DEBUG
ai-commit

"Command not found"

  • Ensure binary is in PATH
  • Restart terminal after installation

"Auto-push failed but commit succeeded"

  • This is expected behavior but commit is preserved
  • Push manually: git push
  • Check remote configuration: git remote -v

"Auto-commit not working"

# Check if enabled
ai-commit config --show

# Enable it
ai-commit config --auto-commit on

Development

# Build JAR (fast iteration)
mvn clean package
java -jar target/ai-commit-cli-1.0.0.jar

# Build native binary
mvn clean package -Pnative

# Run with debug logging
export AI_LOG_LEVEL=DEBUG
./target/ai-commit

# Run tests
mvn test

FAQ

Q: Why not just use JetBrains AI Assistant?
A: It's excellent for IntelliJ users, but it limits you to their provider selection (no OpenRouter, DeepSeek, or custom APIs), requires IntelliJ IDEA Ultimate, and only works inside JetBrains IDEs. This tool works everywhere and with any provider.

Q: Which AI provider should I use?
A: Honestly, it's your choice. For instance, I use OpenRouter mainly since you can get really good models for free and have access to a lot of models with just one API key. Then I use ollama (or LM Studio) just for testing. You can get professional grade models, but you're limited by your system's hardware.

Q: Does this send my code to AI providers?
A: It sends the git diff (changes only), not your entire codebase. Use Ollama for fully local processing with zero external API calls.

Q: When should I use auto-commit vs interactive mode?
A: Use auto-commit for rapid development when you trust the AI (small, frequent commits). Use interactive mode when you want to review messages carefully (large changes, important commits).

Q: What happens if AI generation fails with auto-commit enabled?
A: Nothing is committed. Auto-commit only proceeds if the AI successfully generates a valid message. Your changes remain staged.

Q: Can I edit the message with auto-commit enabled?
A: No. Auto-commit skips all prompts. Disable it first: ai-commit config --auto-commit off

Q: Does auto-push require auto-commit?
A: No. Auto-push can work without auto-commit being enabled. But if you need a fully automated workflow, you can enable it, just note that you won't be able to modify the commit message.

Q: How much does it cost?
A: Depends on your provider:

  • OpenAI gpt-4o-mini: ~$0.0001-0.001 per commit
  • DeepSeek: ~$0.00001 per commit
  • Ollama: $0 (free, local)
  • OpenRouter: Varies by model (many free options)

Q: Why is the binary 99MB?
A: It includes 5 AI provider SDKs and the GraalVM runtime for instant startup. Future versions may offer slim builds with only the providers you need.

Q: Does it work with monorepos?
A: Yes, it analyzes all staged changes regardless of repo structure.

Q: Can I use this in CI/CD?
A: Yes! Set environment variables and enable auto-commit for fully automated commit message generation in pipelines.

Q: Can I export my settings?
A: Not directly, but they're stored in standard OS locations. You can back up those files manually.

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

License

MIT - use freely, commercially or personally.

Acknowledgments

Support

Related Projects


Built because I wanted to use OpenRouter and DeepSeek from anywhere, not just IntelliJ. Now with auto-commit and auto-push for lightning-fast workflows. If it helps you too, give it a star 🤗

About

CLI tool that generates conventional commit messages using AI. Supports OpenAI, Anthropic, Google Gemini, DeepSeek, Ollama, and any OpenAI-compatible API. Built with Java 25 & GraalVM for instant startup. Works everywhere, terminal, any IDE, any platform. 100% local option available.

Topics

Resources

License

Contributing

Stars

Watchers

Forks