git commit, GGA intercepts the commit via a Git pre-commit hook, sends your staged files to an AI provider for review, and either allows or blocks the commit based on the AI’s response.
Step-by-step flow
Load config from .gga
GGA loads configuration in this order, with each level overriding the previous:
- Global config —
~/.config/gga/config(or%APPDATA%\gga\configon Windows) - Project config —
.ggain the current directory - Environment variables —
GGA_PROVIDER,GGA_TIMEOUT
| Setting | Default | Description |
|---|---|---|
PROVIDER | (required) | Which AI to use |
FILE_PATTERNS | * | Which files to include |
EXCLUDE_PATTERNS | (none) | Which files to skip |
RULES_FILE | AGENTS.md | Path to your coding standards |
STRICT_MODE | true | How to handle ambiguous AI responses |
TIMEOUT | 300 | Seconds to wait for the AI |
Validate provider is installed
GGA checks that the configured provider CLI is available on your
PATH. If it is not found, GGA exits with an error before doing any other work.For example, if PROVIDER="claude" is set but the claude CLI is not installed, you will see:Check AGENTS.md exists
GGA verifies that the file referenced by
RULES_FILE (default: AGENTS.md) exists in the project. If it does not, the review is blocked with instructions:Get staged files
GGA calls
git diff --cached --name-only --diff-filter=ACM to get the list of added, copied, and modified files in the staging area.This list is then filtered:- Include: only files matching
FILE_PATTERNS(comma-separated glob patterns, e.g.*.ts,*.tsx) - Exclude: files matching
EXCLUDE_PATTERNS(e.g.*.test.ts,*.spec.ts,*.d.ts)
*-prefixed patterns (e.g., *.tsx matches any file ending in .tsx) and exact-match for all others.In CI mode (--ci), GGA uses git diff --name-only HEAD~1..HEAD instead of reading the staging area — reviewing the files changed in the last commit rather than staged files.In PR mode (--pr-mode), GGA detects the base branch and reviews all files changed across the full PR range.Filter out cached files
If caching is enabled (the default), GGA skips any file that:
- Has not changed since it last passed review
- Was reviewed under the same
AGENTS.mdand.ggaconfig
AGENTS.md or .gga changes — ensuring that new rules are applied to previously-cached files.Files that pass the current review are added to the cache. Files that fail are not cached.Use gga run --no-cache to force a full review, ignoring all cached results.Build the prompt
GGA constructs a prompt that includes:If the commit-msg hook variant is installed, the commit message is also included in the prompt between the coding standards and the files.
- The full contents of your
AGENTS.mdas the coding standards - The full contents of each staged file (read from the Git staging area with
git show :file, not from the working directory — so what is reviewed is exactly what will be committed) - Instructions to the AI on what format to respond in
Send to AI provider
GGA pipes the prompt to your configured provider’s CLI and waits for a response, up to
TIMEOUT seconds (default: 300).A progress indicator is shown while waiting. If the provider does not respond within the timeout:- In STRICT_MODE=true (default): the commit is blocked
- In STRICT_MODE=false: the commit is allowed through with a warning
Parse the response
GGA scans the first 15 lines of the AI’s response for a status line. It accepts both plain and markdown-formatted variants:
STATUS: PASSEDSTATUS: FAILED**STATUS: PASSED****STATUS: FAILED**
STATUS: PASSED — cached files are written to the cache and the commit proceeds.If STATUS: FAILED — the full AI response (including violation details) is printed and the commit is blocked with exit code 1. Git will not create the commit.If neither is found — this is an ambiguous response. STRICT_MODE controls the outcome (see below).STRICT_MODE behavior
STRICT_MODE controls what happens when the AI response does not contain STATUS: PASSED or STATUS: FAILED in the first 15 lines.
| STRICT_MODE | Outcome |
|---|---|
true (default) | Commit is blocked. GGA exits with an error. |
false | Commit is allowed. GGA exits with a warning. |
STRICT_MODE=true:
STRICT_MODE=false:
Ambiguous responses are rare with well-known providers but can occur with local models that don’t reliably follow output formatting instructions. If you see frequent ambiguous responses, try a more capable model or refine your
AGENTS.md to be more explicit.The commit-msg hook variant
gga install --commit-msg installs GGA as a commit-msg hook instead of a pre-commit hook. In this mode:
- The Git commit message file is passed to
gga runas an argument - The commit message is included in the AI prompt alongside the staged file contents
- The AI can validate both code quality and commit message quality in one pass
Caching internals
The cache is stored per-project in a directory derived from the repo’s root path. Each cached file is recorded by its content hash. The cache also stores a hash ofAGENTS.md and .gga — if either changes, all cached entries are invalidated automatically.
Cache commands: