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
| Flag | Description | Default |
|---|---|---|
-p, --provider <provider> | LLM provider: openai, anthropic, google, ollama | openai |
-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 jest | Auto-detected |
-o, --out-dir <dir> | Output directory for test files | Same as source |
--overwrite | Overwrite existing test files | false |
--no-edge-cases | Skip edge case tests | Edge cases enabled |
--no-error-handling | Skip error handling tests | Error handling enabled |
--instructions <text> | Additional instructions for the LLM | — |
--max-tokens <n> | Max tokens for LLM response | 4096 |
--temperature <n> | Temperature for LLM | 0.2 |
--dry-run | Generate tests without writing files | false |
-s, --stream | Stream LLM output in real-time | true |
-V, --version | Output the version number | — |
-h, --help | Display 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:
- Header — provider, model, framework, file count
- Progress — streaming LLM output per file
- File summary — test file path, test count, categories, duration
- Final summary — total tests, files, tokens, time