mutation-testing
Skill0 starsChanged 9 days agoMITView on GitHub
Meta-test your test harness — apply small intentional defects to production code, expect the suite to catch each one. Surfaces silent coverage gaps that 100% line coverage hides.
32 other projects use a version of this.
Adopted by
Most recently taken up by
- bartoszkobylinski/lovsportheir own version, first seen Nov 15, 2026
- camunda/camundatheir own version, first seen Nov 8, 2026
- DnsQueen/orcinus-skillstheir own version, first seen Nov 8, 2026
- Integralist/agent-skillstheir own version, first seen Nov 1, 2026
- shangyiy/life-kittheir own version, first seen Nov 1, 2026
- Hakkadaikon/hymmetheir own version, first seen Oct 26, 2026
Used with
Projects with it also use domain-modeling and grill-with-docs.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
GoogleSkilldomain-modeling
Build and sharpen a project's domain model. Use when the user wants to pin down domain terminology or a ubiquitous language, record an architectural decision, or when another skill needs to maintain the domain model.
Also in 3 projects that use this
MicrosoftSkillgrill-with-docs
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise. Use when user wants to stress-test a plan against their project's language and documented decisions.
Also in 3 projects that use this
Other versions32 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 32
- metabase/metabase★ 50ksame name
- recharts/recharts★ 28ksame name
- camunda/camunda★ 4.4ksame name
- ThibautBaissac/rails_ai_agents★ 665same name
- proffesor-for-testing/agentic-qe★ 524same name
- s3s-project/s3s★ 315same name
- jvm-skills/jvm-skills★ 140same name
- Amplicode/spring-skills★ 126same name
- GGGODLIN/gggodlin-cc-harness★ 73same name
- Integralist/agent-skills★ 23same name
22 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/bootstrap-project/resources/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/bootstrap-project/resources/CLAUDE.mdCLAUDE.md
- act-tenetsSkill
- adversarial-reviewSkill
- annotate-screenshotSkill
- anti-hallucinationSkill
- ascii-chartSkill
- assess-brainSkill
- big-ideaSkill
- bootstrap-coreSkill
- bootstrap-projectSkill
- browser-toolsSkill
- chart-big-ideaSkill
- chart-interpretationSkill
- chart-vocabularySkill
- code-reviewSkill
- communication-craftSkill
- compile-brainSkill
- convertSkill
- corpus-qa-sweepSkill
- critical-thinkingSkill
- deep-reviewSkill
- doc-hygieneSkill
- docs-shellSkill
- docx-to-mdSkill
- ethical-reasoningSkill
- evaluate-before-adoptingSkill
- figure-generatorSkill
- flint-chartSkill
- flint-interactionsSkill
- flint-themeSkill
- git-workflowSkill
- html-to-mdSkill
- humanizerSkill
- install-visual-companionsSkill
- lint-clean-markdownSkill
- markdown-mermaidSkill
- markdown-sanitization-chainSkill
- md-to-emlSkill
- md-to-htmlSkill
- md-to-txtSkill
- md-to-wordSkill
- meditationSkill
- planSkill
- platform-awarenessSkill
- print-svg-style-guideSkill
- proactive-awarenessSkill
- problem-framing-auditSkill
- project-capability-authoringSkill
- project-statusSkill
- render-chartSkill
- render-verifySkill
- rich-emailSkill
- risk-analysisSkill
- security-and-hardeningSkill
- setup-dependenciesSkill
- setup-enterprise-stackSkill
- spikeSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 29 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
After authoring a new test file, before declaring it "covers" the module
- Distinctive: line 16
After adding tests to a previously-untested module
- Distinctive: line 17
Before publishing any release that newly depends on a module's correctness
- Distinctive: line 18
When a code review surfaces "this is tested, but I'm not sure the tests assert what we think they do"
- Distinctive: line 20
Do NOT fire: when:
- Distinctive: line 35
Expect ≥ 1 failure: If the suite still passes, that branch has no real coverage.
- Distinctive: line 36
Discard the copy: before applying the next mutation.
- Distinctive: line 156
Every named branch in the production module has a mutation entry in your run log
- Distinctive: line 157
Every survivor was either closed by a new test or explicitly accepted with a reason (e.g., "behavior is internal-only, no public contract")
“Common” is measured: kept by at least 6 in 10 of the 29 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Mutation Testing
A green test suite tells you the tests passed. It does not tell you whether the tests would have caught a real defect. Mutation testing closes that gap: introduce a one-character defect in production code, run the suite, expect at least one test to fail. Survivors are coverage gaps.
Coverage measures whether the line was executed. Mutation measures whether the line was meaningfully asserted on. The two are not the same.
When to fire
- After authoring a new test file, before declaring it "covers" the module
- After adding tests to a previously-untested module
- Before publishing any release that newly depends on a module's correctness
- When a code review surfaces "this is tested, but I'm not sure the tests assert what we think they do"
Do NOT fire when:
- The code under test is throwaway (one-off scripts, scratch experiments)
- A formal mutation-testing tool (
stryker,mutmut) is already in CI — that supersedes the manual protocol below - The cost of running the suite once is high (long integration tests) — sample the high-risk mutations instead of running all of them
The protocol
For each load-bearing branch / guard / constant in the module:
- Copy the project or a supported test fixture to a temporary location. The mutation target must be inside that copy, never the working tree.
- Apply a one-character defect that flips the behavior (invert a comparison, change a numeric literal, replace a guard with
if (false)) - Run the suite against the copy —
npm testor the project's canonical entry point, with any required root override targeting the copy. - Expect ≥ 1 failure. If the suite still passes, that branch has no real coverage.
- Discard the copy before applying the next mutation.
- Record the result: caught / survived / precondition-not-found, as one result line per mutation in a run-log file. The harness below already prints
[Name] CAUGHT/[Name] *** SURVIVED ***/[Name] PRECONDITION-NOT-FOUND; capture those lines to the log so the tally (below) is a count, not a recollection.
The source files must remain unchanged. A mutation run that requires restoring a working-tree file is already too risky: an interrupted process, a failed write, or another tool reading the file can leave a real defect behind.
Isolated Mutation Harness
function Test-Mutation {
param(
[string]$ProjectRoot,
[string]$RelativePath,
[string]$Find,
[string]$Replace,
[string]$Name,
[scriptblock]$RunTests
)
$sandbox = Join-Path ([System.IO.Path]::GetTempPath()) ("mutation-" + [guid]::NewGuid())
try {
New-Item -ItemType Directory -Force -Path $sandbox | Out-Null
Copy-Item -LiteralPath $ProjectRoot -Destination (Join-Path $sandbox 'project') -Recurse
$copyRoot = Join-Path $sandbox 'project'
$target = Join-Path $copyRoot $RelativePath
$original = Get-Content -LiteralPath $target -Raw
if (-not $original.Contains($Find)) { "[$Name] PRECONDITION-NOT-FOUND"; return }
Set-Content -LiteralPath $target -Value $original.Replace($Find, $Replace) -NoNewline
$exitCode = & $RunTests $copyRoot
if ($exitCode -ne 0) { "[$Name] CAUGHT" } else { "[$Name] *** SURVIVED ***" }
} finally {
Remove-Item -LiteralPath $sandbox -Recurse -Force -ErrorAction SilentlyContinue
}
}
# The test command receives the disposable project root. Adapt its root override
# or fixture option to your project; do not silently fall back to the real root.
$runTests = {
param($copyRoot)
Push-Location $copyRoot
try { npm test; return $LASTEXITCODE } finally { Pop-Location }
}
Test-Mutation $PWD 'lib/semver.js' 'if (pa.major !== pb.major)' 'if (pa.major === pb.major)' 'M2 major-equality inverted' $runTestsFor a small validator, a purpose-built temporary fixture is often cheaper than copying the whole project. Steward's ONE-check suite uses that pattern: it generates disposable fixtures and temporary validator copies, then asserts the working validators' bytes remain unchanged.
Tallying the results
The mutations-caught ratio in the Quality bar comes from counting the run log's result lines mechanically, never from tallying outcomes as you go:
- PowerShell:
$caught = (Select-String -Path $log -Pattern '\] CAUGHT$').Count,$survived = (Select-String -Path $log -Pattern 'SURVIVED').Count,$missing = (Select-String -Path $log -Pattern 'PRECONDITION-NOT-FOUND').Count - bash:
grep -c '\] CAUGHT$' run.log,grep -c 'SURVIVED' run.log,grep -c 'PRECONDITION-NOT-FOUND' run.log
Report caught / (caught + survived) from those counts, with survived and precondition-not-found listed separately.
Counter-Test Detection Rules
A detector needs two proofs. First, inject the live defect it exists to catch into an isolated active artifact and assert that it reports a failure. Then add the innocent case that previously caused a false positive and assert silence.
For example, a rule against a retired process must flag a new active route that revives the process, while allowing historical prose that says the process was retired. A counter-test for a detection rule keeps a correct historical record from looking like the defect itself.
High-value mutation patterns
| Production-code shape | Mutation that catches a real defect |
if (cond) return X (guard) | Replace cond with false — proves the guard fires |
a < b ? -1 : 1 (compare) | Swap the branches — proves ordering is asserted |
a !== b (inequality) | Replace with a === b — proves the inequality matters |
Object.freeze(X) | Strip the freeze — proves callers depend on immutability |
flag === 'specific-value' | Change the literal — proves the value matters, not just truthiness |
Object.assign({}, src, ...) (immutable merge) | Drop the {} (mutates src) — proves no-mutation is asserted |
arr.filter(x => x.kind === 'edition') (filter) | Replace with true — proves the filter has data to filter against |
fs.writeFileSync(p, v, { flag: 'wx' }) (exclusive write) | Drop the flag — proves exclusivity matters |
Anti-patterns the protocol catches
1. Filter with no input data. A .filter(e => e.name !== 'local') test passes trivially when the test data contains zero local/ entries. Mutation: replace with e => true. If no test fails, the filter is unverified. Fix by seeding test data that would be filtered out and asserting it doesn't appear in the output.
2. Exports that production never calls. Easy to grep: Select-String -Path src/,extension.js -Pattern "exportedName" — if production callers are zero, the unit tests are testing dead code. Either wire the export into production or remove it.
3. Platform-skipped tests with no fallback. A symlink-cycle test that skips on Windows is no coverage on Windows. Look for t.skip(...) and ask: does the protected behavior have a deterministic, platform-independent test alongside it?
4. "Didn't throw" assertions. A test that builds a 60-level deep tree and asserts the call "didn't throw" is true even with the depth cap removed. Add a sharp assertion: with cap=50, the depth-60 leaf must be unreachable.
5. Frontmatter-only tests. A test that JSON.parse's a manifest and asserts keys.includes('spec_version') passes even when the field has the wrong value. Assert on the value, not just key presence.
What "good coverage" looks like
For each production module:
- Every load-bearing branch has a mutation that catches its removal. Not "every line is covered" — every branch where flipping the condition would ship a real defect.
- The mutation that catches it names the behavior (e.g., "stale-lock breaking disabled" → caught by
stale lock (>10min mtime) broken atomicallytest). - Active-filter tests where source data doesn't naturally exercise the filter. Seed the data; verify the filter fires.
- Reference-equality tests for null-result fast paths (e.g., a pure function that returns the input unchanged on null provenance — assert
out === input).
Worked examples from the field
| Mutation | Production code | Test that caught it | Lesson |
marker_schema_version: 2 → 1 | lib/edition-install.js applyStaticFetchMarkerFields | "all six v2 fields" asserts marker_schema_version === 2 | Assert on the literal value, not just presence |
if (_seen.has(real)) → if (false) | lib/fs-utils.js listFilesRecursive | "pre-populated _seen short-circuits the walk" | Exploit the function's internal parameters (_seen, _depth) for deterministic platform-independent coverage |
e.name !== 'local' → e.isDirectory() (filter removed) | .github/scripts/build-edition-manifest.cjs | "regenerates without leaking local/ entries (active filter test)" | When the source tree has no local/ dirs, the filter has nothing to filter against — seed temp local/ subdirs to make the filter measurable |
Object.assign({}, marker, ...) → Object.assign(marker, ...) | lib/edition-install.js applyStaticFetchMarkerFields | "does not mutate the input marker" | The {} is load-bearing; mutate it to prove the test asserts immutability |
Quality bar
A mutation-testing pass is complete when:
- Every named branch in the production module has a mutation entry in your run log
- Every survivor was either closed by a new test or explicitly accepted with a reason (e.g., "behavior is internal-only, no public contract")
- The total mutations-caught ratio is recorded from the run-log counts (e.g., "15 of 16 mutations caught; M8 deferred"; see Tallying the results)
- The working tree's source files remain unchanged throughout the run, and the temporary copy is removed after each mutation
Anti-patterns
| Anti-pattern | Correction |
| Running mutations on throwaway code | Use the protocol on production modules with real consumers; throwaway code is throwaway |
| Reading "coverage 100%" as "tests are good" | Coverage is a necessary but insufficient signal; mutation tells you whether the assertion was meaningful |
| Mutating a live source file then restoring it | Use a temporary copy; restore logic cannot protect an interrupted live mutation |
| Manually running 20 mutations one at a time | Use the isolated harness above; it handles copy disposal + result aggregation |
| Treating a SURVIVED mutation as a test-quality problem alone | Often it surfaces a production-code design problem (dead export, untestable branch) |
Falsifiability — would revise if
- Event-based: if a formal mutation-testing tool (Stryker, mutmut) is adopted in CI, this skill becomes documentation for the manual fallback only; trim the protocol section accordingly.
Origin
Codified 2026-05-31 after meta-testing a static-fetch test harness (commit 4163f67). The protocol caught two real coverage gaps (symlink-cycle protection and depth-cap enforcement in lib/fs-utils.js) that platform-skipped tests had been silently hiding. Applied a second time to another test harness, where it caught two more gaps (local/ filter on skills and instructions in build-edition-manifest.cjs). 12 of 12 caught after gap-closing — the protocol is the reason the final harnesses are trustworthy.
Related
- code-review/SKILL.md — pre-publish review; mutation testing is the final layer when code review surfaces test-quality concerns
- Release preflight discipline — releases that newly depend on a module's correctness should mutation-test it first (Alex ACT itself formalizes this in the Steward release ritual)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

