agentleFS
hidevinliuhidevinliu/red-green-mode/skills/mutation-check/SKILL.md

mutation-check

Skill11 starsChanged 3 months agoMITView on GitHub

Lightweight mutation testing that answers one question: does this test actually bite the code it claims to guard? It breaks the target production code on purpose; the test must go red. If it stays green, it is a dead or weak test. Use when the user asks "is this test testing anything", "does this test have teeth", "find dead/weak tests", "run a mutation test", "are my acceptance criteria real", or "I changed the code and no test went red" (这个测试是不是白测了 / 有没有牙 / 找死测试 / 帮我做 mutation test). Zero dependencies (Python stdlib). Python is first-class (function-level `file.py::func` targets); C-family languages are best-effort. Not for running a test suite, measuring coverage, or writing tests.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. trailofbits/coop★ 808same name
    2. jisuzzzz/haechi★ 17same name
    3. ArthurC02/SkillHub★ 1same name
    4. scoobydont-666/shared-claude-skills★ 1same 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 repositoryOne other file it gives its agents.

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before calling a test DEAD, narrow the target to the function the test actually asserts on (file.py::func) and run again.

    line 54
  2. Very specific:

    If you already have an acceptance-contract.json (the shared source of truth for the PRD → TDD → red-green handoff), check each criterion's …

    line 60

“Common” is measured: kept by at least 6 in 10 of the 3 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

mutation-check · find dead and weak tests

A standalone entry point to red-green-mode's contract quality gate. It reuses tools/rgm_mutation.py from this repository, so you can hunt dead tests without entering the full red-green loop.

Requires the red-green-mode repository on disk. In the commands below, $RGM is its root (for example ~/.claude/skills/red-green-mode). See "Install" at the end.

What it catches

Beyond "green is not the same as correct" there is a third trap: a test that is always green proves nothing. Common shapes:

  • assert True, an assertion that always holds, or a test that only checks "no exception"
  • a test that asserts on a mock's return value and never touches real logic
  • a test that exercises function A while claiming to guard function B
  • core logic changed and not one related test went red (a blind spot)

mutation-check injects a single-point change into the target code (flipped comparison, emptied return, negated boolean, flipped arithmetic operator, number ±1, commented-out line) and re-runs the test. The test must go red. If every sampled mutation survives, the test does not bite that code.

Usage

A · Check one pair (most common)

Give it one test command and the production code it should guard (narrow it to a function with ::func):

python3 "$RGM/tools/rgm_mutation.py" check-pair \
  --verifier "python3 -m pytest tests/test_calc.py::test_add -q" \
  --target   "src/calc.py::add" \
  --root . --format sentinel
# ALIVE = has teeth (>=1 mutation killed); DEAD = dead/weak test
# exit 0 = ALIVE or N/A, 1 = DEAD, 2 = BLOCK

Before calling a test DEAD, narrow the target to the function the test actually asserts on (file.py::func) and run again. Many DEAD results come from a target that is too large (a whole file) where sampling missed the lines the test covers. That is a false DEAD, not a weak test.

B · Check every item in an acceptance contract

If you already have an acceptance-contract.json (the shared source of truth for the PRD → TDD → red-green handoff), check each criterion's verifier:

python3 "$RGM/tools/rgm_mutation.py" check \
  --contract acceptance-contract.json --root . --format sentinel

Explain why one item is DEAD

python3 "$RGM/tools/rgm_mutation.py" explain \
  --contract acceptance-contract.json --item AC-03 --root .
# lists the mutations tried; for ALIVE, which one was killed; for DEAD, how many survived

Reading the result

ResultMeaningNext step
ALIVEThe test goes red when the code breaksThe target is real
DEADEvery sampled mutation survived① Narrow the target to ::func to rule out a false DEAD. ② Still DEAD: the test checks the wrong thing or asserts too loosely. Strengthen the assertion
N/ANo target given, or the item guards nothingUse check --require-targets to force a target on every item
BLOCKTarget or symbol not found, or a leftover backup existsFix the target path; clear leftovers with restore --root .

Safety and limits

  • Writes to your files, but leaves nothing behind. Each mutation is preceded by a byte-level backup; a finally block restores it unconditionally, and an on-disk sidecar covers a killed process. After a normal run the working tree is byte-identical. Never commit mid-run.
  • Weak criterion by design. It asserts that a test has some teeth (at least one mutation killed), not that its teeth are complete. Sampling is capped, so a huge target with a narrow test can produce a false DEAD; narrow with ::func.
  • Languages. Python is first-class (AST syntax check plus ::func). C-family files (.js/.ts/.go/.java/.rs…) are best-effort: no ::symbol, commenting a line can cut a multi-line statement, and it has not been verified end-to-end on real runtimes.
  • Full limitations are in the docstring at the top of tools/rgm_mutation.py. The referee for the tool itself is tests/test_mutation.py.

Install

git clone https://github.com/hidevinliu/red-green-mode ~/.claude/skills/red-green-mode
ln -s ~/.claude/skills/red-green-mode/skills/mutation-check ~/.claude/skills/mutation-check
export RGM=~/.claude/skills/red-green-mode

For Codex or another runtime, link the same folder into that runtime's skills directory.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.