/test-gen
Intelligent test suite generator with framework detection, programmatic structure analysis, and comprehensive test creation
How it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/test-gen
Context preview
What this command does when you run it.
Intelligent test suite generator with framework detection, programmatic structure analysis, and comprehensive test creation
Command definition
test-gen.mdallowed-tools: Task, Read, Write, Edit, MultiEdit, Bash(fd:*), Bash(rg:*), Bash(jq:*), Bash(bat:*), Bash(eza:*), Bash(gdate:*), Bash(wc:*), Bash(head:*), Bash(mvn:*), Bash(gradle:*), Bash(cargo:*), Bash(go:*), Bash(deno:*), Bash(npm:*)
name: "Test Gen"
description: "Intelligent test suite generator with framework detection, programmatic structure analysis, and comprehensive test creation"
author: "wcygan"
tags: ["test","generate"]
version: "1.0.0"
created_at: "2025-07-14T00:00:00Z"
updated_at: "2025-07-14T00:00:00Z"
Context
- Session ID: !`gdate +%s%N 2>/dev/null || date +%s%N 2>/dev/null || echo "$(date +%s)$(jot -r 1 100000 999999 2>/dev/null || shuf -i 100000-999999 -n 1 2>/dev/null || echo $RANDOM$RANDOM)"`
- Target: $ARGUMENTS
- Current directory: !`pwd`
- Project structure: !`eza -la --tree --level=2 2>/dev/null | head -10 || fd . -t d -d 2 | head -8`
- Existing tests: !`fd "(test|spec)\.(js|ts|jsx|tsx|rs|go|java|py)$" . | wc -l | tr -d ' '` files
- Build files: !`fd "(package\.json|Cargo\.toml|go\.mod|deno\.json|pom\.xml|build\.gradle)" . -d 3 | head -5 || echo "No build files detected"`
- Testing frameworks: !`fd "package.json" . | xargs jq -r '.devDependencies // {} | keys[]' 2>/dev/null | rg "(jest|vitest|mocha|ava|playwright|cypress)" | head -3 || echo "No JS test frameworks"`
- Modern tools status: !`echo "fd: $(which fd >/dev/null && echo ✓ || echo ✗) | rg: $(which rg >/dev/null && echo ✓ || echo ✗) | jq: $(which jq >/dev/null && echo ✓ || echo ✗)"`
Your Task
STEP 1: Initialize intelligent test generation session with comprehensive project analysis
- CREATE session state file: `/tmp/test-gen-session-$SESSION_ID.json`
- ANALYZE project structure and technology stack from Context section
- DETECT primary programming language and testing frameworks
- IDENTIFY existing test patterns and coverage gaps
# Initialize test generation session state
echo '{
"sessionId": "'$SESSION_ID'",
"target": "'$ARGUMENTS'",
"detectedLanguages": [],
"testingFrameworks": [],
"existingTestCount": 0,
"generatedTests": []
}' > /tmp/test-gen-session-$SESSION_ID.jsonSTEP 2: Multi-language framework detection with intelligent routing
**JavaScript/TypeScript Projects:**
# Detect testing framework from package.json
fd "package.json" . | xargs jq -r '.devDependencies // {} | keys[]' 2>/dev/null | rg "(jest|vitest|mocha|ava)"
# Deno projects
fd "deno.json" . | xargs jq -r '.tasks // {} | keys[]' 2>/dev/null | rg "test"
# Test file patterns
fd "(test|spec)\.(js|ts|jsx|tsx)$" . --max-depth 2**Rust Projects:**
# Cargo.toml analysis
fd "Cargo.toml" . | xargs rg "\[dev-dependencies\]" -A 10 2>/dev/null || echo "No Cargo.toml found"
fd "(lib|main)\.rs$" . | xargs rg "#\[cfg\(test\)\]" 2>/dev/null || echo "No Rust test modules found"
**Go Projects:**
# Test file detection
fd "_test\.go$" . 2>/dev/null || echo "No Go test files found"
go list ./... 2>/dev/null | rg "test" || echo "Go modules not available"
**Python Projects:**
# Testing framework detection
fd "(requirements|pyproject)\.(txt|toml)" . | xargs rg "(pytest|unittest|nose)" 2>/dev/null || echo "No Python test frameworks detected"
fd "test_.*\.py$|.*_test\.py$" . 2>/dev/null || echo "No Python test files found"
**Java Projects:**
# Maven/Gradle test detection
fd "pom\.xml$" . | xargs rg "(junit|testng|mockito)" 2>/dev/null || echo "No Maven test dependencies"
fd "build\.gradle$" . | xargs rg "(junit|testng|spock)" 2>/dev/null || echo "No Gradle test dependencies"
fd ".*Test\.java$" . 2>/dev/null || echo "No Java test files found"
STEP 3: Parallel test analysis and generation with sub-agent coordination
TRY:
IF project_complexity == "multi-language" OR codebase_size > 50_files:
LAUNCH parallel sub-agents for comprehensive test generation:
- **Agent 1: Unit Test Analysis**: Analyze existing unit tests and identify gaps
- Focus: Function coverage, edge cases, error handling patterns
- Tools: rg for test pattern analysis, code complexity assessment
- Output: Unit test coverage report and generation targets
- **Agent 2: Integration Test Strategy**: Design integration test architecture
- Focus: API endpoints, database interactions, service boundaries
- Tools: fd for endpoint discovery, dependency mapping
- Output: Integration test plan and mock requirements
- **Agent 3: E2E Test Planning**: Analyze user flows and critical paths
- Focus: Frontend interactions, user journeys, business workflows
- Tools: Component analysis, routing discovery
- Output: E2E test scenarios and automation strategy
- **Agent 4: Test Data Management**: Design test data generation and management
- Focus: Realistic test data, factories, fixtures, mocks
- Tools: Schema analysis, data model discovery
- Output: Test data strategy and generation utilities
ELSE:
EXECUTE streamlined single-agent test generation:
Test Generation Strategies
STEP 4: Language-specific test generation with programmatic structure analysis
**Analysis Phase with Dynamic Language Detection:**
# Extract function signatures and interfaces based on detected project type
PROJECT_LANG=$(fd "(package\.json|Cargo\.toml|go\.mod|pom\.xml)" . | head -1 | sed 's/.*\.//' || echo "unknown")
case $PROJECT_LANG in
"json")
echo "📦 JavaScript/TypeScript project detected"
# Parse TypeScript/JavaScript for functions and classes
rg "^(export\s+)?(function|class|const|let)\s+\w+" --type-add 'web:*.{js,ts,jsx,tsx}' --type web -A 3 2>/dev/null || echo "No JS/TS functions found"
;;
"toml")
echo "🦀 Rust project detected"
# Extract public functions and structs
rg "^pub\s+(fn|struct|enum|trait)" --type rust -A 2 2>/dev/null || echo "No public Rust items found"
;;
"mod")
echo "🐹 Go project detected"
# Extract public functions and types
rg "^func\s+[A-Z]\w*|^type\s+[A-Z]\w*" --type go -A 2 2>/dev/null || echo "No public Go items fouRead more
allowed-tools: Task, Read, Write, Edit, MultiEdit, Bash(fd:*), Bash(rg:*), Bash(jq:*), Bash(bat:*), Bash(eza:*), Bash(gdate:*), Bash(wc:*), Bash(head:*), Bash(mvn:*), Bash(gradle:*), Bash(cargo:*), Bash(go:*), Bash(deno:*), Bash(npm:*) name: "Test Gen" description: "Intelligent test suite generator with framework detection, programmatic structure analysis, and comprehensive test creation" author: "wcygan" tags: ["test","generate"] version: "1.0.0" created_at: "2025-07-14T00:00:00Z" updated_at: "2025-07-14T00:00:00Z"
Context
- Session ID: !`gdate +%s%N 2>/dev/null || date +%s%N 2>/dev/null || echo "$(date +%s)$(jot -r 1 100000 999999 2>/dev/null || shuf -i 100000-999999 -n 1 2>/dev/null || echo $RANDOM$RANDOM)"`
- Target: $ARGUMENTS
- Current directory: !`pwd`
- Project structure: !`eza -la --tree --level=2 2>/dev/null | head -10 || fd . -t d -d 2 | head -8`
- Existing tests: !`fd "(test|spec)\.(js|ts|jsx|tsx|rs|go|java|py)$" . | wc -l | tr -d ' '` files
- Build files: !`fd "(package\.json|Cargo\.toml|go\.mod|deno\.json|pom\.xml|build\.gradle)" . -d 3 | head -5 || echo "No build files detected"`
- Testing frameworks: !`fd "package.json" . | xargs jq -r '.devDependencies // {} | keys[]' 2>/dev/null | rg "(jest|vitest|mocha|ava|playwright|cypress)" | head -3 || echo "No JS test frameworks"`
- Modern tools status: !`echo "fd: $(which fd >/dev/null && echo ✓ || echo ✗) | rg: $(which rg >/dev/null && echo ✓ || echo ✗) | jq: $(which jq >/dev/null && echo ✓ || echo ✗)"`
Your Task
STEP 1: Initialize intelligent test generation session with comprehensive project analysis
- CREATE session state file: `/tmp/test-gen-session-$SESSION_ID.json`
- ANALYZE project structure and technology stack from Context section
- DETECT primary programming language and testing frameworks
- IDENTIFY existing test patterns and coverage gaps
# Initialize test generation session state
echo '{
"sessionId": "'$SESSION_ID'",
"target": "'$ARGUMENTS'",
"detectedLanguages": [],
"testingFrameworks": [],
"existingTestCount": 0,
"generatedTests": []
}' > /tmp/test-gen-session-$SESSION_ID.jsonSTEP 2: Multi-language framework detection with intelligent routing
**JavaScript/TypeScript Projects:**
# Detect testing framework from package.json
fd "package.json" . | xargs jq -r '.devDependencies // {} | keys[]' 2>/dev/null | rg "(jest|vitest|mocha|ava)"
# Deno projects
fd "deno.json" . | xargs jq -r '.tasks // {} | keys[]' 2>/dev/null | rg "test"
# Test file patterns
fd "(test|spec)\.(js|ts|jsx|tsx)$" . --max-depth 2**Rust Projects:**
# Cargo.toml analysis fd "Cargo.toml" . | xargs rg "\[dev-dependencies\]" -A 10 2>/dev/null || echo "No Cargo.toml found" fd "(lib|main)\.rs$" . | xargs rg "#\[cfg\(test\)\]" 2>/dev/null || echo "No Rust test modules found"
**Go Projects:**
# Test file detection fd "_test\.go$" . 2>/dev/null || echo "No Go test files found" go list ./... 2>/dev/null | rg "test" || echo "Go modules not available"
**Python Projects:**
# Testing framework detection fd "(requirements|pyproject)\.(txt|toml)" . | xargs rg "(pytest|unittest|nose)" 2>/dev/null || echo "No Python test frameworks detected" fd "test_.*\.py$|.*_test\.py$" . 2>/dev/null || echo "No Python test files found"
**Java Projects:**
# Maven/Gradle test detection fd "pom\.xml$" . | xargs rg "(junit|testng|mockito)" 2>/dev/null || echo "No Maven test dependencies" fd "build\.gradle$" . | xargs rg "(junit|testng|spock)" 2>/dev/null || echo "No Gradle test dependencies" fd ".*Test\.java$" . 2>/dev/null || echo "No Java test files found"
STEP 3: Parallel test analysis and generation with sub-agent coordination
TRY:
IF project_complexity == "multi-language" OR codebase_size > 50_files:
LAUNCH parallel sub-agents for comprehensive test generation:
- **Agent 1: Unit Test Analysis**: Analyze existing unit tests and identify gaps
- Focus: Function coverage, edge cases, error handling patterns
- Tools: rg for test pattern analysis, code complexity assessment
- Output: Unit test coverage report and generation targets
- **Agent 2: Integration Test Strategy**: Design integration test architecture
- Focus: API endpoints, database interactions, service boundaries
- Tools: fd for endpoint discovery, dependency mapping
- Output: Integration test plan and mock requirements
- **Agent 3: E2E Test Planning**: Analyze user flows and critical paths
- Focus: Frontend interactions, user journeys, business workflows
- Tools: Component analysis, routing discovery
- Output: E2E test scenarios and automation strategy
- **Agent 4: Test Data Management**: Design test data generation and management
- Focus: Realistic test data, factories, fixtures, mocks
- Tools: Schema analysis, data model discovery
- Output: Test data strategy and generation utilities
ELSE:
EXECUTE streamlined single-agent test generation:
Test Generation Strategies
STEP 4: Language-specific test generation with programmatic structure analysis
**Analysis Phase with Dynamic Language Detection:**
# Extract function signatures and interfaces based on detected project type
PROJECT_LANG=$(fd "(package\.json|Cargo\.toml|go\.mod|pom\.xml)" . | head -1 | sed 's/.*\.//' || echo "unknown")
case $PROJECT_LANG in
"json")
echo "📦 JavaScript/TypeScript project detected"
# Parse TypeScript/JavaScript for functions and classes
rg "^(export\s+)?(function|class|const|let)\s+\w+" --type-add 'web:*.{js,ts,jsx,tsx}' --type web -A 3 2>/dev/null || echo "No JS/TS functions found"
;;
"toml")
echo "🦀 Rust project detected"
# Extract public functions and structs
rg "^pub\s+(fn|struct|enum|trait)" --type rust -A 2 2>/dev/null || echo "No public Rust items found"
;;
"mod")
echo "🐹 Go project detected"
# Extract public functions and types
rg "^func\s+[A-Z]\w*|^type\s+[A-Z]\w*" --type go -A 2 2>/dev/null || echo "No public Go items fouA lightweight (~46kB) and comprehensive CLI tool for managing Claude commands, configurations, and workflows.
Repo: kiliczsh/claude-cmd
Other commands on claude-cmd.
- /agent-browser-automation
Automate browser interactions for development testing using Puppeteer MCP
Open command - /agent-prep-merge
Prepare branches for merging across multiple worktrees and coordinate integration
Open command - /agent-persona-accessibility-expert
Transform into accessibility expert for WCAG compliance and inclusive design
Open command - /agent-persona-api-designer
Transform into an API design specialist who creates well-structured, developer-friendly APIs
Open command - /agent-persona-backend-specialist
Transform into backend specialist for scalable API and system design
Open command - /agent-persona-cloud-architect
Cloud architect persona for designing scalable, secure cloud infrastructure using modern cloud-native technologies
Open command

