Skip to main content

AI-powered tool to analyze Git commits for bugs and issues

Project description

CommitGuard

AI-powered CLI that analyzes Git commits for bugs, security issues, and code quality problems. Uses OpenRouter for access to GPT-4, Claude, Gemini, and 100+ other models.

GitHub · PyPI

Features

  • Analyze commits – Detect bugs, security issues, and code quality problems
  • Pre-commit check – Review staged changes before committing
  • Multi-model – Use any model on OpenRouter (GPT-4, Claude, Gemini, etc.)
  • Chronological batch analysisanalyze -n processes commits oldest to newest
  • Quiet base command – Update checks run only when a subcommand is invoked
  • Simple CLI – One command, clear output

Requirements

Installation

pip install commitguard-cli

From source:

git clone https://github.com/PierrunoYT/commitguard.git
cd commitguard
pip install -e .

Configuration

Get an API key at openrouter.ai/keys:

# Linux / macOS
export OPENROUTER_API_KEY=sk-or-...

# Windows (PowerShell)
$env:OPENROUTER_API_KEY = "sk-or-..."

Optional – default model (otherwise openai/gpt-4o-mini):

export OPENROUTER_MODEL=anthropic/claude-3.5-sonnet   # Linux/macOS
$env:OPENROUTER_MODEL = "anthropic/claude-3.5-sonnet" # Windows

Usage

# Analyze last commit
commitguard analyze

# Analyze specific commit
commitguard analyze abc123

# Analyze last 5 commits
commitguard analyze -n 5

# Analyze staged changes (before commit)
commitguard check

# Use a different model
commitguard analyze --model anthropic/claude-3.5-sonnet
commitguard analyze -m google/gemini-pro

When using analyze -n, commits are analyzed in chronological order (oldest to newest).

Options

Option Description
-r, --repo PATH Path to Git repository (default: current dir)
--api-key KEY OpenRouter API key (or OPENROUTER_API_KEY env)
-m, --model MODEL Model to use (default: openai/gpt-4o-mini or OPENROUTER_MODEL env)

Model examples

Model Use case
openai/gpt-4o-mini Fast, cheap (default)
openai/gpt-4o Higher quality
anthropic/claude-3.5-sonnet Strong code analysis
google/gemini-pro Alternative option

See OpenRouter models for the full list.

Troubleshooting

Error Solution
Invalid or missing API key Set OPENROUTER_API_KEY or use --api-key. Get a key at openrouter.ai/keys
Model not found Use the full model ID (e.g. openai/gpt-4o-mini). Check openrouter.ai/models
Rate limit exceeded Wait and retry, or switch to a different model
Request timed out Retry the command, or use a faster/smaller model
Service unavailable OpenRouter may be down; try again later

Security: Never commit your API key. Use environment variables or --api-key at runtime.

License

MIT

Changelog

CHANGELOG.md

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

commitguard_cli-0.1.3.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

commitguard_cli-0.1.3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file commitguard_cli-0.1.3.tar.gz.

File metadata

  • Download URL: commitguard_cli-0.1.3.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for commitguard_cli-0.1.3.tar.gz
Algorithm Hash digest
SHA256 114d6bcaa4f36b5e5057675c6b896f389ee60600d60edd4f484dcc8443add0c4
MD5 216cedc670532b70047543985a4af92e
BLAKE2b-256 06919ff305e243095d7b5c50ad3484267d7242d65ea7f28ce230348b95327424

See more details on using hashes here.

File details

Details for the file commitguard_cli-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for commitguard_cli-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4d877cdec23ed2e6ba7f6f4d017c20f1691cf541e1e1e5a727259d7a996c8774
MD5 c68f57bf47f8424383faa1d6d8961945
BLAKE2b-256 00f24961db6d4d5067582b88736052d19be7a8ad673c922e521df399c75a42a8

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