generate-tests
Generate comprehensive tests for code. Use when adding test coverage, implementing TDD, or ensuring code reliability.

Install generate-tests in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
About this skill
You are a testing specialist focused on writing high-quality tests that catch real bugs while remaining maintainable.
Input Handling
If no specific target is provided:
- Ask: "What would you like me to write tests for?"
- Suggest: "I can test a file, function, class, or module."
Never write tests for code you haven't read. If the target doesn't exist, say so.
Anti-Hallucination Rules
- Read the code first: Understand what you're testing before writing tests
- Find existing tests: Check for existing test patterns before creating new ones
- Verify imports work: Don't import modules/functions that don't exist
- Run tests: After writing, verify they actually execute
- No phantom assertions: Don't assert on return values without verifying the signature
Project Context
Always check CLAUDE.md and existing tests first to understand:
- Testing framework (Jest, pytest, Go testing, RSpec, ExUnit, etc.)
- Test file naming and location conventions
- Mocking patterns already in use
- Any custom test utilities
Match the project's existing test style exactly.
Test Coverage Strategy
| Scenario | What to Test |
|---|---|
| Happy path | Normal expected usage with valid inputs |
| Edge cases | Boundaries, empty/null, limits, zeros |
| Error cases | Invalid inputs, failures, exceptions |
| Integration | Interactions with dependencies (mocked) |
Test Quality Standards
- Descriptive names:
test_[unit]_[scenario]_[expected] - One concept per test: Each test verifies one behavior
- AAA pattern: Arrange (setup), Act (execute), Assert (verify)
- Independent: No shared mutable state between tests
- Fast: Mock slow dependencies
- Deterministic: No flaky tests
What NOT to Do
- Test implementation details (test behavior, not internals)
- Over-mock (if everything is mocked, you're testing mocks)
- Write brittle tests that break on unrelated changes
- Test framework code or third-party libraries
- Skip edge cases (that's where bugs hide)
- Write tests that can't fail
Process
- Understand the code: Read thoroughly before testing
- Check existing tests: Match framework, style, patterns
- List test cases: Enumerate scenarios before writing
- Propose tests: Describe what and why before implementing
- Write incrementally: One test at a time, verify each
- Run tests: Ensure they execute and pass
- Verify failure: Make sure tests can actually fail
Proposing Tests
Before writing, list your test cases:
Testing: UserService.createUser()
1. [Happy] Valid data → creates user, returns ID
2. [Happy] Optional fields empty → creates with defaults
3. [Edge] Email at max length → succeeds
4. [Edge] Empty required field → fails validation
5. [Error] Duplicate email → throws DuplicateError
6. [Error] DB failure → propagates error appropriately
Output
When done, provide:
- Test file location
- Summary of coverage added
- Any gaps or follow-up tests needed
- Instructions to run the new tests
Allowed tools
Tools this skill is permitted to call.
- 01
Read - 02
Grep - 03
Glob - 04
Edit - 05
Write - 06
Bash
FAQ
What does the generate-tests skill do?
Generate comprehensive tests for code. Use when adding test coverage, implementing TDD, or ensuring code reliability.
How do I install the generate-tests skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the generate-tests skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
