No slash command · from testing-plugin
Runs mutation testing with Stryker (TS/JS) and mutmut (Python) to find weak tests that pass on mutated code. Helps improve test quality by validating that tests actually catch bugs.
Ships in testing-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Expert knowledge for mutation testing - validating that your tests actually catch bugs by introducing deliberate code mutations.
| Use this skill when... | Use another skill instead when... |
|---|---|
| Validating test effectiveness | Writing unit tests (use vitest-testing) |
| Finding weak/insufficient tests | Analyzing test smells (use test-quality-analysis) |
| Setting up Stryker or mutmut | Writing E2E tests (use playwright-testing) |
| Improving mutation score | Generating test data (use property-based-testing) |
| Checking if tests catch real bugs | Setting up code coverage only |
Mutation Testing Concept
What Mutation Testing Reveals
# Using Bun
bun add -d @stryker-mutator/core
# For Vitest
bun add -d @stryker-mutator/vitest-runner
# For Jest
bun add -d @stryker-mutator/jest-runner
npx stryker run # Run mutation testing
npx stryker run --incremental # Only changed files
npx stryker run --mutate "src/utils/**/*.ts" # Specific files
npx stryker run --reporters html,clear-text # HTML report
open reports/mutation/html/index.html # View report
Mutation score: 82.5%
- Killed: 66 (tests caught the mutation)
- Survived: 14 (tests passed despite mutation - weak tests!)
- No Coverage: 0 (mutated code not executed)
- Timeout: 0 (tests took too long)
// Source code
function calculateDiscount(price: number, percentage: number): number {
return price - (price * percentage / 100)
}
// WEAK: Test passes even if we mutate the calculation
test('applies discount', () => {
const result = calculateDiscount(100, 10)
expect(result).toBeDefined() // Too weak!
})
// STRONG: Test catches mutation
test('applies discount correctly', () => {
expect(calculateDiscount(100, 10)).toBe(90)
expect(calculateDiscount(100, 20)).toBe(80)
expect(calculateDiscount(50, 10)).toBe(45)
})
A static mutant mutates code that runs at module load (constant maps, Zod
schemas). Observed with @stryker-mutator/vitest-runner 10.0.0 on Vitest 4.1:
ignoreStatic: true | Effect |
|---|---|
| Skips | Static mutants that no test covers |
| Does not skip | Static mutants some test covers — these run only against the 1-2 tests Stryker attributes coverage to, often unrelated files that imported the module first |
So a static mutant can report Survived although the test that really asserts on
that code would kill it. One Next.js app: 384 of 766 survivors were static: true
with testsCompleted <= 5; excluding them moved the score from 68% to ~79%. A
static survivor that ran against many tests is real (dropping .trim() from
a Zod schema survived 195 tests, and stayed green across all 96 related tests
when applied by hand). Count the survivors worth reading:
jq '[.files[].mutants[] | select(.status=="Survived" and ((.static|not) or .testsCompleted > 5))] | length' reports/mutation/mutation.json
The threshold 5 is a heuristic from that one codebase, not a Stryker-defined
value. Tie-breaker for a suspicious static survivor: apply the mutation by hand
and run the related tests — a red suite means the survivor was false.
uv add --dev mutmut # Using uv
pip install mutmut # Using pip
uv run mutmut run # Run mutation testing
uv run mutmut run --paths-to-mutate=src/calculator.py # Specific files
uv run mutmut results # Show results
uv run mutmut summary # Summary
uv run mutmut show 1 # Show specific mutant
uv run mutmut apply 1 # Apply mutant manually
uv run mutmut html # HTML report
Status: 45/50 mutants killed (90%)
- Killed: 45 (tests caught the mutation)
- Survived: 5 (tests passed despite mutation)
Everything above assumes a framework. Plenty of real mutation testing is a hand-rolled loop instead — apply a mutation, run one assertion, catch the failure — typically because the thing under test is a build-time check in a generator or builder rather than a unit test suite.
That loop is worth writing. But it drops the one piece of bookkeeping the frameworks give you for free: Stryker and mutmut tell you which test killed each mutant. A hand-rolled harness usually reports only that something failed, and "something failed" is indistinguishable from "the check I am testing failed". Four ways that goes wrong — the first three observed in one session, the fourth in another:
Before trusting a hand-rolled harness's table, open references/hand-rolled-harness-failures.md: §1 an earlier check masks the one under test, §2 choosing a mutation only the target check can see, §3 import-time derived state left stale after mutating a table, §4 the mutated file was never imported (false MISSED, with the per-runtime search-path table).
A harness that prints CAUGHT for every mutation is often quoted as proof the suite is sound. It proves something weaker:
An all-CAUGHT table proves each mutation was caught by some assertion. It never proves the assertion you meant was the one that caught it — nor that any individual assertion is capable of failing.
Two cheap additions close most of the gap:
raise or accept-all that fails to turn the suite red
is not a weak assertion, it is proof the harness is not running the file it
edited (§4).workflows/survivor-triage.workflow.js ships beside this skill. It is a TEMPLATE to adapt,
not a script to run verbatim. Read it, then rewrite it for the work in front of you. It runs
Stages 1 and 2 of references/triaging-large-survivor-sets.md.
Adapt freely: the agent prompts, project, the severity rubric and noise list,
staticMinTests (default 5, per § "Static survivors under the Vitest runner are often false"), integrationGlob,
verifyKinds, and the MAX_CLUSTERS / VERIFY_MAX caps.
Agent budget: 14 — up to 8 read-only triage agents (one per caller cluster) and up to 6 skeptics (verifyCap, default 4, clamped to 6).
Preserve across any adaptation: (a) the loop bound is the caller's clusters, cut by
CLUSTERS.slice(0, 8) after an explicit over-cap abort, and the skeptics by a literal
slice(0, 6), never a prose "for each"; (b) the closed kind and held | downgraded | refuted
enums, with a held that lacks a reproduction recorded as refuted and a dead skeptic returned
unverified, never held; (c) the Rank barrier: every cluster's claims are sorted by severity
before any skeptic starts, so the cap goes to the worst claims in the scan, not to the cluster
that finished first; (d) whatever the cap or a dead skeptic leaves comes back in unverified
in the claim shape, so { worktree, project, claims: <unverified> } re-runs the same template
as verify-only. scripts/tests/test-survivor-triage.sh pins (a)–(d), each literal slice on its own.
Skip the harness when: the scan is one cluster, or few enough survivors to read in one pass — that is a linear pass and the harness is pure overhead. The reference's stages remain the authoritative description of what each stage must produce; the harness only fixes how the work is split.
| Score | Quality | Action |
|---|---|---|
| 90%+ | Excellent | Maintain quality |
| 80-89% | Good | Small improvements |
| 70-79% | Acceptable | Focus on weak areas |
| 60-69% | Needs work | Add missing tests |
| < 60% | Poor | Major test improvements needed |
| Context | Command |
|---|---|
| Quick TS mutation | npx stryker run --incremental --reporters clear-text |
| Targeted TS mutation | npx stryker run --mutate "src/core/**/*.ts" |
| Quick Python mutation | uv run mutmut run --paths-to-mutate=src/core/ |
| View survived | uv run mutmut results | grep Survived |
| CI mode | npx stryker run --reporters json |
For detailed examples, advanced patterns, and best practices, see REFERENCE.md.
vitest-testing - Unit testing frameworkpython-testing - Python pytest testingtest-quality-analysis - Detecting test smellsapi-testing - HTTP API testingagent-patterns-plugin:tool-result-traps - Control-testing any negative that gates an action (§4's hard-wired raise is exactly that control)REFERENCE.md (opens in a new tab)references/hand-rolled-harness-failures.md (opens in a new tab)references/triaging-large-survivor-sets.md (opens in a new tab)scripts/tests/run-survivor-triage.mjs (opens in a new tab)scripts/tests/test-survivor-triage.sh (opens in a new tab)workflows/survivor-triage.workflow.js (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub laurigates/claude-plugins --plugin testing-plugin20 skills in this plugin
/benchmark-controlsBenchmark control hazards: mutated controls, disagreeing harnesses, VM lock scaling, hyperfine 2.0 exports. Use when benchmarking, comparing timings, A/B runs, hyperfine./measurement-controlsCheck a benchmark, A/B or eval metric measures what it claims: control arms, oracles that can fail, pooled correlations, small x/N. Use when setting up an experiment or a metric says improved./odiff-image-diffingodiff pixel-by-pixel image diffing. Use when comparing screenshots, detecting visual regressions, diffing before/after PNGs, asserting golden images.Other plugins' skills for the same job