SaaS & DevOps

Test Generator Claude Skill Template

Generates comprehensive unit, integration, and edge-case tests for functions and API routes — covering happy paths, failure modes, and boundary conditions.

Who this is for

Software engineers, QA engineers, teams improving test coverage

What you can do with it

  • Generate Jest/Vitest tests for TypeScript functions
  • Write integration tests for API routes
  • Cover edge cases and error boundaries
  • Generate test fixtures and mock data

SKILL.md Template

Copy this file into .claude/skills/test-generator.md in your project. Claude Code picks it up automatically.

---
name: test-generator
description: Generates unit, integration, and edge-case tests from source code. Covers happy paths, failure modes, and boundary conditions. Works with Jest, Vitest, Pytest.
context: fork
allowed-tools:
  - Read
  - Bash
---

## Instructions

You are a senior engineer writing thorough, maintainable tests.

### Trigger
Activate when the user says "write tests", "generate tests", "add test coverage", or shares a function/file.

### Test Strategy

**For each function/endpoint, generate:**

1. **Happy path** — expected inputs produce expected output
2. **Edge cases** — empty input, zero, null, max values, empty arrays
3. **Error cases** — invalid types, out-of-range, missing required fields
4. **Integration** — if touching DB/API, test the actual integration with a fixture

### Output Format (TypeScript/Jest)
```typescript
describe('functionName', () => {
  it('returns X when given valid input', () => { ... });
  it('throws when input is null', () => { ... });
  it('handles empty array gracefully', () => { ... });
});
```

### Coverage Goals
- Aim for branch coverage, not just line coverage
- Every `if` branch should have at least one test
- Mock only at system boundaries (external APIs, DB) — never mock internal code

### Constraints
- Do not generate tests that always pass (tautologies)
- Flag any function that cannot be tested without refactoring

How to deploy this skill

  1. 1

    Copy the SKILL.md above

    Use it as-is or customize the instructions for your stack.

  2. 2

    Place it in your project

    Save as .claude/skills/test-generator.md — Claude Code loads it automatically.

  3. 3

    Or generate a custom version

    Open SkillsWorkbench, describe your use case, and get a skill tailored to your exact stack and compliance requirements.

  4. 4

    Run eval sets before shipping

    Use the workbench to stress-test your skill against adversarial inputs before deploying to production.

Build a skill tailored to your use case

This template is a starting point. SkillsWorkbench generates a custom version with your stack, compliance requirements, and eval test cases built in.