/qa-mutation-testing:mutmut-mutationfrom qa-mutation-testing
Runs mutmut mutation testing on Python pytest/unittest suites to verify test quality. Shows surviving mutants, applies them to disk, and configures suppressions via pyproject.toml.
Ships in qa-mutation-testing. 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.
Per mutmut-docs:
"Mutmut is a mutation testing system for Python, with a strong focus on ease of use." (mutmut-docs)
Key features per mutmut-docs:
pip install mutmut and confirm the pytest / unittest suite is green before mutating.setup.cfg or pyproject.toml (source_paths + test selection) so only project source is mutated.mutmut run - the first run is slow; state is cached so later runs are incremental.mutmut results; open survivors interactively with mutmut browse.mutmut apply <id>, re-run that test, then revert.# pragma: no mutate for genuinely unreachable lines only.mutmut results as an artifact.Per mutmut-docs:
pip install mutmut
mutmut run
mutmut run "automatically detects test folders ('tests' or
'test') and locates source code" (mutmut-docs).
The first run is slow (full suite per mutant); subsequent runs use the cached state.
Per mutmut-docs, settings go in setup.cfg or
pyproject.toml:
[mutmut]
source_paths=src/
pytest_add_cli_args_test_selection=tests/
Or in pyproject.toml:
[tool.mutmut]
source_paths = ["src/"]
pytest_add_cli_args_test_selection = "tests/"
Common config:
| Setting | Use |
|---|---|
source_paths | Which files to mutate. |
pytest_add_cli_args_test_selection | Which tests to run per mutant. |
runner | pytest (default) or python -m unittest. |
tests_dir | Override auto-detected test directory. |
do_not_mutate | Regex of files / lines to skip. |
Per mutmut-docs, "Results are explored via mutmut browse,
where mutants can be retested or written to disk using mutmut apply <mutant>."
mutmut browse # interactive TUI
mutmut results # summary table
mutmut show <id> # show specific mutant diff
Output:
Total: 142
Killed: 119 (83.8%)
Survived: 23 (16.2%)
Timeout: 0
Suspicious: 0
Per mutmut-docs, common mutations include:
"Integer literals are changed by adding 1. So 0 becomes 1, 5 becomes 6, etc."
<becomes<=
breakconverts tocontinueand vice versa
Other mutators: arithmetic (+ → -), comparison flipping,
constant replacement, statement removal.
Per mutmut-docs:
Use code comments to skip specific areas:
# pragma: no mutate(single line)# pragma: no mutate block(indentation blocks)# pragma: no mutate start/end(arbitrary ranges)
def divide(a, b):
if b == 0: # pragma: no mutate
raise ZeroDivisionError("intentional unreachable")
return a / b
Use sparingly - each pragma is a confession that a line isn't mutation-tested. Reviewable in PRs.
Once a surviving mutant is identified, write a test that catches it. To verify the test catches this specific mutation:
mutmut apply <mutant-id> # writes the mutant to disk
pytest tests/affected_test.py # the new test should fail
git checkout src/ # revert the mutant
This proves the test catches the specific bug class.
- name: Mutation testing
if: github.event_name == 'schedule' # weekly
run: |
pip install -e '.[dev]'
pip install mutmut
mutmut run --max-children 4
- name: Surface results
if: always()
run: mutmut results > mutation-summary.txt
- uses: actions/upload-artifact@v4
if: always()
with:
name: mutation-results
path: mutation-summary.txt
For PRs, mutmut doesn't have native incremental mode; use
source_paths to scope to changed files via a wrapper script:
CHANGED=$(git diff --name-only origin/main...HEAD | grep '^src/')
mutmut run --paths-to-mutate "$CHANGED"
A team wants to verify the pytest suite for src/discounts.py before a release.
setup.cfg:
[mutmut]
source_paths=src/discounts.py
pytest_add_cli_args_test_selection=tests/test_discounts.py
mutmut run, then mutmut results:
Total: 142
Killed: 119 (83.8%)
Survived: 23 (16.2%)
mutmut browse shows a survivor: the boundary if total > 100: mutated to if total >= 100: - the suite never exercises total == 100.total == 100, then confirm it catches the mutant:
mutmut apply <id> # id from the browse listing
pytest tests/test_discounts.py # now fails on the mutated line
git checkout src/ # revert the mutant
mutmut run shows the mutant killed and the score up by one mutant.Anti-patterns (pragma escape hatches, full-mutation-per-PR, third-party source_paths, unrealistic gates) and mutmut's limitations (slow runs, no native PR diff scoping, equivalent mutants) are catalogued in references/mutmut-pitfalls.md.
setup.cfg / pyproject.toml, mutator examples (integer
literals, comparison flipping, break/continue).stryker-mutation,
stryker-net-mutation,
pitest-mutation,
mull-mutation - per-language
siblings.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/mull-mutationUse for any question about mutation testing in C or C++, or when a C/C++ suite has high coverage but bugs still ship: sets up Mull for Clang builds (version-matched package, -fpass-plugin flags, CMake, mull-runner, mutators, path filters) and runs it in GitHub Actions. Other languages: stryker-mutation, stryker-net-mutation, pitest-mutation, mutmut-mutation./mutant-survival-triageUse when a mutation testing run (StrykerJS, PIT, mutmut or Mull) has surviving mutants, a low mutation score, or a large report to work through: classifies each survivor (missing case, weak assertion, equivalent, unreachable, flaky), drafts the test or assertion that kills it, and states the mutation score with its formula. Does not rewrite tests automatically./pitest-mutationUse for any question about mutation testing in Java or Kotlin, or when a JVM suite has high line coverage but may assert nothing: sets up PIT (PITest) with Maven or Gradle, target classes, mutators, mutation-score thresholds that fail the build, incremental runs, Kotlin support and the HTML and XML reports./stryker-mutationUse when a JavaScript or TypeScript suite has high coverage but bugs still slip through, and the team wants mutation testing to find weak tests. Sets up StrykerJS: the Jest, Vitest, Mocha or Karma runner, stryker.conf.json, thresholds and incremental runs on pull requests./stryker-net-mutationUse for any question about mutation testing in .NET or C#, or when a .NET suite passes with good coverage but may assert nothing: sets up Stryker.NET (dotnet-stryker tool, project and solution scoping, xUnit, NUnit or MSTest, stryker-config.json thresholds) and runs it in CI. Has a worked example and mutator levels.npx claudepluginhub testland/qa --plugin qa-mutation-testing2 plugins ship this exact skill · first indexed Nov 12, 2026
Other plugins' skills for the same job