Skip to main content

CLI Reference

Usage

testpilot [options] <target>

The target can be a single file or a directory. When pointing at a directory, testpilot generates tests for all .ts, .tsx, .js, .jsx files (excluding existing test/spec files).

Options

FlagDescriptionDefault
-p, --provider <provider>LLM provider: openai, anthropic, google, ollamaopenai
-m, --model <model>Model to use (e.g. gpt-4o, claude-sonnet-4-20250514)Provider default
-k, --api-key <key>API key (or use environment variable)
-f, --framework <framework>Test framework: vitest or jestAuto-detected
-o, --out-dir <dir>Output directory for test filesSame as source
--overwriteOverwrite existing test filesfalse
--no-edge-casesSkip edge case testsEdge cases enabled
--no-error-handlingSkip error handling testsError handling enabled
--instructions <text>Additional instructions for the LLM
--max-tokens <n>Max tokens for LLM response4096
--temperature <n>Temperature for LLM0.2
--dry-runGenerate tests without writing filesfalse
-s, --streamStream LLM output in real-timetrue
-V, --versionOutput the version number
-h, --helpDisplay help

Examples

# Generate tests for a single file
npx testpilot src/utils.ts

# Use Anthropic with Claude
npx testpilot src/utils.ts --provider anthropic --model claude-sonnet-4-20250514

# Generate Jest tests
npx testpilot src/utils.ts --framework jest

# Process an entire directory
npx testpilot src/helpers/

# Dry run — preview without writing
npx testpilot src/utils.ts --dry-run

# Use local Ollama models
npx testpilot src/utils.ts --provider ollama --model llama3

# Overwrite existing test files
npx testpilot src/utils.ts --overwrite

# Custom instructions
npx testpilot src/utils.ts --instructions "Test with French locale strings"

# Redirect output to a specific directory
npx testpilot src/utils.ts --out-dir tests/

Output

testpilot-ai displays:

  1. Header — provider, model, framework, file count
  2. Progress — streaming LLM output per file
  3. File summary — test file path, test count, categories, duration
  4. Final summary — total tests, files, tokens, time