mutation-test
БесплатноЗапускает вложенные скриптыНе проверенRun mutation testing to validate test quality beyond code coverage. Use when assessing test effectiveness, finding weak tests, or validating test suite quality.
от jmagly★ 233 звезды на GitHubОб этом скилле
Mutation Test Skill
Purpose
Run mutation testing to measure test suite effectiveness. Mutation testing introduces small changes (mutants) to code and checks if tests catch them. High coverage with low mutation score indicates weak tests.
Research Foundation
| Concept | Source | Reference |
|---|---|---|
| Mutation Testing Theory | IEEE TSE (2019) | Papadakis et al. "Mutation Testing Advances" |
| ICST Mutation Workshop | IEEE Annual | Mutation 2024 |
| Stryker Mutator | Industry Tool | stryker-mutator.io |
| PITest | Java Tool | pitest.org |
| mutmut | Python Tool | github.com/boxed/mutmut |
When This Skill Applies
- User asks to "validate test quality" or "check test effectiveness"
- User mentions "mutation testing" or "mutation score"
- User wants to know if tests are "actually testing anything"
- High coverage but bugs still escaping
- Assessing test suite health
- Pre-release quality validation
Trigger Phrases
| Natural Language | Action |
|---|---|
| "Run mutation testing" | Execute mutation analysis |
| "Check if my tests are effective" | Run mutation + analyze |
| "Validate test quality" | Mutation score report |
| "Are my tests catching real bugs?" | Mutation analysis |
| "Find weak tests" | Identify low-score tests |
| "Why did this bug escape tests?" | Mutation analysis on module |
Mutation Testing Concepts
What is a Mutant?
A mutant is a small code change that should cause tests to fail:
// Original
if (age >= 18) { return "adult"; }
// Mutant 1: Changed >= to >
if (age > 18) { return "adult"; }
// Mutant 2: Changed >= to ==
if (age == 18) { return "adult"; }
// Mutant 3: Changed "adult" to ""
if (age >= 18) { return ""; }
Mutation Operators
| Operator | Example | Tests |
|---|---|---|
| Arithmetic | + → - |
Math operations |
| Relational | >= → > |
Boundary conditions |
| Logical | && → || |
Boolean logic |
| Literal | true → false |
Constant handling |
| Return | return x → return null |
Return value handling |
Mutation Score
Mutation Score = (Killed Mutants / Total Mutants) × 100
| Score | Quality | Interpretation |
|---|---|---|
| 90%+ | Excellent | Tests are highly effective |
| 80-89% | Good | Target for production |
| 60-79% | Adequate | Room for improvement |
| <60% | Poor | Tests need significant work |
Implementation Process
1. Detect Project and Resolve Tool
def mutation_tool(project_type):
if project_type == "javascript":
return "stryker"
elif project_type == "python":
return "mutmut"
elif project_type == "java":
return "pitest"
Use the project's existing lockfile or approved dependency workflow. Record the resolved tool and version in the evidence; do not install an unpinned tool as an implicit side effect of this skill.
2. Configure Mutation Testing
Stryker (JavaScript):
// stryker.config.json
{
"mutate": ["src/**/*.ts", "!src/**/*.test.ts"],
"testRunner": "vitest",
"reporters": ["html", "progress"],
"coverageAnalysis": "perTest",
"thresholds": {
"high": 80,
"low": 60,
"break": 50
}
}
mutmut 3 (Python):
# pyproject.toml
[tool.mutmut]
source_paths = ["src/package/"]
only_mutate = ["src/package/critical_contract.py"]
pytest_add_cli_args = ["--no-cov", "-q"]
pytest_add_cli_args_test_selection = ["tests/test_critical_contract.py"]
mutate_only_covered_lines = true
Keep both only_mutate and the selected tests explicit. A directory-wide
fallback is not an acceptable substitute for a target that was selected to fit
the runtime budget.
PITest (Java):
<!-- pom.xml -->
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.15.0</version>
<configuration>
<targetClasses>
<param>com.example.*</param>
</targetClasses>
<mutationThreshold>80</mutationThreshold>
</configuration>
</plugin>
3. Preflight Python Native Extensions
mutmut 3's covered-line mode runs coverage and stats in the same parent Python
process. Its coverage phase snapshots sys.modules, runs the selected tests,
then unloads every newly imported module. A later stats pass can re-import a
native extension that cannot safely be initialized twice. This is an upstream
mutmut boundary, not a killed/survived mutant and not evidence that the project
tests failed. See mutmut #528.
Before any Python run with mutate_only_covered_lines = true, execute the
selected tests through the bundled subprocess probe:
python scripts/native_extension_preflight.py \
--test-selection tests/test_critical_contract.py \
--pytest-arg=--no-cov \
--
Установить mutation-test в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mutation-test?
Run mutation testing to validate test quality beyond code coverage. Use when assessing test effectiveness, finding weak tests, or validating test suite quality.
Как установить скилл mutation-test?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mutation-test запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This 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…
от Anthropic