Token导航 LogoToken导航

Agent Skill · 待分类

mutation-testing(突变测试)

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

mutation-testing 是待分类类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为权限未标注;许可证信息还不明确,暂无第三方扫描结果,按安装量在待分类类的 11,209 个 Skill 里排第 8,567。

总安装 291周安装 12GitHub Stars 643下载 95核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:mutation-testing(突变测试)
来源仓库:https://github.com/citypaul/.dotfiles
仓库路径:skills/mutation-testing
安装命令:
npx skills add https://github.com/citypaul/.dotfiles --skill mutation-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/citypaul/.dotfiles --skill mutation-testing

这个 Skill 是做什么的

这个 Skill 的分类还没最终确定,用法以来源仓库的说明为准。

用于辅助测试设计、自动化测试和回归验证,适合编写测试计划或分析失败日志。适用于 Codex、Claude、Cursor、Gemini CLI 等宿主环境,聚焦测试有效性验证。使用时需确认项目测试框架、运行命令和夹具数据,避免为通过测试而修改真实逻辑。涉及浏览器或外部服务时,应区分本地模拟、测试环境与生产环境的操作差异。

mutation-testing 属于待分类类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/mutation-testing

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/citypaul/.dotfiles --skill mutation-testing;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    权限没有明确标注,第一次使用时只给一个无关紧要的任务,观察它到底读了哪些文件和网络。

常见问题

6 条

mutation-testing 怎么安装?

在终端执行 npx skills add https://github.com/citypaul/.dotfiles --skill mutation-testing。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

mutation-testing 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

mutation-testing 需要什么权限?

权限级别没有明确标注。第一次使用时建议只给无关紧要的任务,观察它实际读写了哪些内容。

mutation-testing 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

mutation-testing 用的人多吗?

公开数据是累计安装 291 次,近一周安装 12 次,下载 95 次,GitHub 643 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

mutation-testing 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理待分类类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 要求有安全扫描结论才肯安装的团队。
  • 需要厂商级技术支持和 SLA 的生产系统。

待分类类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
infsh-cli

infsh CLI · Codex、Claude

4,374,576382权限未标注未明确未收录
ai-video-generation

AI 视频生成 · Codex、Claude

4,313,376382调用外部服务未明确有提醒
lark-openapi-explorer

云雀 OpenAPI 浏览器 · Codex、Claude

2,064,1209,011需要联网未明确有提醒
lark-workflow-standup-report

Lark 工作流程站立报告 · Codex、Claude

2,041,6328,978需要联网未明确通过
use-my-browser

使用我的浏览器 · Codex、Claude

1,848,49140操作浏览器未明确未通过
mutation-testing

突变测试 · 本页

291643权限未标注未明确未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
mutation-testing
description
Mutation testing patterns for verifying test effectiveness. Use when analyzing branch code to find weak or missing tests.

Mutation Testing

Mutation testing answers the question: "Are my tests actually catching bugs?"

Code coverage tells you what code your tests execute. Mutation testing tells you if your tests would detect changes to that code. A test suite with 100% coverage can still miss 40% of potential bugs.


Core Concept

The Mutation Testing Process:

  1. Generate mutants: Introduce small bugs (mutations) into production code
  2. Run tests: Execute your test suite against each mutant
  3. Evaluate results: If tests fail, the mutant is "killed" (good). If tests pass, the mutant "survived" (bad - your tests missed the bug)

The Insight: A surviving mutant represents a bug your tests wouldn't catch.


When to Use This Skill

Use mutation testing analysis when:

  • Reviewing code changes on a branch
  • Verifying test effectiveness after TDD
  • Identifying weak tests that appear to have coverage
  • Finding missing edge case tests
  • Validating that refactoring didn't weaken test suite

Integration with TDD:

TDD Workflow                    Mutation Testing Validation
┌─────────────────┐             ┌─────────────────────────────┐
│ RED: Write test │             │                             │
│ GREEN: Pass it  │──────────►  │ After GREEN: Verify tests   │
│ REFACTOR        │             │ would kill relevant mutants │
└─────────────────┘             └─────────────────────────────┘

Systematic Branch Analysis Process

When analyzing code on a branch, follow this systematic process:

Step 1: Identify Changed Code

# Get files changed on the branch
git diff main...HEAD --name-only | grep -E '\.(ts|js|tsx|jsx)$' | grep -v '\.test\.'

# Get detailed diff for analysis
git diff main...HEAD -- src/

Step 2: Generate Mental Mutants

For each changed function/method, mentally apply mutation operators (see Mutation Operators section below).

Step 3: Verify Test Coverage

For each potential mutant, ask:

  1. Is there a test that exercises this code path?
  2. Would that test FAIL if this mutation were applied?
  3. Is the assertion specific enough to catch this change?

Step 4: Document Findings

Categorize findings:

CategoryDescriptionAction Required
KilledTest would fail if mutant appliedNone - tests are effective
SurvivedTest would pass with mutantAdd/strengthen test
No CoverageNo test exercises this codeAdd behavior test
EquivalentMutant produces same behaviorNone - not a real bug

Mutation Operators

Arithmetic Operator Mutations

OriginalMutatedTest Should Verify
a + ba - bAddition behavior
a - ba + bSubtraction behavior
a * ba / bMultiplication behavior
a / ba * bDivision behavior
a % ba * bModulo behavior

Example Analysis:

// Production code
const calculateTotal = (price: number, quantity: number): number => {
  return price * quantity;
};

// Mutant: price / quantity
// Question: Would tests fail if * became /?

// ❌ WEAK TEST - Would NOT catch mutant
it('calculates total', () => {
  expect(calculateTotal(10, 1)).toBe(10); // 10 * 1 = 10, 10 / 1 = 10 (SAME!)
});

// ✅ STRONG TEST - Would catch mutant
it('calculates total', () => {
  expect(calculateTotal(10, 3)).toBe(30); // 10 * 3 = 30, 10 / 3 = 3.33 (DIFFERENT!)
});

Conditional Expression Mutations

OriginalMutatedTest Should Verify
a < ba <= bBoundary value at equality
a < ba >= bBoth sides of condition
a <= ba < bBoundary value at equality
a <= ba > bBoth sides of condition
a > ba >= bBoundary value at equality
a > ba <= bBoth sides of condition
a >= ba > bBoundary value at equality
a >= ba < bBoth sides of condition

Example Analysis:

// Production code
const isAdult = (age: number): boolean => {
  return age >= 18;
};

// Mutant: age > 18
// Question: Would tests fail if >= became >?

// ❌ WEAK TEST - Would NOT catch boundary mutant
it('returns true for adults', () => {
  expect(isAdult(25)).toBe(true);  // 25 >= 18 = true, 25 > 18 = true (SAME!)
});

// ✅ STRONG TEST - Would catch boundary mutant
it('returns true for exactly 18', () => {
  expect(isAdult(18)).toBe(true);  // 18 >= 18 = true, 18 > 18 = false (DIFFERENT!)
});

Equality Operator Mutations

OriginalMutatedTest Should Verify
a === ba !== bBoth equal and not equal cases
a !== ba === bBoth equal and not equal cases
a == ba != bBoth equal and not equal cases
a != ba == bBoth equal and not equal cases

Logical Operator Mutations

OriginalMutatedTest Should Verify
a && b`a \\b`Case where one is true, other is false
`a \\b`a && bCase where one is true, other is false
a ?? ba && bNullish coalescing behavior

Example Analysis:

// Production code
const canAccess = (isAdmin: boolean, isOwner: boolean): boolean => {
  return isAdmin || isOwner;
};

// Mutant: isAdmin && isOwner
// Question: Would tests fail if || became &&?

// ❌ WEAK TEST - Would NOT catch mutant
it('returns true when both conditions met', () => {
  expect(canAccess(true, true)).toBe(true);  // true || true = true && true (SAME!)
});

// ✅ STRONG TEST - Would catch mutant
it('returns true when only admin', () => {
  expect(canAccess(true, false)).toBe(true);  // true || false = true, true && false = false (DIFFERENT!)
});

Boolean Literal Mutations

OriginalMutatedTest Should Verify
truefalseBoth true and false outcomes
falsetrueBoth true and false outcomes
!(a)aNegation is necessary

Block Statement Mutations

OriginalMutatedTest Should Verify
{ code }{ }Side effects of the block

Example Analysis:

// Production code
const processOrder = (order: Order): void => {
  validateOrder(order);
  saveOrder(order);
  sendConfirmation(order);
};

// Mutant: Empty function body
// Question: Would tests fail if all statements removed?

// ❌ WEAK TEST - Would NOT catch mutant
it('processes order without error', () => {
  expect(() => processOrder(order)).not.toThrow();  // Empty function also doesn't throw!
});

// ✅ STRONG TEST - Would catch mutant
it('saves order to database', () => {
  processOrder(order);
  expect(mockDatabase.save).toHaveBeenCalledWith(order);
});

String Literal Mutations

OriginalMutatedTest Should Verify
"text"""Non-empty string behavior
"""Stryker was here!"Empty string behavior

Array Declaration Mutations

OriginalMutatedTest Should Verify
[1, 2, 3][]Non-empty array behavior
new Array(1, 2)new Array()Array contents matter

Unary Operator Mutations

OriginalMutatedTest Should Verify
+a-aSign matters
-a+aSign matters
++a--aIncrement vs decrement
a++a--Increment vs decrement

Method Expression Mutations (TypeScript/JavaScript)

OriginalMutatedTest Should Verify
startsWith()endsWith()Correct string position
endsWith()startsWith()Correct string position
toUpperCase()toLowerCase()Case transformation
toLowerCase()toUpperCase()Case transformation
some()every()Partial vs full match
every()some()Full vs partial match
filter()(removed)Filtering is necessary
reverse()(removed)Order matters
sort()(removed)Ordering is necessary
min()max()Correct extremum
max()min()Correct extremum
trim()trimStart()Correct trim behavior

Optional Chaining Mutations

OriginalMutatedTest Should Verify
foo?.barfoo.barNull/undefined handling
foo?.[i]foo[i]Null/undefined handling
foo?.()foo()Null/undefined handling

Mutant States and Metrics

Mutant States

StateMeaningAction
KilledTest failed when mutant appliedGood - tests are effective
SurvivedTests passed with mutant activeBad - add/strengthen test
No CoverageNo test exercises this codeAdd behavior test
TimeoutTests timed out (infinite loop)Counted as detected
EquivalentMutant produces same behaviorNo action - not a real bug

Metrics

  • Mutation Score: killed / valid * 100 - The higher, the better
  • Detected: killed + timeout
  • Undetected: survived + no coverage

Target Mutation Score

ScoreQuality
< 60%Weak test suite - significant gaps
60-80%Moderate - many improvements possible
80-90%Good - but still gaps to address
> 90%Strong - but watch for equivalent mutants

Equivalent Mutants

Equivalent mutants produce the same behavior as the original code. They cannot be killed because there is no observable difference.

Common Equivalent Mutant Patterns

Pattern 1: Operations with identity elements

// Mutant in conditional where both branches have same effect
if (whatever) {
  number += 0;  // Can mutate to -= 0, *= 1, /= 1 - all equivalent!
} else {
  number += 0;
}

Pattern 2: Boundary conditions that don't affect outcome

// When max equals min, condition doesn't matter
const max = Math.max(a, b);
const min = Math.min(a, b);
if (a >= b) {  // Mutating to <= or < has no effect when a === b
  result = 10 ** (max - min);  // 10 ** 0 = 1 regardless
}

Pattern 3: Dead code paths

// If this path is never reached, mutations don't matter
if (impossibleCondition) {
  doSomething();  // Mutating this won't affect behavior
}

How to Handle Equivalent Mutants

  1. Identify: Analyze if mutation truly changes observable behavior
  2. Document: Note why mutant is equivalent
  3. Accept: 100% mutation score may not be achievable
  4. Consider refactoring: Sometimes equivalent mutants indicate unclear code

Branch Analysis Checklist

When analyzing code changes on a branch:

For Each Function/Method Changed:

  • [ ] Arithmetic operators: Would changing +, -, *, / be detected?
  • [ ] Conditionals: Are boundary values tested (>=, <=)?
  • [ ] Boolean logic: Are all branches of &&, || tested?
  • [ ] Return statements: Would changing return value be detected?
  • [ ] Method calls: Would removing or swapping methods be detected?
  • [ ] String literals: Would empty strings be detected?
  • [ ] Array operations: Would empty arrays be detected?

Red Flags (Likely Surviving Mutants):

  • [ ] Tests only verify "no error thrown"
  • [ ] Tests only check one side of a condition
  • [ ] Tests use identity values (0, 1, empty string)
  • [ ] Tests only verify function was called, not with what
  • [ ] Tests don't verify return values
  • [ ] Boundary values not tested

Questions to Ask:

  1. "If I changed this operator, would a test fail?"
  2. "If I negated this condition, would a test fail?"
  3. "If I removed this line, would a test fail?"
  4. "If I returned early here, would a test fail?"

Strengthening Weak Tests

Pattern: Add Boundary Value Tests

// Original weak test
it('validates age', () => {
  expect(isAdult(25)).toBe(true);
  expect(isAdult(10)).toBe(false);
});

// Strengthened with boundary values
it('validates age at boundary', () => {
  expect(isAdult(17)).toBe(false);  // Just below
  expect(isAdult(18)).toBe(true);   // Exactly at boundary
  expect(isAdult(19)).toBe(true);   // Just above
});

Pattern: Test Both Branches of Conditions

// Original weak test - only tests one branch
it('returns access result', () => {
  expect(canAccess(true, true)).toBe(true);
});

// Strengthened - tests all meaningful combinations
it('grants access when admin', () => {
  expect(canAccess(true, false)).toBe(true);
});

it('grants access when owner', () => {
  expect(canAccess(false, true)).toBe(true);
});

it('denies access when neither', () => {
  expect(canAccess(false, false)).toBe(false);
});

Pattern: Avoid Identity Values

// Weak - uses identity values
it('calculates', () => {
  expect(multiply(10, 1)).toBe(10);  // x * 1 = x / 1
  expect(add(5, 0)).toBe(5);         // x + 0 = x - 0
});

// Strong - uses values that reveal operator differences
it('calculates', () => {
  expect(multiply(10, 3)).toBe(30);  // 10 * 3 != 10 / 3
  expect(add(5, 3)).toBe(8);         // 5 + 3 != 5 - 3
});

Pattern: Verify Side Effects

// Weak - no verification of side effects
it('processes order', () => {
  processOrder(order);
  // No assertions!
});

// Strong - verifies observable outcomes
it('processes order', () => {
  processOrder(order);
  expect(orderRepository.save).toHaveBeenCalledWith(order);
  expect(emailService.send).toHaveBeenCalledWith(
    expect.objectContaining({ to: order.customerEmail })
  );
});

Integration with Stryker (Optional)

For automated mutation testing, use Stryker:

Installation

npm init stryker

Configuration (stryker.conf.json)

{
  "testRunner": "jest",
  "coverageAnalysis": "perTest",
  "reporters": ["html", "clear-text", "progress"],
  "mutate": ["src/**/*.ts", "!src/**/*.test.ts"]
}

Running

npx stryker run

Incremental Mode (for branches)

npx stryker run --incremental

Summary: Mutation Testing Mindset

The key question for every line of code:

"If I introduced a bug here, would my tests catch it?"

For each test, verify it would catch:

  • Arithmetic operator changes
  • Boundary condition shifts
  • Boolean logic inversions
  • Removed statements
  • Changed return values

Remember:

  • Coverage measures execution, mutation testing measures detection
  • A test that doesn't make assertions can't kill mutants
  • Boundary values are critical for conditional mutations
  • Avoid identity values that make operators interchangeable

Quick Reference

Operators Most Likely to Have Surviving Mutants

  1. >= vs > (boundary not tested)
  2. && vs || (only tested when both true/false)
  3. + vs - (only tested with 0)
  4. * vs / (only tested with 1)
  5. some() vs every() (only tested with all matching)

Test Values That Kill Mutants

AvoidUse Instead
0 (for +/-)Non-zero values
1 (for */)Values > 1
Empty arraysArrays with multiple items
Identical values for comparisonsDistinct values
All true/false for logical opsMixed true/false

平台分布

Codex

38.96%
按下载量换算37

Claude

28.32%
按下载量换算27

Cursor

19.25%
按下载量换算18

Gemini CLI

10.25%
按下载量换算10

安全审计

暂无安全审计结果可展示。

权限和风险

权限未标注

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills