Python AI commit tools¶
A single self-healing script (aic.py) that turns git diff --cached into a
clean, conventional commit message. One CLI, four providers — Anthropic Claude,
Google Gemini, OpenAI, and Ollama (local) — selected by auto-detection (Ollama →
Anthropic → Gemini → OpenAI) or forced with --provider. Flags work the same for
every provider.
For a side-by-side comparison of providers, flags, costs, and setup, see the bundled comparison guide:
AI commit comparison guide (full text)
AI Commit Tools Comparison¶
A single script — aic.py — turns git diff --cached into a clean, conventional
commit message using one of four AI providers. It auto-detects the best available
provider, or you can force one with --provider. All flags work identically across
providers.
Providers¶
| Provider | Alias | API key | Default model | Notes |
|---|---|---|---|---|
| Ollama (local) | git aicl |
none | first installed of PREFERRED_MODELS |
Free, private, no network; auto-falls back to smaller models on OOM/timeout |
| Anthropic Claude | git aica |
ANTHROPIC_API_KEY |
claude-haiku-4-5 |
Fast, high quality |
| Google Gemini | git aicg |
GOOGLE_API_KEY / GEMINI_API_KEY |
gemini-2.0-flash |
Generous free tier |
| OpenAI | git aico |
OPENAI_API_KEY |
low-cost auto-pick (-m to choose) |
State-of-the-art quality |
git aic (no provider) auto-detects in priority order: Ollama → Anthropic →
Gemini → OpenAI (Ollama first because it's free and local). Use git aic --cloud
(or -c) to skip Ollama and use the best available cloud provider. If Ollama runs
but every local model is exhausted, aic offers to switch to a cloud provider.
Quick start¶
```powershell
Set whichever cloud key(s) you want (PowerShell; use setx to persist)¶
$env:ANTHROPIC_API_KEY = "..." $env:GOOGLE_API_KEY = "..." $env:OPENAI_API_KEY = "..."
Ollama needs no key — just run ollama serve and ollama pull <model>¶
```
bash
git aic # auto-detect provider, commit staged changes
git aica # force Anthropic
git aicg # force Gemini
git aico # force OpenAI
git aicl # force Ollama (local)
git aic --cloud # auto-detect, but skip Ollama
git aic --provider openai -m # equivalent to: force OpenAI, pick model interactively
Command flags (identical for every provider)¶
| Flag | Description |
|---|---|
FILES... |
Stage the named files first |
-a, --add-all |
Stage all changes before committing |
-c, --cloud |
Skip Ollama; use the best available cloud provider |
-d, --dry-run |
Show generated message without committing |
-f, --fill-placeholders |
Fill the cinfo placeholders for extra context |
-i, --interactive-add |
Interactive file staging with fzf (git adi) |
-m, --model |
Select a model interactively |
-p, --push |
Push after a successful commit |
--provider |
Force a provider: ollama / anthropic / gemini / openai |
-r, --review |
Review and approve message before commit [y/n/e/r] |
-v, --debug |
Verbose logging |
-w, --watermark |
Add a "Generated by ..." signature |
Flags combine, e.g. git aic -arp = stage all → review → commit → push.
Which provider?¶
- Ollama — free, private, offline; quality depends on your installed models and RAM.
- Anthropic / OpenAI — best quality when you have credits.
- Gemini — generous free tier, fast, good for high-volume use.
Installation¶
- Ensure Python is installed.
- Run
gitinit.cmdto set up theaic/aica/aicg/aico/aiclaliases. - Dependencies auto-install on first run via
dependency_manager.py— and only for the provider you actually use (an OpenAI-only user never installs the Anthropic SDK).
Dependencies (installed lazily, per provider)¶
- Ollama →
requests - Anthropic →
anthropic,httpx - Gemini →
requests - OpenAI →
openai,httpx
Troubleshooting¶
- Rate limit (429): wait, check the provider's usage dashboard, or add credits / upgrade.
- API key not set:
aicprints the exact env var to set and where to get the key. - Ollama not running / no models: start it with
ollama serveandollama pull llama3.2:3b. - Out of RAM with Ollama: lower
OLLAMA_NUM_CTX, or let the automatic small-model fallback handle it; raiseOLLAMA_TIMEOUTfor slow cold starts. - List models:
git aic --provider <name> -m.
License¶
Part of the power-user-scripts repository.
The tool¶
aic.py¶
git aic auto-detects; git aica / git aicg / git aico / git aicl are
thin aliases that pin Anthropic / Gemini / OpenAI / Ollama via --provider. The
provider classes (AnthropicProvider, GeminiProvider, OpenAIProvider,
OllamaProvider) all live inside this one module.
aic
¶
AI-powered Git commit message generator — one tool, many providers.
This single module replaces the old family of per-provider scripts (aica.py / aicg.py / aico.py / aicl.py). It generates a conventional-commit message from your staged changes using whichever AI provider you pick.
Providers (the "implementations" behind one shared framework): - Ollama (local) — no API key, runs at localhost:11434 (--provider ollama) - Anthropic Claude — ANTHROPIC_API_KEY (--provider anthropic) - Google Gemini — GOOGLE_API_KEY / GEMINI_API_KEY (--provider gemini) - OpenAI — OPENAI_API_KEY (--provider openai)
Usage
git aic # auto-detect: Ollama (local) > Anthropic > Gemini > OpenAI git aic --cloud # skip Ollama, use the best available cloud provider git aic --provider X # force a specific provider (X = ollama|anthropic|gemini|openai)
All commit flags work the same across every provider
FILES... stage these files first -a / --add-all stage all changes (git add .) -i / --interactive-add stage interactively via 'git adi' (fzf) -d / --dry-run print the message, do not commit -r / --review review before committing [y/n/e/r] -p / --push push after a successful commit -m / --model pick the model interactively -f / --fill-placeholders fill the 'cinfo' placeholders for extra context -w / --watermark append a "Generated by ..." signature -v / --debug verbose logging
Design: a Provider abstract base class declares the contract; each concrete
provider implements only its own API calls. The shared git framework
(staging, prompt building, the review/commit loop) lives here exactly once.
Third-party SDKs are imported lazily — only the chosen provider's packages are
installed/loaded, so an OpenAI-only user never pulls in the Anthropic SDK.
Companion utilities¶
chat.py¶
chat
¶
aipr.py¶
aipr
¶
dependency_manager.py¶
dependency_manager
¶
🛡️ Dependency Manager (Self-Healing Environment Engine)¶
A drop-in module to ensure Python scripts automatically install their own dependencies before execution. It uses a "Hierarchy of Trust" security model to prevent dependency confusion attacks.
Usage
import dependency_manager
Method 1: The Smart List (Recommended)¶
Automatically resolves pip names using the Internal Golden Map.¶
dependency_manager.require(["requests", "cv2", "yaml"])
Method 2: The Explicit Override (For private packages or version pinning)¶
dependency_manager.require({ "my_module": "my-private-package>=1.0.0", "legacy_lib": "legacy-pkg==2.4.1" })
Debug Mode
Run your main script with '--debug' to see verbose installation logs. e.g., python my_script.py --debug