sequenzia/agent-alchemy/generate-tests
Claude Code and agent skill by sequenzia/agent-alchemy
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Generate test files from acceptance criteria or existing code. Supports criteria-driven mode (from specs/tasks) and code-analysis mode (from source files). Auto-detects test framework and spawns test-writer agents for parallel generation.
Install
npx vskill@latest install sequenzia/agent-alchemy/generate-testsSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as sequenzia/agent-alchemy/generate-tests.
Generate Tests Skill
Generate high-quality, behavior-driven test files from acceptance criteria or existing source code. This skill auto-detects the project's test framework, loads framework-specific patterns, and spawns test-writer agents to produce runnable test files that follow project conventions.
CRITICAL: Complete ALL 6 phases. The workflow is not complete until Phase 6: Report is finished. After completing each phase, immediately proceed to the next phase without waiting for user prompts.
Core Principles
- Tests before implementation -- Generated tests should initially fail (RED state) when no implementation exists, confirming they test real behavior.
- Behavior over implementation -- Test what the code does, not how it does it. Tests should survive refactoring.
- Follow project conventions -- Match the project's existing test framework, file naming, directory structure, and assertion patterns.
- Standalone operation -- This skill works independently. It does not require the SDD pipeline,
tdd-cycle, or any other skill to function.
AskUserQuestion is MANDATORY
IMPORTANT: You MUST use the AskUserQuestion tool for ALL questions to the user. Never ask questions through regular text output.
- Framework selection questions -> AskUserQuestion
- Clarifying questions about scope -> AskUserQuestion
- Confirmation questions -> AskUserQuestion
Text output should only be used for presenting information, summaries, and progress updates.
Phase 1: Parse Input
Goal: Determine the operating mode and resolve input paths.
Analyze the $ARGUMENTS to determine which mode to use:
Mode Detection
Criteria-Driven Mode -- triggered when input is:
- A spec file path (e.g.,
specs/SPEC-feature.md) - A task ID (e.g.,
5,#5,task-5) - A spec section reference (e.g.,
specs/SPEC-feature.md Section 5.1)
Code-Analysis Mode -- triggered when input is:
- A source file path (e.g.,
src/utils.py,src/services/auth.ts) - A directory path (e.g.,
src/services/)
Ambiguous input: If the input could be either mode (e.g., a path that could be a spec or source file), check the file content. If it contains **Acceptance Criteria:** or is a markdown file in a specs/ directory, use criteria-driven mode. Otherwise, use code-analysis mode.
Path Resolution
- Resolve relative paths against the project root
- For task IDs: use
TaskGetto retrieve the task description, then extract acceptance criteria - For spec section references: read the spec file and locate the referenced section
- For directories: glob for source files (exclude test files, node_modules, __pycache__, .git)
- Validate that all resolved paths exist; if not, proceed to error handling (Phase 1 error cases below)
Error Cases
Invalid spec path:
Invalid task ID:
Empty directory:
Phase 2: Detect Framework
Goal: Auto-detect the project's test framework using the detection chain.
Load Detection Chain
Read the framework detection reference for the full detection algorithm:
Follow the detection chain in priority order:
Step 1: Config-File Detection (High Confidence)
Check for framework configuration files:
Python:
pyproject.tomlwith[tool.pytest.ini_options]or[tool.pytest]-> pytestsetup.cfgwith[tool:pytest]-> pytestpytest.iniexists -> pytestconftest.pyat project root or intests/-> pytest
TypeScript/JavaScript:
vitest.config.*exists -> Vitest (takes priority)jest.config.*exists -> Jestpackage.jsonwithvitestin dependencies/devDependencies -> Vitestpackage.jsonwithjestin dependencies/devDependencies -> Jestpackage.jsonwith"jest": {}config section -> Jest
Step 2: Existing Test File Detection (Medium Confidence)
If no config files found, scan for existing test files:
test_*.pyor*_test.py-> pytest*.test.ts/*.spec.tswithvitestimports -> Vitest*.test.ts/*.spec.tswithjestimports or no explicit imports -> Jest
Step 3: Settings Fallback (Low Confidence)
If detection is still ambiguous, check .claude/agent-alchemy.local.md for:
If tdd.framework is set to a recognized value (pytest, jest, vitest), use it. If set to auto or an unrecognized value, continue to Step 4.
Step 4: User Prompt Fallback
If all detection methods fail, prompt the user:
Detection Result
After detection, record:
- Framework: pytest | Jest | Vitest
- Test directory: Path to test root (e.g.,
tests/,__tests__/,src/) - Naming pattern: File naming convention (e.g.,
test_*.py,*.test.ts) - Assertion library: Default or extended (e.g.,
@testing-library/jest-dom) - Existing fixtures: Notable fixtures or test utilities found
- Confidence: High | Medium | Low
Monorepo Handling
In monorepos, detect framework per-directory by walking up from the target source file to find the nearest config file. Different directories may use different frameworks.
Phase 3: Load References
Goal: Load framework-specific patterns and project conventions.
Load Test Patterns
Read the test patterns reference for framework-specific guidance:
This provides:
- Arrange-Act-Assert and Given-When-Then patterns
- Behavior-driven vs implementation-detail test guidance
- Framework-specific naming conventions
- Anti-patterns to avoid
Load Framework Templates
Read the framework templates reference for boilerplate structure:
This provides:
- Boilerplate templates for pytest, Jest, and Vitest
- Configuration reference for each framework
- Fixture and test utility patterns
Load Cross-Plugin Skills
Load language-specific patterns and project conventions for the target project:
Apply these skills' guidance when generating tests to ensure:
- Language idioms are followed (TypeScript strict typing, Python type hints)
- Project naming conventions are matched
- Import patterns are consistent with the codebase
Scan Existing Tests
If the project has existing test files:
- Read 2-3 representative test files to understand the project's test style
- Note patterns: fixture usage, test grouping, assertion style, mock patterns
- Match these patterns in generated tests for consistency
Phase 4: Generate Tests
Goal: Produce test files by spawning test-writer agents.
Criteria-Driven Mode
When operating from acceptance criteria (spec, task, or section reference):
- Extract criteria: Parse the acceptance criteria into categories:
- Functional: Core behavior assertions (highest priority)
- Edge Cases: Boundary conditions and unusual inputs
- Error Handling: Error paths and error messages
- Performance: Efficiency-related assertions (if applicable)
- Plan test files: Determine how many test files to create:
- One feature/module = one test file
- Multiple features = one test file per feature
- Group related criteria into describe blocks or test classes
- Map criteria to test cases: For each criterion, create one or more test cases:
- Each criterion gets at least one test
- Complex criteria may need multiple tests (happy path + variations)
- Edge cases get individual tests
- Error handling criteria get tests verifying error types and messages
- Determine test file paths: Follow the project's convention:
- Match existing test directory structure
- Use the detected naming pattern
- Place tests adjacent to source files if the project uses colocated tests, or in the test directory if centralized
Code-Analysis Mode
When operating from source files:
- Analyze source files: For each source file, identify:
- Public functions and methods (skip private/internal)
- Function signatures: parameters, return types, side effects
- Class structures: constructors, public methods, properties
- Module exports: what is available to consumers
- Generate characterization tests: Create tests that verify current behavior:
- Test each public function with representative inputs
- Test return values and observable side effects
- Test error conditions visible from the signature (e.g., nullable params)
- Identify untested edge cases: Look for:
- Boundary conditions (empty inputs, null values, max values)
- Error paths (invalid types, missing required fields)
- State transitions (before/after operations)
- Preserve existing tests: Before writing, check for existing test files:
- If a test file already exists for the source file, do NOT overwrite it
- Instead, generate a supplementary test file with a
_additionalor_generatedsuffix - Report which files were skipped and why
Spawning Test-Writer Agents
Single feature/file: Use a single test-writer agent:
Multiple features/files: Spawn test-writer agents in parallel:
Wait for all agents to complete before proceeding to Phase 5.
Agent Failure Handling
If a test-writer agent fails:
- Log which feature/file failed
- Continue with successful results
- Report the failure in Phase 6 with recommendations
Phase 5: Validate
Goal: Verify generated tests are syntactically valid and follow conventions.
Syntax Validation
For each generated test file, run a syntax check:
pytest:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingclaude/tdd-tools/skills/generate-tests/SKILL.md
Popularity
- Repository stars
- 42
- Repository forks
- 7
- 7-day trend score
- 19
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sequenzia/agent-alchemy/generate-tests)