Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问许可证需确认审计通过

mutation-testing突变测试

Agent Skill

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

总安装

2,179

周安装

89

GitHub Stars

2

下载量

705
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/jwilger/agent-skills --skill mutation-testing

简介

mutation-testing 用于辅助测试设计、用例整理和回归验证。

  • 适合编写单元测试、端到端测试或根据失败日志定位问题。
  • 使用时需确认项目测试框架、运行命令和夹具数据。
  • 安装命令:npx skills add https://github.com/jwilger/agent-skills --skill mutation-testing
  • 涉及浏览器或外部服务时应区分本地模拟与生产环境。

SKILL.md

Mutation Testing

Value: Feedback -- mutation testing closes the verification loop by proving that tests actually detect the bugs they claim to prevent. Without it, passing tests may provide false confidence.

Purpose

Teaches the agent to run mutation testing as a quality gate before PR creation. Mutation testing makes small changes (mutations) to production code and checks whether tests catch them. Surviving mutants reveal gaps where bugs could hide undetected. The required mutation kill rate is 100%.

Practices

Detect and Run the Right Tool

Detect the project type and run the appropriate mutation testing tool.

  1. Check for project markers:

- Cargo.toml -> Rust -> cargo mutants - package.json -> TypeScript/JavaScript -> npx stryker run - pyproject.toml or setup.py -> Python -> mutmut run - mix.exs -> Elixir -> mix muzak

  1. Verify the tool is installed. If not, provide installation instructions:

- Rust: cargo install cargo-mutants - TypeScript: npm install --save-dev @stryker-mutator/core - Python: pip install mutmut - Elixir: add {:muzak, "~> 1.0", only::test} to deps

  1. Run mutation testing against the relevant scope. Prefer scoping to changed files or packages rather than the entire codebase when possible: # Rust (scoped to package) cargo mutants --package <package> --jobs 4 # TypeScript npx stryker run # Python (scoped to source) mutmut run --paths-to-mutate=src/ mutmut results # Elixir mix muzak

Parse and Report Results

Extract from the mutation tool output:

  • Total mutants generated
  • Mutants killed (tests detected the change)
  • Mutants survived (tests did NOT detect the change)
  • Timed-out mutants
  • Mutation score percentage

Analyze Surviving Mutants

For each surviving mutant, report three things:

  1. Location: File and line number
  2. Mutation: What was changed (e.g., "replaced + with -")
  3. Meaning: What class of bug this lets through

Common mutation types and what survival indicates:

  • Arithmetic (+ -> -, * -> /): Calculations not verified
  • Comparison (> -> >=, == -> !=): Boundary conditions untested
  • Boolean (&& -> ||, ! removed): Logic branches not covered
  • Return value (true -> false, Ok -> Err): Return paths not checked
  • Statement removal (line deleted): Side effects not asserted

Scenario Coverage Check

Before recommending any test for a surviving mutant, check scenario coverage:

For each surviving mutant:

Step 1 — Scenario check: Does any acceptance scenario or domain scenario (from the slice's acceptance_scenarios or domain_scenarios arrays, or the plan's Confirmed Scenarios sections) require the behavior being mutated?

  • YES → A scenario exists but its test is missing. Proceed to Recommend Missing Tests below.
  • NO → Flag for human decision: Surviving mutant at [file]:[line] has no GWT scenario requiring this behavior. Options: (a) Delete the code — this behavior may not be needed. (b) Add a missing acceptance or domain scenario — the spec is incomplete. The 100% kill rate still applies; this clarifies how to resolve it. Do NOT proceed to test recommendations for uncovered mutants. Writing a test without a scenario games the metric without testing real behavior.

Recommend Missing Tests

For each surviving mutant with a covering scenario, suggest a specific test:

Surviving: src/money.rs:45 -- replaced `+` with `-` in Money::add()
Recommend: Test that adding Money(50) + Money(30) equals Money(80),
           not Money(20). The current tests do not assert the sum value.

Surviving: src/account.rs:78 -- replaced `>` with `>=` in check_balance()
Recommend: Test the exact boundary -- check_balance with exactly zero
           balance. Current tests only check positive and negative.

Structured Output

After mutation testing completes, produce a MUTATION_RESULT evidence packet:

{
  "tool": "cargo-mutants",
  "scope": ["src/money.rs", "src/account.rs"],
  "total_mutants": 42,
  "killed": 40,
  "survived": 2,
  "score": 95.2,
  "survivors": [
    {"file": "src/money.rs", "line": 45, "mutation_type": "arithmetic", "description": "replaced + with -"}
  ],
  "verdict": "FAIL"
}
  • Verdict: PASS if score is 100% on changed files, FAIL otherwise
  • When running in pipeline mode, store to .factory/audit-trail/slices/<slice-id>/mutation.json
  • When running standalone, the output is informational only -- display it and proceed to the quality gate

Enforce the Quality Gate

The required mutation kill rate is 100%. All mutants must be killed.

  • If score is 100%: Report success, proceed to PR creation
  • If score is below 100%: List all survivors with recommendations. Block PR creation with a clear warning. The user may override, but the default is to fix first.

Do:

  • Scope mutation runs to changed code when possible
  • Report survivors with actionable fix recommendations
  • Re-run after fixes to confirm all mutants are now killed
  • Treat timeouts as killed (the mutation broke something)

Do not:

  • Skip mutation testing before PR creation
  • Accept surviving mutants without reporting them
  • Run mutations on the entire codebase when only a module changed
  • Recommend tests for data validation that belongs in domain types

Pipeline Mode

When invoked by the pipeline orchestrator:

  • A FAIL verdict routes automatically back to the tdd skill with the survivor list attached. The pipeline handles this rework routing -- mutation-testing just reports results.
  • Survivor details in the MUTATION_RESULT packet must be specific enough (file, line, mutation type, description) for the TDD pair to write targeted tests without re-running the mutation tool to understand what failed.
  • The pipeline may invoke mutation-testing multiple times per slice; each run overwrites the previous mutation.json for that slice.

Enforcement Note

  • Pipeline mode: Gating. 100% kill rate is a gate -- failing blocks merge.
  • Standalone mode: Advisory. The agent reports but cannot prevent override.

Hard constraints:

  • 100% kill rate: [H] in pipeline mode, [RP] in standalone (block PR, user can override with documented reason)

See CONSTRAINT-RESOLUTION.md in the template directory for override documentation requirements.

Constraints

  • 100% kill rate: 100% means 100%. Not "close enough." Not "98% with justification." The only path below 100% is an explicit user override, which MUST include a documented reason explaining why each surviving mutant is acceptable. "I want to ship" is not a reason. "This mutant tests logging output which is not a business rule" is a reason.
  • "No test without scenario": Writing a test solely to kill a mutant without a corresponding scenario games the metric. The test proves you can kill the mutant, not that the behavior matters. If no scenario covers the behavior, the correct response is to flag the gap for the team -- the missing scenario might reveal a missing requirement.

Verification

After completing mutation testing, verify:

  • Mutation testing tool was run against the relevant scope
  • All surviving mutants are listed with file, line, and mutation type
  • Each survivor checked for scenario coverage before test recommendations
  • Each survivor with a covering scenario has a specific test recommendation
  • Each survivor without a covering scenario is flagged for human decision
  • Mutation score is 100% (or user explicitly chose to override)
  • If fixes were made, mutation testing was re-run to confirm

If any criterion is not met, revisit the relevant practice before proceeding.

Dependencies

This skill works standalone but is most valuable as a pre-PR quality gate. It integrates with:

  • tdd: TDD produces the tests that mutation testing validates; surviving mutants indicate the TDD cycle missed a case
  • code-review: Mutation results inform code review -- reviewers can check that new code has no surviving mutants

Missing a dependency? Install with:

npx skills add jwilger/agent-skills --skill tdd

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.35%
按下载量换算242

Claude

31.39%
按下载量换算221

Cursor

17.1%
按下载量换算121

Gemini CLI

8.72%
按下载量换算61

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

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

来源信息

继续浏览同类 Skills