ai-commit

AI-Commit

commit

AI-Commit is a powerful CLI tool designed to revolutionize your Git workflow by leveraging AI for three key tasks: generating commit messages, providing basic code reviews, and enforcing commit message style guides. By integrating cutting-edge AI models, AI-Commit helps you create meaningful, Conventional Commits-compliant messages, get quick feedback on your code changes, and ensure your commit messages adhere to a high standard of clarity and informativeness—all right from your terminal.

It supports:

Boost your commit quality, enforce standards, and save valuable time with AI-Commit, your all-in-one AI assistant for Git workflows.

https://github.com/renatogalera/ai-commit


🛠️ Installation

You can install AI-Commit using one of two methods: via our automated installation script or by building from source.

Automated Installation via Script

The installation script will:

To install via the script, run the following commands in your terminal:

curl -sL https://raw.githubusercontent.com/renatogalera/ai-commit/main/scripts/install_ai_commit.sh | bash

Note: If you are not running as root, the script will prompt for your password to use sudo when moving the binary.

Building from Source

If you prefer to build AI-Commit manually from source, follow these steps:

git clone https://github.com/renatogalera/ai-commit.git
cd ai-commit
go build -o ai-commit ./cmd/ai-commit
# Optionally, move the binary into your PATH for global access:
sudo mv ai-commit /usr/local/bin/

✨ Key Features


⚙️ Configuration

AI-Commit automatically creates a config.yaml file at ~/.config/ai-commit/config.yaml upon first run. This file lets you personalize default settings:

# Your name and email address for git commits.
authorName: "Your Name"
authorEmail: "youremail@example.com"

provider: "phind"

phindApiKey: ""             # Phind does not require an API key by default
phindModel: "Phind-70B"      # Current Phind model is free

openAiApiKey: "sk-YOUR-OPENAI-KEY"
openaiModel: "gpt-4o-latest"

geminiApiKey: "YOUR-GEMINI-KEY"
geminiModel: "models/gemini-2.0-flash"

anthropicApiKey: "sk-YOUR-ANTHROPIC-KEY"
anthropicModel: "claude-3-5-sonnet-latest"

deepseekApiKey: "YOUR-DEEPSEEK-KEY"
deepseekModel: "deepseek-chat"

semanticRelease: false
interactiveSplit: false
enableEmoji: false
commitType: ""
template: ""
promptTemplate: "" # Customize the AI prompt template for commit messages, reviews, and style checks
commitTypes:
  - type: "feat"
    emoji: "✨"
  - type: "fix"
    emoji: "🐛"
  - type: "docs"
    emoji: "📖"
  - type: "style"
    emoji: "🎨"
  - type: "refactor"
    emoji: "♻️"
  - type: "test"
    emoji: "🧪"
  - type: "chore"
    emoji: "🔧"
  - type: "perf"
    emoji: "⚡"
  - type: "build"
    emoji: "📦"
  - type: "ci"
    emoji: "🚀"

lockFiles: # Specify lock files to be ignored in diffs for commit messages and reviews
  - "go.mod"
  - "go.sum"

Note: Command-line flags always take precedence over configuration file values. API keys can be set via environment variables or within config.yaml. You can now also customize the promptTemplate in this file to adjust the behavior of both commit message generation and code reviews.

API Keys via Environment Variables:


🚀 Basic Usage

  1. Stage your changes:
    git add .
    
  2. Commit Message Generation
     ai-commit
    

    Standard interactive commit message generation, without style review.

    • Confirm Commit: Enter or y to commit with the generated message.
    • Regenerate Message: r to generate a new commit message. Track regen attempts in the UI.
    • Change Commit Type: t to select a different commit type, influencing AI generation.
    • Edit Message: e to manually edit the commit message in the TUI (Ctrl+s to save, Esc to cancel).
    • Edit Prompt: p to customize the AI prompt text for specific instructions (Ctrl+s to apply, Esc to cancel).
    • View Diff: l to review the full Git diff within the TUI (Esc or q to return).
    • Help: ? to toggle help text showing keybindings.
    • Quit: q, Esc, or Ctrl+C to exit without commit.
    • AI Style Review Feedback: When using --review-message, any style feedback from the AI will also be displayed in the TUI (feature to be implemented in future versions for interactive feedback). For now, feedback is shown in the terminal output before the TUI.

🎛️ Command-Line Flags

Main Flags:

Workflow Control Flags:

Subcommand:


✍️ More Examples

  1. Summarize a Commit:
    ai-commit summarize
    

    Lists commits with fzf, and after you pick one, shows an AI-generated summary in the terminal.

  2. Interactive Commit with Style Review:
    ai-commit --review-message
    

    Launches the interactive TUI after generating and AI-reviewing the commit message style.

  3. Force Commit with Style Review (Non-Interactive):
    ai-commit --force --review-message
    

    Directly commits staged changes after generating and AI-reviewing the commit message style, skipping the TUI. Style review feedback is printed to the terminal before commit.

  4. AI-Powered Code Review:
    ai-commit review
    

    Executes AI code review and outputs suggestions to the terminal.

  5. Semantic Release (Manual Version):
    ai-commit --semantic-release --manual-semver
    

    Semantic release with manual version selection TUI.

  6. Provider and Model Selection:
    ai-commit --provider=openai --model=gpt-4 --apiKey=sk-...
    ai-commit --provider=gemini --model=models/gemini-2.0-flash --geminiApiKey=...
    ai-commit --provider=anthropic --model=claude-3-sonnet --anthropicApiKey=...
    ai-commit --provider=deepseek --model=deepseek-chat --deepseekApiKey=...
    ai-commit --provider=phind --model=Phind-70B           # Phind model is currently free; API key is optional
    
  7. Interactive Split Commit:
    ai-commit --interactive-split