mutation-test
Skill1 starsChanged 3 months agoMITView on GitHub
Proves a test actually checks something, by breaking the behaviour it claims to cover and confirming it goes red. Use when a test, fixture, assertion or guard has been reported as working and you want evidence rather than a green run, or to check a claim that some code is dead, unused or unreachable. Also use it to SCOPE that work to a PR or a diff — shortlisting the changed lines and giving you a throwaway checkout to break them in. It does not mutate anything for you. Triggers on "mutation test", "mutation testing", "prove it fails", "are these tests real", "does this test actually assert anything", "is that assertion live", "did you verify it's not vacuous", "which changed lines are tested", "is this PR actually covered", "are the changes in PR 123 tested", "check the coverage on this diff", "mutation test this PR", or any claim that a test passes being offered as evidence the behaviour is correct. Also use it proactively before reporting harness or fixture work as done.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- AlvaroVFon/skillstheir own version, first seen Oct 3, 2026
- greglas75/zuvotheir own version, first seen Sep 6, 2026
- squall-chua/skillstheir own version, first seen Aug 9, 2026
- sunitghub/canon-skillstheir own version, first seen Jul 26, 2026
- nwiizo/ccswarmtheir own version, first seen Apr 17, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- nwiizo/ccswarm★ 153same name
- sunitghub/canon-skills★ 9same name
- greglas75/zuvo★ 8same name
- AlvaroVFon/skills★ 2same name
- squall-chua/skills★ 2same name
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 repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- user-claude-md/CLAUDE.mdCLAUDE.md
- adversarial-reviewSkill
- feature-planningSkill
- hyperdxSkill
- langfuseSkill
- pr-reviewSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 9 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 59
If you use an isolated tree anyway, do not try to prove the wiring with a probe first.
- Very specific: line 74
Never overwrite an existing backup: If <file>.mtbak is already there when you go to make one, a previous run was interrupted: that file is …
- Very specific: line 83
Use cmp <file> <file>.mtbak — or a checksum taken before the mutation — and delete the copy only once it matches.
- Distinctive: line 109
If the claim is "X is absent when Y", make X present when Y.
- Distinctive: line 126
Before touching anything, run the test that claims to cover the behaviour.
- Distinctive: line 138
Read the mutated line back.
- Distinctive: line 144
Not just that it went red — *why*.
- Distinctive: line 204
If the same class of defect keeps appearing, a mutation run per instance is the wrong tool.
- Distinctive: line 213
Delete the thing — from a copy, per the rules above — run the tests it plausibly touches, and report what broke.
- Distinctive: line 258
Before your command runs it establishes three things, all of them directly observed:
- Very specific: line 298
Every added or modified line in the diff, as path<TAB>line.
- Distinctive: line 344
No coverage map, so a run over several lines means running the suite several times.
“Common” is measured: kept by at least 6 in 10 of the 5 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 run is the null result, not evidence. A dead assertion and a live one produce identical output, so "it passed" discriminates nothing.
This skill establishes the one thing that does discriminate: break the behaviour and watch it go red. Work is not done when it passes. It is done when it has been seen to fail for the right reason.
Scope, and what this version does not do
Two paths. Path A runs one claim at a time, by hand, mutating the file in place — the right answer for code you have just written, because a worktree cannot hold uncommitted work. Path B takes a PR or a diff and gives you the changed lines plus a throwaway checkout to work in; it needs committed work. Neither path applies a mutation for you — choosing the edit and judging the result are manual in both. There is no coverage map, so checking several lines means running the suite several times.
Rules
- Break the source, never the test. Mutating the test proves only that the test tests itself.
- Never mutate test files.
- Copy the file before you touch it, and restore from that copy. Not from git.
The files this skill is pointed at are usually the ones just written, so they
hold uncommitted work —
git checkout,git restoreandgit stashdestroy it rather than restoring it.cp <file> <file>.mtbak, mutate, thenmvit back. Mutate the file where the tests actually load it from — in place. The tempting shortcut is to mutate a copy instead, so the real tree stays clean: a
git worktree, a scratch checkout, a second clone. By default that does not work, and it fails silently. A Python editable install records an absolute path to the original source; configured source roots, prebuilt artifacts and installed packages behave the same way. The tests go on importing the file you did not touch, so every mutant passes — which is indistinguishable from a real coverage gap, and reads as "nothing covers this line" when the truth is "nothing ran your change". This is what makes the backup rule above load-bearing rather than merely tidy, and it is why this skill mutates in place instead of somewhere clean.If you use an isolated tree anyway, do not try to prove the wiring with a probe first. Three designs tried and each was defeated: breaking the syntax shows only that something read the file, a lint step objects while the judging step never runs; emptying it is no better, a type checker notices the symbol is gone without executing anything; appending a fatal statement is caught by a formatter reacting to the added bytes, and in Go, Rust or Java there is no legal top-level fatal statement to append at all. Every one of them measures the same thing — does the command react to these bytes changing — which any step that merely reads the file satisfies.
Judge it from the results instead, where the signal is honest: mutate several independent lines, and if every single mutant survives, suspect the environment before believing the coverage. That cannot be fooled by a linter, needs no knowledge of the language, and costs nothing, because you were running the mutants anyway.
- Never overwrite an existing backup. If
<file>.mtbakis already there when you go to make one, a previous run was interrupted: that file is the only pristine copy left and the working file is probably still mutated. Recover from it, verify withcmp, delete it, and start again. Copying over it destroys the original permanently — the same way a colliding backup key destroyed one in an earlier batch runner — part of why none ships. - Verify the restore by content, not by
git status. On an already-dirty filegit statussays "modified" before and after the mutation andgit diffshows a diff either way, so neither can tell a restored file from a still-mutated one. Usecmp <file> <file>.mtbak— or a checksum taken before the mutation — and delete the copy only once it matches. - A survivor is a coverage gap, not a bug. The code is usually correct as written. The finding is that a future edit could change behaviour with the suite still green.
- Do not write the test that closes the gap unless asked. Report, then stop — see Why this reports and does not fix.
- When the same class keeps recurring, stop mutating and build a guard. See Retire the class.
The procedure
For each claim under test, one at a time.
1. Name the claim precisely
Not "fixture 147 passes" but "fixture 147 asserts that a null prompt_tokens
reaches no span attribute". A claim you cannot state in one sentence cannot be
mutation-tested, because you do not know what to break.
2. Take a copy, then choose the mutation
Copy first — that copy is the only thing standing between a mutation and lost
work. Check it does not already exist before you write it: [[ -e <file>.mtbak ]]
means a previous run was interrupted and left the original there, so recover from
it before doing anything else. Never copy over it. Then prefer the smallest mutation that violates the claim and nothing else.
If the claim is "X is absent when Y", make X present when Y. If it is a pair of
opposite claims (X true here, false there), you need both directions: a
one-way mutation can only ever kill one of them, and the survivor is not evidence
of anything.
Good targets, in rough order of value:
- Boundaries —
>=↔>,<↔<=, off-by-one on an index or floor - Decision constants — a timeout, threshold, retry count. Change to a different plausible value, not to garbage
- Sentinels and defaults —
None↔{}, a fail-closed default flipped open - Operators —
and↔or, a dropped negation - Deleted stores — remove a write, see if any test observes it
- Error paths — swallow a raise, drop a rollback, skip a cleanup
3. Run the test unmodified — confirm it is green
Before touching anything, run the test that claims to cover the behaviour. If it is already failing, stop and say so. A red starting point makes the whole exercise unable to answer the question: the test fails identically with and without the mutation, so "it went red" is not evidence the mutation caused it, and a dead assertion is indistinguishable from a live one.
Knowing the test was green beforehand is what licenses the inference. Discovering it afterwards means running the whole thing again.
4. Apply the mutation, and confirm it landed — before running anything
This is the step that is skipped, and skipping it produces false "survivors". Read the mutated line back. A find/replace that matched nothing, matched in the wrong place, or matched inside a comment leaves the behaviour intact, and the green run that follows means nothing at all.
5. Run, and read the failure message
Not just that it went red — why. A test that fails with an import error or a fixture error when you expected an assertion failure did not exercise the claim; it broke on the way there.
6. Restore, and verify by content
cp <file>.mtbak <file> — copy rather than move, so the backup survives a failed
restore — then cmp <file> <file>.mtbak. Delete the backup only once they
match. If cmp disagrees, leave it in place and say so: it is still the only
pristine copy, and removing it on the way past is how the original gets lost. Do this before reporting anything, not after. A stray mutation left
behind is worse than every finding is good.
7. Report the two claims separately
"The mutation landed" and "the test caught it" are different findings. Say both. A reader cannot tell a live assertion from a skipped step otherwise.
What a survivor means
A mutation that leaves the suite green means one of:
- The assertion is dead — it exists but is not pointed at anything.
- The mutation did not land — check step 4 again before concluding anything.
- The mutation was not a violation — you broke something the claim does not actually cover. Sharpen the claim or the mutation.
- The claim is a negative control — it fails only for a non-conforming implementation, so no conforming mutation kills it. Legitimate, but say so explicitly rather than leaving it looking verified.
- The fixtures derive from the mutated value — mutating a constant moves both sides together. Usually correct and refactor-safe, not a defect.
Rule out the middle three before reporting the first.
Why this reports and does not fix
The report is the artifact. Closing a gap is a separate decision, taken with the
report in hand — the same split as pr-review and adversarial-review.
The reason is not just workflow tidiness. A test written to kill a mutant tends
to test the mutant rather than the behaviour. Handed >= → > and told "make
this fail", the path of least resistance is to assert on the exact boundary value,
which pins an implementation detail and makes the threshold harder to tune later.
You get a green suite that is no more correct and more expensive to change.
Deciding what a survivor means needs judgement the mutation cannot supply:
- Most survivors on a constant happen because the tests derive their fixtures FROM that constant, so mutating it moves both sides together. That is usually correct and refactor-safe, not a defect.
- Pinning the literal (
assert WINDOW == 60.0) closes the mutant and buys nothing — a pure change-detector that fails on every legitimate retune. - The useful test states the operational claim in absolute terms ("two minutes of silence means the endpoint recovered"), which kills a 60→600 mutation while surviving a 60→90 retune.
Those three look identical from a survivor list. Only a human reading the code can tell them apart, so report, then stop.
Retire the class
If the same class of defect keeps appearing, a mutation run per instance is the wrong tool. Prefer a structural guard that makes the class impossible: enumerate what each consumer actually reads and fail when something declares a key nobody reads. That retires the class instead of re-detecting it, and it keeps working when nobody remembers to run this skill.
Claim checking
For "this code is dead / unused / can be removed", the same method answers it. Delete the thing — from a copy, per the rules above — run the tests it plausibly touches, and report what broke. A claim that survives deletion is probably right; one that kills two tests is answered, and the reply writes itself. This is the only way to disagree with a static-analysis finding on evidence rather than assertion.
Highest-risk signal
A test that passes the moment you wire it, with no other work, is the most likely to be vacuous — not the easiest win. Treat an immediate pass as a reason to mutate, not a reason to move on.
Why this skill prompts for permission
mutation_test_worktree.sh deliberately ships without a permission rule, so
it asks before it runs. That is not unfinished setup, and adding a rule for it
is not the fix.
Its --setup and --test arguments are handed to bash -c verbatim. Any rule
that lets the script run unprompted approves the wrapper, not the payload — so
an agent that assembled a test command from a repository's README or CI config
could run it with no prompt at all. The script is invoked once per mutation
session rather than once per file, so the cost is a single prompt showing the
exact command that will execute.
The isolation layer: mutation_test_worktree.sh
This skill ships two scripts. This one gives you a disposable checkout that is
known-good before you touch it; mutation_test_changed_lines.sh is a standalone
diff parser that opens no repository and is run on its own, in Path B step 1.
The manual procedure above uses neither — Path A mutates in place, which is
the whole point of the in-place rule. This script is for the case where you
genuinely need an isolated tree, and Path B
is built on it.
mutation_test_worktree.sh run --test <cmd> [--setup <cmd>] [--repo <path>]
[--ref <ref>] [--keep] -- <command>...It creates a throwaway git worktree, runs your command inside it, and removes
it. The worktree's path never leaves the script; your command sees it as the
working directory and in $MUTATION_TEST_WORKTREE, and its exit status is
passed through unchanged.
Before your command runs it establishes three things, all of them directly observed:
- the repository has no uncommitted or untracked changes, so the checkout
matches what you are looking at — a worktree holds committed work only.
This one is skipped when
--refnames something other thanHEAD, since the reasoning only holds while the worktree is cut from the commit your tree is sitting on. Path B's PR recipe always passes such a ref, so it always skips this; the run says so when it does - a
--setupcommand you named ran successfully in it --testexits 0 in it, so the baseline is green
What it deliberately does NOT establish is that --test can see a mutation
at all. Nothing exit-code-shaped can: three designs tried and each was defeated
by a step that reads a file without executing it. Judge it from your own
results: mutate a line you are confident IS covered and confirm that one goes
red before trusting a survivor anywhere else. This script says so on success
rather than implying more.
It refuses rather than guessing, and every refusal prints a machine-readable
mutation_test_worktree: refused: <slug> line before exiting. It asks for
permission on every run, deliberately — see Why this skill prompts for
permission.
Path B: scoping a run to a PR or a diff
For a PR or a diff, rather than picking lines by eye. It needs committed work, because a worktree holds nothing else — so Path A above remains the answer for code you have just written.
There is no batch runner. Choosing the mutation and judging the result stay manual, exactly as in Path A. What this path gives you is a shortlist of candidate lines and a disposable checkout that is known-good before you start.
1. Get the candidate lines.
gh pr diff 277 | mutation_test_changed_lines.sh --suffix .pyEvery added or modified line in the diff, as path<TAB>line. Deleted lines are
absent — there is nothing left to mutate. A hunk whose declared length does not
match its content is refused rather than guessed at.
Fetch the PR head if you plan to check it out, because gh pr diff and
gh pr view are API calls that write nothing to your object database, and a
fork's head is never fetched by the default refspec:
git fetch origin pull/277/head
gh pr view 277 --json headRefOid --jq .headRefOid2. Pick the lines that carry real risk.
This is the judgement no tool makes for you. A changed line is not a claim; the question is which of these lines, if silently broken, would leave the suite green. Read them and choose a handful.
3. Work in a throwaway checkout.
mutation_test_worktree.sh run --ref <pr-head-sha> --test 'make test' -- \
<your command>It cuts a worktree at the ref you name, runs --setup in it, confirms the
baseline is green, runs your command inside it, and removes it. Your own files
are never touched. --ref is the head SHA from step 1; without it the worktree
is cut from your HEAD, which the diff's line numbers do not address.
The command you pass is yours — an editor invocation, a small script, anything. Then apply one mutation, run the suite, read the failure, exactly as in Path A. Because the checkout is disposable there is nothing to restore: when the command returns, the worktree goes.
What is still not here
No batch runner. Nothing here applies a mutation, runs the suite and scores it for you. Applying an edit to someone's file and reliably putting it back is a small idea with a large number of ways to lose their work, and nothing shipped here does it. Choosing the mutation and judging the result are yours; what this skill provides around that is a shortlist of candidate lines and a checkout you cannot damage.
No coverage map, so a run over several lines means running the suite several
times. That map is where "0 covering tests for all nine mutants" came from, and
running everything is slower but cannot be subtly wrong. No timeout, because
timeout is GNU coreutils and absent on a stock macOS.
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.

