mutation-testing
Finds weak or missing tests by checking whether small code changes (mutants) would be caught by the test suite, then hands the gaps to TDD. Use when verifying…
от nikeyes★ 24 звезды на GitHub
Установить mutation-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Mutation Testing
Answers one question: "If I introduced a bug here, would a test fail?" Coverage tells you a line was executed; mutation testing tells you a change to that line would be detected.
Attribution: Adapted from eferro's skill-factory (Apache-2.0), itself based on Paul Hammond's mutation-testing skill.
Usage
/mutation-testing <file> # whole module
/mutation-testing # branch diff: git diff main...HEAD plus uncommitted changes
/mutation-testing --changed <files...> # only changed hunks: git diff HEAD -- <files>; untracked files whole
/mutation-testing --tool [...] # force the project's mutation tool (see Modes)
Only production code is mutated. Skip test files, generated code and pure configuration.
Modes
- Mental (default): you generate mutants by reading the code and reason about whether the tests would fail. Fast, works in any language, leaves the working tree untouched except for the empirical checks below.
- Tool: run the project's mutation tool restricted to the scope. Use it when
--toolis passed or the project already configures one (stryker.config.*/stryker.conf.*,[tool.mutmut]inpyproject.toml/setup.cfg, the pitest plugin inpom.xml/build.gradle*). See the tool reference for the scoped command.
Never install a mutation tool or add its configuration. If --tool is passed and no tool is set up, say so and continue in mental mode.
Workflow
Resolve scope. List the production files and, for diff modes, the changed line ranges.
Check the baseline. Run the tests that cover the scope. If they fail, stop and report: mutation results are meaningless on a red suite.
Generate mutants. For each function in scope, apply the operators in operators.md plus the language reference: python.md, javascript.md (JS/TS), java.md, kotlin.md. Favor the high-yield operators listed there; skip mutants that would not compile. In tool mode, run the tool instead: mutmut.md, stryker.md, pitest.md.
Evaluate each mutant. Find the tests that exercise the line and trace a concrete input: would an assertion produce a different result? Count a mutant as killed only when you can name the test and the input that kills it. When unsure, check empirically (see Applying Mutants).
Classify each survivor:
Class Meaning Action Missing test No test exercises the input that distinguishes the mutant Behavior for tdd Weak test A test runs the line but its assertion or inputs cannot tell the difference (identity values, toBeTruthy, "does not throw")Behavior for tdd Superfluous code The mutated code does not affect observable behavior: duplicate branches, unreachable defensive checks, redundant calls Refactor candidate for tdd Equivalent The mutant is semantically identical to the original ( x + 0vsx - 0)Drop it A survivor never proves the business logic is wrong — only that no test distinguishes the two versions.
If the plan you're implementing explicitly asks for code that looks superfluous (a signature, a default, a defensive check), don't hand it over as a refactor candidate. Report it as still alive and give that as the reason.
Hand off to tdd. Invoke
/stepwise-core:tddwith the Skill tool, using the handoff format below. Describe behaviors, not mutants: tdd writes tests through the public interface and does not need to know how the gap was found.Verify each kill. For every test tdd added, apply its mutant, run that test, confirm it fails, and revert. If the mutant still survives, send tdd one sharper behavior (a more distinguishing input); after that retry, report it as still alive.
- Tests tdd left skipped with
- BUGcannot kill anything: list them under Bugs found instead of verifying them. - If tdd applied refactor candidates, rerun steps 3–5 on the refactored lines. Hand any new survivors to tdd once more.
- Tests tdd left skipped with
Report using the format below.
Applying Mutants
Empirical checks edit production code temporarily. After each check, the file must be byte-for-byte what it was before the mutant; confirm it with a checksum. These files usually hold uncommitted work that git can't restore, so keep your own copy before mutating. If you can't get the file back, stop and report. One mutant at a time, running only the tests that cover it; never commit or stage.
Handoff Format (to tdd)
These behaviors already exist in the code, but no test pins them down.
Expect each test to pass on its first run; do not change production code to make
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/java.md
- references/javascript.md
- references/kotlin.md
- references/mutmut.md
- references/operators.md
- references/pitest.md
- references/python.md
- references/stryker.md
FAQ
Что делает скилл mutation-testing?
Finds weak or missing tests by checking whether small code changes (mutants) would be caught by the test suite, then hands the gaps to TDD. Use when verifying test effectiveness, asking "would my tests catch this bug?", hunting surviving mutants, or checking changed code after TDD. Triggers on "mutation testing", "mutants", "surviving mutants", "Stryker", "mutmut", "PIT" or "pitest".
Как установить скилл mutation-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mutation-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…