Token导航 LogoToken导航

Agent Skill · 开发

mutation-testing(突变测试)

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

mutation-testing 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为执行命令;许可证为 MIT,第三方扫描有未通过项,按安装量在开发类的 21,746 个 Skill 里排第 20,201。

总安装 235周安装 10GitHub Stars 19下载 82核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/roasbeef/claude-files --skill mutation-testing

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于辅助测试设计与自动化验证,支持突变测试用例生成。适合提升代码覆盖率检测精度,识别潜在逻辑漏洞。通过 npx 命令从 claude-files 仓库安装,操作简便。需确认项目是否已配置对应测试框架,避免运行时错误。mutation-testing 属于开发类 Skill,可作为该场景下的辅助能力补充。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

    它需要执行命令,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

mutation-testing 怎么安装?

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

mutation-testing 支持哪些 AI 工具?

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

mutation-testing 需要什么权限?

权限级别是执行命令。安装流程涉及命令执行,可能通过 npx skills add https://github.com/roasbeef/claude-files --skill mutation-testing;npx skills add roasbeef/claude-files --skill "mutation-testing" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

mutation-testing 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

mutation-testing 用的人多吗?

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

mutation-testing 安全吗?

第三方扫描有未通过项,风险较高。除非你确认过源码,否则不建议直接安装到常用环境。

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

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 需要执行命令,装到常用环境前要先评估影响面。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

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

不太适合

  • 不能接受 Skill 在你机器上执行命令的人。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

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

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
mutation-testing

突变测试 · 本页

23519执行命令MIT未通过

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

SKILL.md 原文

Mutation Testing

Mutation testing evaluates test quality by introducing small, deliberate bugs (mutations) into code and checking if tests catch them. This provides a behavioral measure of test effectiveness beyond simple coverage metrics.

Core Concept

Mutation testing workflow:

  1. Generate mutations (small code changes)
  2. Run test suite against each mutation
  3. Classify results:

- Killed: Test fails (good - test caught the bug) - Survived: Test passes (bad - test missed the bug) - Timeout: Test hangs or exceeds time limit

  1. Calculate mutation score: killed / (total - timeouts)
  2. For survived mutants, generate targeted tests

Why mutation testing matters: Tests can achieve 100% line coverage while missing critical bugs. Mutation testing reveals if tests actually verify behavior or just execute code.

When to Use Mutation Testing

Use mutation testing proactively for:

  • After test generation: Validate that newly written tests are effective
  • Mission-critical code: Ensure financial, consensus, or security-critical code has thorough tests
  • PR reviews: Quality gate to prevent merging code with weak tests
  • Refactoring: Verify tests catch regressions before changing code
  • Complex logic: Validate tests for boundary conditions, error handling, state machines

Target mutation scores:

  • Mission-critical code: 90%+
  • Core business logic: 80-90%
  • General code: 70-80%
  • Low-risk code: 60-70%

AST-Based Mutation Generation

This skill uses Go's go/ast and go/parser packages to generate intelligent mutations by analyzing code structure.

Standard Go mutations:

  • Arithmetic operators: +, -, *, /, %
  • Relational operators: <, <=, >, >=, ==,!=
  • Logical operators: &&, ||, negation
  • Conditional boundaries: off-by-one errors
  • Statement removal: delete return, assignment, defer
  • Constant changes: 0, 1, true, false, nil

See mutation_operators.md for complete catalog.

Using the Scripts

All scripts are executable Go programs invoked via shell wrappers.

1. Generate Mutations

~/.claude/skills/mutation-testing/scripts/generate-mutations.sh --file wallet.go --output mutations.json

Analyzes Go source file and generates mutation plan with AST node locations.

2. Run Mutation Tests

~/.claude/skills/mutation-testing/scripts/run-mutation-test.sh --mutation-file mutations.json --mutation-id M0 --package ./internal/wallet --output results/M0.json

Applies specific mutation, runs tests, reports if mutant was killed or survived.

3. Parse Results

~/.claude/skills/mutation-testing/scripts/parse-results.sh --results 'results/*.json' --output report.json

Aggregates mutation results and calculates mutation score.

Integration with Agents

mutation-tester Agent

The mutation-tester agent orchestrates the mutation testing workflow:

  1. Analyzes target code (from git diff or specified files)
  2. Generates intelligent mutations using AST analysis
  3. Runs tests for each mutation in parallel when possible
  4. Identifies surviving mutants and analyzes why tests didn't catch them
  5. Generates targeted tests to kill survivors
  6. Re-runs mutations to verify improvements
  7. Produces detailed mutation report in .reviews/mutations/

test-engineer Integration

After test-engineer generates tests, use mutation testing to validate effectiveness:

User: "Generate tests for CalculateFee function"
[test-engineer creates comprehensive tests]
User: "Run mutation testing to validate"
[mutation-tester verifies test quality]

code-reviewer Integration

Include mutation scores in PR reviews:

User: "/code-review owner/repo#123"
[code-reviewer analyzes changes, invokes mutation-tester]
Review includes: "Mutation score: 82% (18/22 killed), recommend 3 additional tests"

Interpreting Results

High mutation score (>85%)

Tests are thorough and catch most bugs. Focus on surviving mutants if any are high-impact.

Medium mutation score (70-85%)

Tests cover major paths but miss edge cases. Review survivors and add boundary tests.

Low mutation score (<70%)

Significant test gaps. Tests may only verify happy paths. Add error handling, boundary, and negative tests.

Surviving mutants

For each survivor, consider:

  • Equivalent mutant: Mutation doesn't change behavior (can ignore)
  • Missing test: Need test for that code path
  • Weak assertion: Test runs code but doesn't verify output
  • Boundary condition: Need edge case test

Best Practices

Focus on high-impact code: Run mutation testing on critical paths, not trivial getters/setters.

Interpret in context: Mutation score is a signal, not a goal. A 75% score with good tests covering critical paths may be better than 95% with superficial tests.

Handle equivalent mutants: Some mutations don't change behavior (e.g., i++ vs ++i in some contexts). Flag and ignore these.

Mutation testing is not fuzzing: Mutations test if existing tests catch changes. Fuzzing tests if code handles unexpected inputs. Both are valuable but different.

Iterate: Use mutation testing to guide test improvement, not as one-time audit.

Performance: For large codebases, run mutation testing on changed files only (from git diff). Full mutation testing can be done nightly.

Example Workflow

// Original code in wallet.go
func CalculateFee(amount int64) int64 {
    if amount > 1000 {
        return amount / 100
    }
    return 10
}

// Generated mutations:
// M1: amount >= 1000 (boundary condition)
// M2: amount < 1000 (relational flip)
// M3: amount == 1000 (boundary)
// M4: return amount / 10 (arithmetic change)
// M5: return 0 (constant change)

// Existing test
func TestCalculateFee(t *testing.T) {
    fee := CalculateFee(2000)
    assert.Equal(t, 20, fee)
}

// Mutation results:
// M1: SURVIVED - test doesn't check boundary at 1000
// M2: KILLED - test with 2000 fails
// M3: SURVIVED - test doesn't check exact boundary
// M4: KILLED - wrong calculation detected
// M5: KILLED - wrong result detected

// Score: 60% (3/5 killed)
// Generate tests for M1 and M3:

func TestCalculateFee_Boundary(t *testing.T) {
    // Test exact boundary
    assert.Equal(t, 10, CalculateFee(1000))
    // Test just above boundary
    assert.Equal(t, 10, CalculateFee(1001))
}

// Re-run: 100% (5/5 killed)

Troubleshooting

"No mutations generated": Check that file contains mutatable code (not just type definitions or constants).

"All mutants timeout": Tests may be running too slowly or hanging. Check test implementation.

"Mutation score very low": Tests may only check happy paths. Add error cases, boundary tests, and assertions on actual behavior.

"Cannot compile mutated code": Mutation may have violated type constraints. This is a bug in mutation generation - report it.

Further Reading

平台分布

Claude Code

26.68%
按下载量换算22

windsurf

23.37%
按下载量换算19

trae

18.4%
按下载量换算15

OpenCode

11.89%
按下载量换算10

Codex

7.33%
按下载量换算6

Antigravity

3.35%
按下载量换算3

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/roasbeef/claude-files --skill mutation-testing;npx skills add roasbeef/claude-files --skill "mutation-testing" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。

继续浏览同类 Skills