Skip to main content

AI-powered Git commit message generator with multi-provider support

Project description

Git Auto Commit (gac)

PyPI version Python Build Status codecov Code Style: black Contributions welcome License: MIT

Features

  • LLM-Powered Commit Messages: Automatically generates clear, concise, and context-aware commit messages using large language models.
  • Deep Contextual Analysis: Understands your code by analyzing staged changes, repository structure, and recent commit history to provide highly relevant suggestions.
  • Multi-Provider & Model Support: Flexibly works with leading AI providers (Anthropic, Cerebras, Chutes.ai, Gemini, Groq, OpenAI, OpenRouter, Streamlake/Vanchin, Synthetic.new, & Z.AI) and local providers (LM Studio & Ollama), easily configured through an interactive setup or environment variables.
  • Seamless Git Workflow: Integrates smoothly into your existing Git routine as a simple drop-in replacement for git commit.
  • Extensive Customization: Tailor commit messages to your needs with a rich set of flags, including one-liners (-o), AI hints (-h), scope inference (-s), and specific model selection (-m).
  • Streamlined Workflow Commands: Boost your productivity with convenient options to stage all changes (-a), auto-confirm commits (-y), and push to your remote repository (-p) in a single step.
  • Interactive Reroll with Feedback: Not satisfied with the generated commit message? Use r for a simple regeneration, or r <feedback> to provide specific improvement suggestions (e.g., r make it shorter, r focus on the bug fix).
  • Token Usage Tracking: Display token consumption statistics (prompt, completion, and total tokens).
  • Security Scanner: Built-in detection of secrets and API keys in staged changes to prevent accidental commits of sensitive information.

How It Works

gac analyzes your staged changes to generate high-quality commit messages with the help of large language models. The tool uses a sophisticated prompt architecture that separates system instructions from user data, enabling better AI understanding and more consistent results.

How to Use

git add .
gac

Simple gac Usage

Installation and Configuration

1. Installation

Quick Try with uvx (no installation)

You can try gac without installing it using uvx:

# Try gac without installation
uvx gac --help

# Set up configuration (creates ~/.gac.env)
uvx gac init

# Use gac on staged changes
git add .
uvx gac

Permanent Installation

Install system-wide using pipx from the GitHub repository:

# Install pipx if you don't have it
python3 -m pip install --user pipx
python3 -m pipx ensurepath

# Install gac
pipx install gac

Verify installation:

gac --version

2. Configuration

The recommended way to configure gac is using the interactive setup:

gac init

This command will guide you through selecting an AI provider, model, and securely entering your API keys. It will create or update a user-level configuration file at $HOME/.gac.env.

Example $HOME/.gac.env output:

GAC_MODEL=anthropic:claude-3-5-haiku-latest
ANTHROPIC_API_KEY=your_anthropic_key_here

Alternatively, you can configure gac using environment variables or by manually creating/editing the configuration file.

Managing Configuration with gac config

You can manage settings in your $HOME/.gac.env file using gac config commands:

  • Streamlake uses inference endpoint IDs instead of model names. When prompted, paste the exact endpoint ID from the Streamlake console.

  • For local providers like Ollama and LM Studio, gac will ask for the base API URL. API keys are optional for these providers unless your instance requires authentication.

  • Show config: gac config show

  • Set a value: gac config set GAC_MODEL groq:meta-llama/llama-4-scout-17b-16e-instruct

  • Get a value: gac config get GAC_MODEL

  • Unset a value: gac config unset GAC_MODEL

3. Verify Setup

Test that gac is working properly with your configuration:

# Make a change to a file
echo "# Test change" >> README.md
git add README.md
gac -o # Generate a one-line commit message

You should see an AI-generated commit message.

4. Upgrade

To upgrade gac to the latest version, run:

pipx upgrade gac

Basic Usage

Once installed and configured, using gac is straightforward:

  1. Stage your changes:

    git add .
    
  2. Run gac:

    gac
    

    This will generate a commit message for review. Confirm with y to accept the message.

Common Commands

  • Generate a commit message: gac
  • Auto-accept the commit message: gac -y
  • Stage all changes and generate a commit message: gac -a
  • Generate a one-line commit message: gac -o
  • Add a hint for the AI: gac -h "Fixed the authentication bug"
  • Push the commit (requires accepting the commit message): gac -p
  • Advanced usage: Add all, auto-confirm, push a one-liner with a hint: gac -aypo -h "update for release"
  • Skip security scan: gac --skip-secret-scan (use with caution)

Security Features

GAC includes a built-in security scanner to prevent accidental commits of sensitive information:

  • Automatic Scanning: By default, scans all staged changes for potential secrets and API keys
  • Interactive Protection: When secrets are detected, you can:
    • Abort the commit (recommended)
    • Continue anyway (not recommended)
    • Remove affected files and continue
  • Wide Coverage: Detects AWS keys, GitHub tokens, OpenAI API keys, database URLs, private keys, and more
  • Smart Filtering: Ignores example keys, placeholders, and test values to reduce false positives

To disable the security scan (not recommended unless you know what you're doing):

# Skip scan for one command
gac --skip-secret-scan

# Or disable via environment variable
export GAC_SKIP_SECRET_SCAN=true
gac

For a full list of CLI flags, advanced options, and example workflows, see USAGE.md.

Best Practices

  • gac loads configuration from two locations (in order of precedence):
    1. User-level $HOME/.gac.env (applies to all projects for the user)
    2. Project-level .env (in the project root, overrides user config if present) Environment variables always take final precedence over both files.
  • Keep API keys out of version control
  • For troubleshooting, see docs/TROUBLESHOOTING.md

Contributing

We welcome contributions! Please see docs/CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License. See LICENSE for details.

Community & Support

For questions, suggestions, or support, please open an issue or discussion on GitHub.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gac-1.8.0.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

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

gac-1.8.0-py3-none-any.whl (54.7 kB view details)

Uploaded Python 3

File details

Details for the file gac-1.8.0.tar.gz.

File metadata

  • Download URL: gac-1.8.0.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for gac-1.8.0.tar.gz
Algorithm Hash digest
SHA256 54ceb9aac270440f32ae909f5f2b644668969c6463e8dbebe4697e499e0d16bf
MD5 de32593d1f063b41b948b6e92dc8d7be
BLAKE2b-256 120ecd05b61674ddea24ed6c1e156468d0a7e28d02ff662e223cb6b4299f4643

See more details on using hashes here.

File details

Details for the file gac-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: gac-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 54.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for gac-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6e4ba46719a019ec4af56dd39061cfe7efc255b08cae9e3ef594c1c930a6674
MD5 0517ef42d27ff3cd360b4d5bd528a568
BLAKE2b-256 885f87bc3e5a22a8b39622d5df23d6a77cdacb601dcb02fb714da53114438fd5

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