/l3a0:fast-mutationfrom l3a0
Speeds up mutation testing by scripting all mutants into a single call scoped to relevant tests, avoiding per-mutant tool round trips. Drives pytest or plain test scripts.
Ships in l3a0. 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.
A mutation run asks whether the tests notice when the code is broken. Its cost should be the tests' run time, and usually it is not. On marketlake's PR #713 the entitlement tests took 0.98 s per mutant, while a lens that broke the code by hand ran for over an hour. The time went to model round trips, about four tool calls per mutant, and to full-suite runs on survivors. This skill moves the whole loop into one script call, and spends model time only on choosing mutants and judging survivors.
scripts/mutate.py takes a JSON spec and runs every mutant in it, in one process. Its
docstring gives the spec format. For each mutant it does five things.
[old, new] string edits. Each old must occur exactly once, or the mutant
is reported NOT-APPLIED and nothing is written.__pycache__, because a same-length edit can keep stale bytecode and fake a
survivor.git checkout -- would also discard uncommitted work.Before any mutant, it refuses a mutated file that resolves outside root, then runs the
baseline and stops with exit code 2 if the baseline is not green. A baseline
that already fails, for example a wall-clock test under load, makes every mutant read as
caught.
After the loop, the runner re-runs each scoped survivor on its own against the tests in the
escalate selection that reach its code. Survivors cannot share one run: two applied together
can mask each other, and a failure could not be pinned on either.
python3 <this skill>/scripts/mutate.py spec.json --out /path/to/scratch/run1
Use --only NAME ... to re-run chosen mutants after adding a test, --no-escalate to skip
the wide runs, --escalate-full to re-run each survivor against the whole escalate
selection, and --workers N to spread the wide runs over pytest-xdist workers.
A suite of plain scripts, each run as python3 tests/<file> and exiting non-zero on a failure, has no pytest to drive. l3a0/claude-plugins is one: most of its test files print an ok or FAIL line per check, and two use unittest. On l3a0/claude-plugins PR #100, the test engineer in each of seven review rounds wrote its own loop to apply a mutant, run the script and restore the file, because this runner only drove pytest.
Set "runner": "script" in the spec for such a suite. Each selection is then a command the spec's interpreter runs, such as ["tests/test_brief_anchors.py"], or a list of such commands that must all pass. Each command reads an empty stdin, so a test that waits for input fails rather than hangs. A run is green when every command exits 0. Its failures are the output lines that match fail_pattern, which defaults to lines starting FAIL, FAILED or ERROR, the last being what unittest prints for a test that raises. A command that fails without such a line is reported by its last output line.
The baseline and each mutant run the same way as with pytest, including the byte-copy restore and the cleared __pycache__. Four things differ in this mode.
timeout is one budget for all the commands of a selection. A run that has already failed when the budget runs out reads red, so a mutant one command caught is not reported as a timeout.escalate selection, because the coverage map is a pytest plugin. Its line says scope=full (script runner, no coverage map), unless --escalate-full was given. The baseline and escalation run under escalate_timeout, which defaults to twice timeout, because the whole suite takes longer than one script. When escalate names the same command as select, a survivor learns nothing from it, so name the whole suite there or pass --no-escalate.tests/test_board_guard.sh goes in as ["-c", "import subprocess, sys; sys.exit(subprocess.call(['sh', 'tests/test_board_guard.sh']))"].{
"runner": "script",
"root": "/path/to/worktree",
"python": "/usr/bin/python3",
"baseline": ["tests/test_brief_anchors.py"],
"select": ["tests/test_brief_anchors.py"],
"escalate": [["tests/test_brief_anchors.py"], ["tests/test_review_post.py"]],
"mutants": [
{"name": "refuse no overwrite", "file": "skills/ask-team/scripts/brief_anchors.py",
"edits": [["if os.path.exists(out):", "if False:"]]}
]
}
A runbook or design doc whose sentences a test asserts is mutated the same way as code. The
file can be any UTF-8 text file, such as docs/what-a-person-runs.md, and each edit swaps
the pinned sentence for a false one. The runner reads and writes the file as bytes with no
newline translation, so a file with CR or CRLF line endings keeps them, and a test that compares
the file's bytes fails only on the edit. An edit that spans lines names \r\n in its old where the
file has it, because the runner matches bytes. An old with a bare \n after other text, where the file has
\r\n, reads NOT-APPLIED. One whose only \n is its first character still matches, at the \n of a \r\n. A file that is not
UTF-8 reads NOT-APPLIED too.
In 16 review rounds of l3a0/ithildin-runtime PR #493,
a lens mutated pinned runbook sentences with sed -i and restored them by copying a backup
back. When a run moved to the background, the runbook stayed mutated for minutes. The runner
restores the file on Ctrl-C, SIGTERM and SIGHUP, and on any failure inside the loop, before it
exits. While a mutant's tests run, though, the mutant sits in the file under root. So point
root at an archive copy, git -C <checkout> archive <head> | tar -x -C <scratch>/copy, never
at a checkout someone reads, and pass --no-escalate. The coverage map records Python
functions, so a mutant of a text file would otherwise escalate against the whole escalate
selection. python stays an absolute path into the checkout, because an archive copy holds
no untracked .venv, and a relative path is read from root. A setting the tests need, such as AWS_CONFIG_FILE=/dev/null, goes before the
command, because every run inherits the runner's environment.
{
"root": "/path/to/scratch/copy",
"python": "/path/to/checkout/.venv/bin/python",
"baseline": ["tests/test_vm_rollout.py"],
"select": ["tests/test_vm_rollout.py", "-k", "refusal"],
"mutants": [
{"name": "stops at the wrong step", "file": "docs/what-a-person-runs.md",
"edits": [["its job stops at `Refuse a plan`", "its job stops at `Read what the plan does`"]]}
]
}
AWS_CONFIG_FILE=/dev/null python3 <this skill>/scripts/mutate.py spec.json --no-escalate --out /path/to/scratch/run1
The wide run exists to catch a test far from the mutated code that still reaches it. Running the whole suite per survivor is an expensive way to find that test. On marketlake's PR #738 each full run took about 250 s on a loaded laptop, which put 48 survivors at more than 3 hours, and every one that finished survived the full suite anyway. Coverage answers the same question exactly, so escalation runs only the tests that execute the mutated function. It takes three steps.
escalate selection once, unmutated, with scripts/cover_map.py
loaded as a pytest plugin. The plugin uses sys.monitoring from Python 3.12 to record
which tests start each function in the mutated files, and it needs no third-party package.
This run doubles as the full-suite run of workflow step 6. If it is red, escalation is
skipped and the runner exits with code 3, because every wide verdict would read as caught.old and new share, added only to make old unique, does not
count. Code nested inside a function, such as an inner function or a generator
expression, counts as that function.The method rests on one assumption: a test that never starts the mutated function cannot
observe the mutation. The runner cannot rely on it in three cases, and each falls back to the
full escalate run for that mutant.
parametrize argument calls it
during collection.Every survivor falls back to the full run when the target interpreter is older than 3.12, or
when another tool already holds the sys.monitoring coverage slot.
Two other routes reach code without starting it in the test's own run, and the map covers
both. A fixture wider than function scope is set up once, inside the first test that asks for
it, so the map credits code it starts to every test that uses the fixture. A test that spawns a
process can run the code in a child the plugin cannot see, so every such test joins every
scoped selection. State carried between tests, such as a memoized result, is not covered.
Use --escalate-full when a suite relies on it.
Each escalated line ends with scope=coverage (N tests) or scope=full (<reason>).
results.jsonl records the map's path in its MAP row and each mutant's scope in its row.
Measured on PR #738 at commit 7d817c6, on a laptop that other sessions kept at a load average between 5 and 30, so every time here is rough.
The map run and every full-suite fallback each cost one full-suite run. pytest-xdist splits a
run across worker processes. On marketlake a trial for issue #746 measured the full suite at a
median of 246.7 s serially and 75.0 s with 8 workers. The runner can pass -n N to the wide
runs, and it never passes it anywhere else.
Ask for workers with "workers": 8 in the spec, or with --workers 8, which wins over the
spec. --workers 0 turns them off. Without either, nothing changes. The runner then adds
-n N to three kinds of run.
workers_min_secs in the map run.
The default is 10 s. The map records each test's run time for this decision.The baseline and the per-mutant runs stay serial. Starting workers costs 2 to 3 s, and a narrow
run takes about 5 s, so workers there would slow the loop down. For the same reason, keep -n
out of the escalate selection itself, or every scoped escalation pays the startup.
When the target interpreter cannot import xdist, the runner prints that pytest-xdist is missing and runs everything serially.
Under xdist each worker is its own process with its own sys.monitoring state, so each worker
maps only the tests it ran. It writes that map next to cover_map.json, as
cover_map.gw0.json and so on. The controller, the process that starts the workers and runs no
test itself, merges them into cover_map.json at the end of the run. The merge unions the
tests per function, outside_tests and the files seen, and it refuses maps that disagree on the
root directory. The rules above still hold inside each worker. Collection runs in every worker,
so a function a parametrize argument calls still counts as running outside tests. A worker sets
up its own copy of each wider fixture, so the fixture rule credits the tests in that worker. A
test that spawns a process is caught in whichever worker ran it. A process that xdist starts
for itself does not count as a spawn. That covers each worker, and on macOS the uname and
file calls a worker makes to report its platform.
A worker that crashes leaves no map. The controller then writes no merged map and prints a
cover_map: line. The crash also fails a test, so the runner treats the map run as red and
skips escalation with exit code 3.
The coverage-scoped runs work under xdist too. Every worker reads the same list of test IDs and so collects the same filtered set, which xdist requires. Only the controller writes the report of which IDs matched.
Measured on PR #738 at commit 8abb35f, with six survivors known to be equivalent, run serially
and then with "workers": 8 on a laptop other sessions kept loaded, so every time is rough.
-k or
node-ID selection that reaches the mutated code, or in script mode the one script that
does. On PR #713 the two whole files took 7.79 s,
and the 17 entitlement tests took 0.98 s. Use the narrow selection per mutant, and the whole
files as the baseline and for escalation.--only to show it is now caught.conftest.py it edited. Leave
the whole suite to CI's run on the push that carries the new assertions, which is where a
far-away break surfaces, since a whole-suite run on the laptop repeats it and takes cores from
the other lenses. Where no CI job runs the suite, run it here once. Check that clean sits
beside backup/ in --out, as ## Safety says, since a restore that missed a surviving
mutant leaves a change the whole suite also passes.A lens prompt should name this skill and give the lens the scoped selection and the target commit. The lens writes the spec, runs it once, and spends its turns on survivors. The prompt should also forbid the slow pattern outright: no hand edit, test run and restore per mutant as separate tool calls, and no full-suite run per mutant.
A run that outlasts the shell's ten-minute foreground limit goes in the background with
run_in_background, and its own completion notice says when it is done. Do not watch it with
until ! pgrep -f "<spec file>". pgrep -f matches the loop's own command line, which
contains the spec file's name, so the loop never exits. On 2026-10-10 one lens left six such
loops running for up to two hours. The lens stops any background task it started before it
reports. The global CLAUDE.md rule "Leave no background job waiting on itself" carries the
full reasoning.
The runner restores every file when it ends, including on Ctrl-C, SIGTERM or SIGHUP, which it
turns into an ordinary exit. SIGKILL cannot be caught, so a run killed that way leaves the current mutant in
place. Copy each file back from backup/ in the --out folder, where the runner wrote a byte copy
of every file under its own path, such as backup/a/b.py, before the first mutant, and
nothing else. A file clean beside backup/ in --out marks that the worktree matches
backup/: applying a mutant removes it and each restore writes it again. So a run that finds backup/ without it, holding other bytes than the
worktree, comes after one killed with a mutant applied, and it refuses to start rather than
overwrite the only copy of an original. Compare each file it names with backup/ before
copying anything back, since an edit made on purpose differs too. A run that finds the marker
empties backup/ and takes fresh backups, so editing a file between runs is fine. Without
--out the folder is ~/.cache/fast-mutation/<hash of root>, created for the user alone, so a
rerun finds the earlier backups and no other user can plant one. Each mutated file must be a
plain path relative to root, with no .. part, because its backup is kept under that path. The
runner prints the --out path before the baseline runs, so a killed run still shows where it is. Any of those
signals arriving during the last restore is ignored, so it cannot cut the restore short. After
a normal run they work again once it is done. After a stop signal they stay ignored until the
runner exits, and when a signal stops the last restore before it has finished, the runner
calls it again, so the restore still runs. Python runs a signal handler only between bytecodes, so these steps narrow the window in
which a signal can skip a restore, and cannot close it. After any exit code other than 0, 2 or
3, compare the worktree with backup/. A restore that hangs can still be stopped with Ctrl-\ or
kill -9, after which backup/ holds the copy. The runner also refuses a file with
a second hard link, because the root check cannot see where the other link sits.
The runner executes code only through pytest, or through the commands a script spec names, in the given worktree. A repository whose
default paths point at live configuration must redirect them in its test setup. Marketlake's
conftest redirects the config directory. A standalone probe that imports the package before
redirecting can write to live configuration, which happened on 2026-10-06. Keep every
mutation run inside the test runner, and point root at a worktree, never at a main checkout that
another session uses.
It does not generate mutants. That is deliberate. Generated mutants come in bulk and need
triage: mutmut ran 243 mutants in 29.7 s on marketlake, but 15 of its 19 survivors were
equivalent. Hand-written mutants aimed at stated guarantees find the gaps that matter. For
breadth, run mutmut with only_mutate scoped to the changed file, separately.
It does not run mutants in parallel. Workers split the tests of one wide run, but the mutants
still run one at a time against one source tree. Parallel mutants would need one source copy
per worker. A copied virtualenv can still import the original source, so verify
module.__file__ points inside the copy. Parallelism also pays only when cores are idle.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub l3a0/claude-plugins --plugin l3a012 skills in this plugin
/ask-boardConvene a board of directors on a strategic decision for a one-person venture. Separate advisor agents, each with its own objective, write blind memos and cross-examine. A secretary agent drafts the synthesis without knowing the CEO's view, and the main thread chairs and keeps the minutes. Use when the user asks to "ask the board", "what would my board say", "convene the board", "give me board feedback on" a plan, or asks a strategic question as the CEO or sole operator of their own venture, such as "should I do X first", "what should I focus on first", or "is my plan right or wrong"./ask-teamConvene a repository's engineering team on a plan, a design, a pull request or a blog post. Separate role agents, one per role, each review the same subject blind to the others, holding only what their role protects and may veto. Verifiers then try to refute each finding by executing code, and only what survives is acted on. Use when asked to "ask the team", "convene the team", "have the team review" an issue, a design doc, a pull request or a blog post, to audit an issue's plan before a build starts, or for the per-role lenses a repository's team charter names for its review step. A pull request review or a post review such as review-post can call it in lens mode, where it returns verified findings to the caller and posts and fixes nothing. To run a whole review round on a pull request, or on companion pull requests that land one rule in several repositories, with its brief, its lenses, its verifiers, its fixes and its review comment, read review-round.md. Not for owner decisions about money, live trading, contracts or law, which go to the board through /l3a0:ask-board.Other plugins' skills for the same job