DocsCLI Reference
CLI Reference
All commands, flags, and exit codes for the testgap CLI.
testgap analyze#
The primary command. Scans your codebase, detects untested functions, and optionally runs AI analysis.
testgap analyze [PATH] [OPTIONS]Arguments
| Option | Type | Default | Description |
|---|---|---|---|
| PATH | path | . | Project directory to analyze |
Options
| Option | Type | Default | Description |
|---|---|---|---|
| --no-ai | flag | — | Skip AI analysis. No API key needed. Fast static analysis only. |
| --format | string | human | Output format: human, json, or markdown |
| --fail-on-critical | flag | — | Exit with code 1 if any critical gaps are found. For CI gates. |
| --languages | string | — | Comma-separated list of languages to analyze (e.g. rust,typescript) |
| --min-severity | string | info | Minimum severity to report: critical, warning, or info |
| --ai-severity | string | critical | Only send gaps at this severity or above to AI. Controls API cost. |
| --verbose | flag | — | Enable verbose logging output |
Examples
# Basic analysis (no AI)
testgap analyze --no-ai
# Analyze specific directory
testgap analyze ./my-project
# JSON output for CI
testgap analyze --format json --fail-on-critical --no-ai
# Only Rust and TypeScript
testgap analyze --languages rust,typescript
# Only show critical gaps
testgap analyze --min-severity critical
# AI on critical gaps only (saves cost)
testgap analyze --ai-severity critical
# Pipe to jq for custom filtering
testgap analyze --format json | jq '.gaps[] | select(.severity == "critical")'testgap init#
Creates a .testgap.toml configuration file in the current directory with sensible defaults.
testgap initNon-destructive
If a
.testgap.toml already exists, init will not overwrite it.Exit Codes#
| Code | Meaning | When |
|---|---|---|
| 0 | Success | No critical gaps found (or --fail-on-critical not set) |
| 1 | Critical gaps | Critical gaps found and --fail-on-critical was set |
| 2 | Runtime error | Unexpected error (parse failure, I/O error, etc.) |
Environment Variables#
| Option | Type | Default | Description |
|---|---|---|---|
| ANTHROPIC_API_KEY | string | — | Required for AI analysis. Use --no-ai to skip. Get yours at console.anthropic.com. |