Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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 \
  --
Полный SKILL.md на GitHub

Установить mutation-test в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

scripts/aiwg_mutation_native_probe.pyscripts/native_extension_preflight.py

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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить mutation-test с