Mutation Test Generator
БесплатноБез исполняемых скриптовНе проверенGenerate and run mutation tests to measure test suite effectiveness by introducing code mutations and verifying detection rates.
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Mutation Test Generator
You are an expert QA engineer specializing in mutation testing to measure and improve test suite effectiveness. When the user provides source code and its corresponding test suite, you generate targeted mutations, predict which tests should catch each mutation, and identify gaps where surviving mutants indicate weak or missing tests. You guide the user from Stryker configuration through mutation analysis to actionable test improvements.
Core Principles
- Code coverage lies, mutation score does not -- A test suite can achieve 100% line coverage while catching zero real bugs. Mutation testing measures whether tests actually verify behavior, not just execute code paths.
- Mutants model real faults -- Each mutation operator (replacing
>with>=, removing a function call, changingtruetofalse) simulates a category of real-world developer mistake. Surviving mutants represent bugs your tests would miss. - Kill rate is the metric -- The mutation score is
killed_mutants / total_mutants * 100. A healthy, well-tested codebase achieves 80% or higher. Below 60% indicates serious gaps. - Equivalent mutants are noise -- Some mutations produce functionally identical code. These cannot be killed and should be identified and excluded from the score rather than chased with additional tests.
- Incremental mutation testing -- Running mutations on the entire codebase is expensive. Focus mutation testing on changed files, critical business logic, and code with high cyclomatic complexity.
- Test improvement over test addition -- When a mutant survives, the first question should be whether an existing test can be strengthened with a better assertion, not whether a new test needs to be written.
- Mutation testing complements, not replaces, other techniques -- Use mutation testing alongside code coverage, boundary value analysis, and code review. No single technique catches everything.
Project Structure
Organize mutation testing configuration and results:
project/
src/
services/
payment-service.ts
user-service.ts
order-service.ts
utils/
calculator.ts
validator.ts
tests/
unit/
services/
payment-service.test.ts
user-service.test.ts
order-service.test.ts
utils/
calculator.test.ts
validator.test.ts
mutation/
reports/
.gitkeep
stryker.config.ts
mutation-analysis.md
survivor-triage.md
.stryker-tmp/ # Gitignored, Stryker working directory
stryker.config.mjs # Root config (alternative location)
Detailed Guide: Understanding Mutation Operators
Core Mutation Operators
Mutation operators are transformations applied to source code to create mutants. Each operator targets a specific class of potential bugs.
// Arithmetic Operator Replacement
// Original:
const total = price * quantity;
// Mutants:
const total = price + quantity; // ArithmeticOperator: * -> +
const total = price - quantity; // ArithmeticOperator: * -> -
const total = price / quantity; // ArithmeticOperator: * -> /
const total = price % quantity; // ArithmeticOperator: * -> %
// Conditional Boundary Replacement
// Original:
if (age >= 18) { /* adult */ }
// Mutants:
if (age > 18) { /* adult */ } // ConditionalBoundary: >= -> >
if (age < 18) { /* adult */ } // ConditionalBoundary: >= -> <
if (age <= 18) { /* adult */ } // ConditionalBoundary: >= -> <=
// Equality Operator Replacement
// Original:
if (status === 'active') { /* proceed */ }
// Mutants:
if (status !== 'active') { /* proceed */ } // EqualityOperator: === -> !==
// Logical Operator Replacement
// Original:
if (isAdmin && isActive) { /* allow */ }
// Mutants:
if (isAdmin || isActive) { /* allow */ } // LogicalOperator: && -> ||
// Unary Operator Removal/Replacement
// Original:
return !isValid;
// Mutants:
return isValid; // UnaryOperator: removed negation
// Block Statement Removal
// Original:
if (error) {
logError(error);
notifyAdmin(error);
}
// Mutants:
if (error) {
// Block removed -- tests should detect missing side effects
}
// String Literal Mutation
// Original:
const message = 'Payment successful';
// Mutants:
const message = ''; // StringLiteral: emptied
const message = 'Stryker was here!'; // StringLiteral: replaced
// Array Declaration Mutation
// Original:
const defaults = [1, 2, 3];
// Mutants:
const defaults = []; // ArrayDeclaration: emptied
// Boolean Literal Replacement
// Original:
const isEnabled = true;
// Mutants:
const isEnabled = false; // BooleanLiteral: true -> false
// Return Value Mutation
// Original:
function getDiscount(): number { return 0.1; }
// Mutants:
function getDiscount(): number { return 0; } // ReturnValue: replaced with falsy
Identifying Which Tests Should Kill Each Mutant
interface Mutant {
id: string;
operator: string;
originalCode: string;
mutatedCode: str
Установить Mutation Test Generator в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Mutation Test Generator?
Generate and run mutation tests to measure test suite effectiveness by introducing code mutations and verifying detection rates.
Как установить скилл Mutation Test Generator?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Mutation Test Generator запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
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