Token导航 LogoToken导航TokenDH.com
开发执行命令github未标认证来源可访问clear审计异常

mutation-testing突变测试

Agent Skill

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

总安装

235

周安装

10

GitHub Stars

19

下载量

82
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 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

简介

用于辅助测试设计与自动化验证,支持突变测试用例生成。

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

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

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

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 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills