Skip to main content
skill CX Codex

qe-test-generation — Claude Code skill for test generation

qe-test-generation generates tests for new or changed code, with emphasis on contracts, invariants, and property checks. Use it to fill coverage gaps or move tests between frameworks.

MIT 142 installs ★ 533 updated 2026-10-25

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add proffesor-for-testing/agentic-qe --skill qe-test-generation -a claude-code
Open on GitHub

What qe-test-generation does

The skill examines methods, branches, dependencies, and error paths, then drafts tests around the code’s observable boundaries. It prioritizes invariants, contracts, and properties; example-based checks and mock interactions are marked as temporary. Tests receive a durable, ephemeral, or live tier tag.

You can set a framework, test type, coverage target, or pattern such as a service layer. Jest, Vitest, Mocha, Pytest, and JUnit are listed for unit and integration tests; e2e support is described for Jest and Vitest, with caveats. Keep generation scoped to individual modules: the agent may truncate output for files over 3000 lines.

What it helps with

  • assert module invariants at public boundaries
  • identify uncovered branches and error paths
  • generate unit and integration tests for changed code
  • migrate tests between Jest, Vitest, and Playwright

Example prompts for the agent

  • Generate tests for src/services/PaymentService.ts, starting with its public contracts and invariants.
  • Find coverage gaps in src/api/ and add unit tests for uncovered branches.
  • Create property and contract tests for src/repositories/.

How to install qe-test-generation

1Skills CLI (Vercel)

npx skills add proffesor-for-testing/agentic-qe --skill qe-test-generation -a claude-code

2Manually: put the files in place

~/.claude/skills/qe-test-generation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/qe-test-generation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about qe-test-generation

How do I install qe-test-generation in Claude Code?

Run npx skills add proffesor-for-testing/agentic-qe --skill qe-test-generation -a claude-code. The skill file is placed at ~/.claude/skills/qe-test-generation/SKILL.md.

What does qe-test-generation do?

It analyzes code and generates tests, prioritizing invariants, contracts, and properties. It can also target coverage gaps and produce unit, integration, and e2e tests.

Which test frameworks does the skill support?

The listed frameworks are Jest, Vitest, Mocha, Pytest, and JUnit. Unit and integration tests are covered for all five; e2e support is listed for Jest and Vitest with caveats.

Source text

SKILL.md · MIT
---
name: "qe-test-generation"
description: "Generates durable-first tests — invariants, contracts, and property-based tests at boundaries that survive a reimplementation — plus unit, integration, and e2e coverage. Use when creating tests for new or changed code, filling coverage gaps, or migrating test suites between Jest, Vitest, and Playwright."
trust_tier: 3
validation:
  schema_path: schemas/output.json
  validator_path: scripts/validate-config.json
  eval_path: evals/qe-test-generation.yaml
---

# QE Test Generation

## Purpose

Guide the use of v3's AI-powered test generation capabilities including pattern-based test synthesis, multi-framework support, and intelligent test case derivation from code analysis.

## Write durable-first (the core rule)

When AI makes code cheap to regenerate, the durable asset is the test that still
holds after the implementation is thrown away and rewritten. Generate tests in
**durability tiers**, and lead with the durable ones (ADR-113):

| Tier | What it is | Survives a rewrite? | When to write |
|------|-----------|---------------------|---------------|
| **Durable** | Invariants, contracts/schemas, property-based tests, behavioral e2e — specified at the module's public boundary | **Yes** | **Always — ≥1 per target** |
| **Ephemeral** | Example-based unit tests, mock-call/interaction tests (TDD-London style) | No (coupled to impl) | For the red-green loop; label them, delete freely |
| **Live** | Monitoring / drift / cost assertions that run against reality | Continuously | For deployed behavior |

**The language-swap heuristic:** *if reimplementing this module in another language
would invalidate the test, the test is at the wrong boundary.* Push it up a tier —
assert on the observable contract, not on how the current code happens to work.

Every generated target MUST include at least one **durable** assertion (an invariant,
a contract check, or a property). Mock-call assertions (`toHaveBeenCalledWith`) are
ephemeral by definition — never let them be the only thing testing a target. Tag each
generated test `// @tier durable|ephemeral|live` so its lifetime is explicit.

These tests are graded as **oracles**: a good test passes against the real code and
*fails* against a seeded bug (mutant). A test that asserts nothing, or only the happy
path, kills no mutants and is rejected — see `/mutation-testing` and ADR-113.

## Activation

- When generating tests for new code
- When improving test coverage
- When migrating tests between frameworks
- When applying TDD patterns
- When generating edge case tests

## Quick Start

```bash
# Generate unit tests for a file
aqe test generate --file src/services/UserService.ts --framework jest

# Generate tests with coverage target
aqe test generate --scope src/api/ --coverage 90 --type unit

# Generate integration tests
aqe test generate --file src/controllers/AuthController.ts --type integration

# Generate from patterns
aqe test generate --pattern repository --target src/repositories/
```

## Agent Workflow

```typescript
// Spawn test generation agents — durable-first
Task("Generate durable-first tests", `
  Analyze src/services/PaymentService.ts and generate Jest tests in tier order.
  1. DURABLE (write these first, >=1 per public method):
     - Invariants ("a refund never makes a balance negative")
     - Contract/schema checks on inputs and outputs crossing the boundary
     - Property-based tests (fast-check) over input ranges, not single examples
  2. EPHEMERAL (the red-green loop; tag '// @tier ephemeral'):
     - Specific happy-path examples and error paths
     - Mock external dependencies ONLY — never let a mock-call assertion be the
       only test for a method
  Apply the language-swap check: if a Python rewrite of PaymentService would break
  the test, move it up to the durable tier.
  Output to tests/unit/services/PaymentService.test.ts
`, "qe-test-architect")

// Property + contract generation (first-class, not opt-in)
Task("Generate property and contract tests", `
  For src/repositories/, derive:
  - Properties: round-trip (write→read returns same), idempotence, ordering invariants
  - Contracts: the repository interface schema, enforced on every CRUD result
  These survive a storage-engine swap; example-based CRUD tests do not.
`, "qe-property-tester")
```

## Test Generation Strategies

### 1. Code Analysis Based

```typescript
await testGenerator.analyzeAndGenerate({
  source: 'src/services/OrderService.ts',
  analysis: {
    methods: true,
    branches: true,
    dependencies: true,
    errorPaths: true
  },
  output: {
    framework: 'jest',
    style: 'describe-it',
    assertions: 'expect'
  }
});
```

### 2. Pattern-Based Generation

```typescript
await testGenerator.applyPattern({
  pattern: 'service-layer',
  targets: ['src/services/*.ts'],
  customizations: {
    mockStrategy: 'jest.mock',
    asyncHandling: 'async-await',
    errorAssertion: 'toThrow'
  }
});
```

### 3. Coverage-Driven Generation

```typescript
await testGenerator.fillCoverageGaps({
  coverageReport: 'coverage/lcov.info',
  targetCoverage: 90,
  prioritize: ['uncovered-branches', 'error-paths'],
  maxTests: 50
});
```

## Framework Support

| Framework | Unit | Integration | E2E | Mocking |
|-----------|------|-------------|-----|---------|
| Jest | ✅ | ✅ | ⚠️ | jest.mock |
| Vitest | ✅ | ✅ | ⚠️ | vi.mock |
| Mocha | ✅ | ✅ | ❌ | sinon |
| Pytest | ✅ | ✅ | ❌ | pytest-mock |
| JUnit | ✅ | ✅ | ❌ | Mockito |

## Test Quality Checks

```yaml
quality_checks:
  durability:                  # the primary check (ADR-113)
    durable_assertions_per_target: 1   # >=1 invariant/contract/property each
    language_swap_safe: true           # would survive a reimplementation
    tier_tags_present: true            # every test tagged durable|ephemeral|live

  fault_detection:             # do the tests actually catch bugs?
    mutation_score_min: 0.6            # kill rate against seeded mutants
    no_assertionless_tests: true       # reject tests that kill 0 mutants

  assertions:
    minimum_per_test: 1
    meaningful: true

  isolation:
    no_shared_state: true
    proper_setup_teardown: true

  naming:
    descriptive: true
    follows_convention: true

  coverage:                    # necessary but NOT sufficient — see fault_detection
    branches: 80
    statements: 85
```

## Skill Composition

- **After generating tests** → Run `/mutation-testing` to verify test quality
- **Before generating** → Use `/test-automation-strategy` to choose framework and patterns
- **Related** → `/qe-coverage-analysis` to find where tests are needed most

## Gotchas

- Agent truncates output on files >3000 lines — scope generation to individual modules, not entire directories
- Components that pass unit tests individually may have zero integration wiring — always generate at least one integration test per module boundary
- When generating tests for a new codebase, check which framework is installed (jest vs vitest vs mocha) — they have different mock APIs and Claude will use the wrong one
- Completion theater: agent may claim "comprehensive tests generated" but leave stubs or hardcoded values — always run the generated tests before accepting
- Fleet must be initialized before using QE agents: run `aqe health` to diagnose, or `aqe init` to re-initialize if you get "Fleet not initialized"

## Coordination

**Primary Agents**: qe-test-generator, qe-pattern-matcher, qe-test-architect
**Coordinator**: qe-test-generation-coordinator
**Related Skills**: qe-coverage-analysis, qe-test-execution

© proffesor-for-testing · MIT · proffesor-for-testing/agentic-qe

Similar skills

All skills for Testing and QA →
test-detect davila7 test-detect detects the project’s test framework, runs the matching checks, and can create starter tests for a source file. CX Codex +1 56installs ai-test-generation kindlmann ai-test-generation — a skill for Claude Code that runs a staged pipeline to generate new test code from PRDs, user stories, code diffs, bug reports, and OpenAPI specs. Enforces guardrails against fake APIs and weak asserts. CX Codex +1 1,600installs test-automation-expert curiositech test-automation-expert — a test automation skill that covers strategy, framework setup, coverage gaps and flaky test debugging. Useful when a project needs tests from scratch or existing ones keep breaking. CX Codex +1 212installs test-guard amElnagdy test-guard reviews generated or edited test code against universal rules before commit or merge. It catches test bloat, over-mocking, and trivial tests in pytest, Jest, Vitest, Go, and PHPUnit suites. CX Codex +1 4,400installs parallel-test-fixing spencerpauly The parallel-test-fixing skill runs your test suite and assigns each failing test file to a separate subagent for parallel fixes. It helps when multiple test files break simultaneously across a codebase. CX Codex +1 455installs test-audit mblode test-audit — a skill for Claude Code, Cursor, Codex and other agents that removes low-value tests from a suite down to a measured target while keeping coverage. Runs as a focused directory audit or a whole-repo campaign with a numeric goal. CX Codex +1 283installs

From the same set73

The whole set →
security-testing security-testing is a Claude Code skill that checks projects for vulnerabilities using the OWASP Top 10 approach. It activates for auth audits, injection testing, and security automation. CX Codex +1 152installs pentest-validation pentest-validation validates SAST and DAST scanner findings against non-production targets, filters out false alarms, and produces PoC exploit proof. CX Codex +1 147installs database-testing database-testing is a Claude Code skill for checking database schemas, data integrity, migrations, transactions, and query performance. It applies to data persistence checks and schema changes. CX Codex +1 146installs performance-testing performance-testing is a Claude Code skill for planning load, stress, and soak tests, setting performance targets, and investigating bottlenecks in API and application results. CX Codex +1 144installs qe-requirements-validation qe-requirements-validation is a skill that checks acceptance criteria for testability, links requirements to test cases, and generates BDD scenarios from user stories before development. CX Codex +1 141installs refactoring-patterns Applies refactoring patterns. Runs when you need to improve code structure without changing behavior. CX Codex +1 140installs chaos-engineering-resilience chaos-engineering-resilience — a skill for injecting controlled failures into distributed systems, verifying recovery mechanisms, and validating resilience. Catches weaknesses before users do. CX Codex +1 138installs localization-testing The localization-testing skill checks translation coverage, locale-specific formats, RTL layouts, and Unicode handling. Use it when adding languages or preparing an international release. CX Codex +1 137installs

Project sponsors

Companies that keep this analytics open