TestGen is the test-generation layer for coding agents.

TestGen is the local test-generation engine for LLM coding agents. It helps agents inspect a repository, understand available capabilities, detect frameworks, estimate scope, generate reviewable patches, and validate tests without surprise writes.

The testgen binary is the local engine. The product experience is the repo-local agent skill, command, or MCP tool that calls the engine with safe defaults.

Installation

Install the local engine once, then install the agent skill into each repo where agents should generate tests.

1. Install the local engine

curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/install.sh | bash
irm https://raw.githubusercontent.com/princepal9120/testgen/main/install.ps1 | iex
go install github.com/princepal9120/testgen-cli@latest

2. Install the agent skill into your repo

curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash

Install one integration only:

# Codex
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent codex

# Claude Code
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent claude

# OpenCode
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent opencode

# Cursor, Cline, Continue, Roo Code, Gemini CLI
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent cursor
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent cline
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent continue
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent roo
curl -fsSL https://raw.githubusercontent.com/princepal9120/testgen/main/scripts/install-agent-skill.sh | bash -s -- --agent gemini

Quick Start

After installation, talk to your coding agent in plain language.

Generate tests for a folder

Use TestGen to analyze this repo and generate review-first unit tests for ./src.
Do not write files until you inspect the dry-run patch.

Generate tests for one file

Use TestGen to create unit tests for ./src/utils.py.
Start with a dry-run patch, then validate the generated test after review.

Large repo or budget-sensitive run

Use TestGen to estimate test generation cost for ./src first.
Then generate review-first patches folder by folder.

Provider Keys

Set one provider key before generation. Analyze and cost-estimate flows can run offline.

# Choose one provider
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."
export GEMINI_API_KEY="AIza..."
export GROQ_API_KEY="gsk_..."

Supported Agents

  • Codex: installs .codex/skills/testgen/SKILL.md
  • Claude Code: installs .claude/commands/testgen.md
  • OpenCode: installs .opencode/commands/testgen.md
  • Cursor: installs .cursor/rules/testgen.mdc
  • Cline: installs .clinerules/testgen.md
  • Continue: installs .continue/prompts/testgen.md
  • Roo Code: installs .roo/commands/testgen.md
  • Gemini CLI: installs GEMINI.md
  • MCP: use testgen mcp for tool-call based hosts

Review-first Workflow

Agents should avoid blind edits. The safe default is analyze, dry-run, inspect, then write and validate.

# 1. Agent checks repo readiness and available capabilities
testgen doctor --path=. --output-format json
testgen capabilities --output-format json

# 2. Agent analyzes scope and cost
testgen analyze --path=./src --cost-estimate --output-format json

# 3. Agent creates reviewable artifacts
testgen generate --path=./src --recursive --type=unit --dry-run --emit-patch --report-usage --output-format json

# 4. Agent writes only after review or explicit instruction
testgen generate --path=./src --recursive --type=unit --validate --output-format json

Doctor and Capabilities

Use these commands when an LLM tool needs to inspect the repo before generating tests.

testgen doctor --path=. --output-format=json
testgen capabilities --output-format=json

Integration Files

All wrappers are thin. They tell agents how to call the local engine safely.

Schemas and Profiles

JSON schemas give wrappers and MCP hosts stable output contracts. Provider profiles document outcome-based model choices.

docs/schemas/
docs/PROFILES.md
docs/profiles/defaults.yaml

Adapter SDK

Contributors can add language support by implementing the adapter interface, parser strategy, fixture expectations, framework detection, prompt templates, and validation command behavior.

Supported Languages

TestGen currently supports JavaScript/TypeScript, Python, Go, Rust, Java, C#, PHP, Ruby, C++, and Kotlin.