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.

usage
testgap analyze [PATH] [OPTIONS]

Arguments

OptionTypeDefaultDescription
PATHpath.Project directory to analyze

Options

OptionTypeDefaultDescription
--no-aiflagSkip AI analysis. No API key needed. Fast static analysis only.
--formatstringhumanOutput format: human, json, or markdown
--fail-on-criticalflagExit with code 1 if any critical gaps are found. For CI gates.
--languagesstringComma-separated list of languages to analyze (e.g. rust,typescript)
--min-severitystringinfoMinimum severity to report: critical, warning, or info
--ai-severitystringcriticalOnly send gaps at this severity or above to AI. Controls API cost.
--verboseflagEnable verbose logging output

Examples

examples.sh
# 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.

usage
testgap init

Non-destructive

If a .testgap.toml already exists, init will not overwrite it.

Exit Codes#

CodeMeaningWhen
0SuccessNo critical gaps found (or --fail-on-critical not set)
1Critical gapsCritical gaps found and --fail-on-critical was set
2Runtime errorUnexpected error (parse failure, I/O error, etc.)

Environment Variables#

OptionTypeDefaultDescription
ANTHROPIC_API_KEYstringRequired for AI analysis. Use --no-ai to skip. Get yours at console.anthropic.com.