mutation-testing by jwilger/agent-skills
npx skills add https://github.com/jwilger/agent-skills --skill mutation-testing价值: 反馈 —— 变异测试通过证明测试确实能检测出它们声称要预防的缺陷,从而闭合了验证循环。没有它,通过的测试可能会提供虚假的信心。
教导代理在创建 PR 前运行变异测试作为质量门禁。变异测试对生产代码进行微小更改(变异),并检查测试是否能捕获这些更改。存活下来的变异体揭示了可能隐藏未被发现的缺陷的空白区域。要求的变异体杀死率是 100%。
检测项目类型并运行适当的变异测试工具。
检查项目标识符:
Cargo.toml -> Rust -> cargo mutantspackage.json -> TypeScript/JavaScript -> npx stryker runpyproject.toml 或 setup.py -> Python -> mutmut run广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
mix.exs -> Elixir -> mix muzak验证工具是否已安装。如果未安装,提供安装说明:
cargo install cargo-mutantsnpm install --save-dev @stryker-mutator/corepip install mutmut{:muzak, "~> 1.0", only: :test} 添加到 deps针对相关范围运行变异测试。尽可能优先限定在更改的文件或包,而不是整个代码库:
cargo mutants --package <package> --jobs 4
# TypeScript
npx stryker run
# Python (限定到源代码)
mutmut run --paths-to-mutate=src/
mutmut results
# Elixir
mix muzak
从变异工具输出中提取:
对于每个存活变异体,报告三件事:
+ 替换为 -”)常见的变异类型及其存活所表明的问题:
+ -> -, * -> /):计算未验证> -> >=, == -> !=):边界条件未测试&& -> ||, ! 被移除):逻辑分支未覆盖true -> false, Ok -> Err):返回路径未检查在推荐任何针对存活变异体的测试之前,检查场景覆盖:
对于每个存活变异体:
步骤 1 — 场景检查: 是否有任何验收场景或领域场景(来自切片的 acceptance_scenarios 或 domain_scenarios 数组,或计划的“已确认场景”部分)需要被变异的行为?
是 → 存在场景但其测试缺失。继续下面的“推荐缺失的测试”。
否 → 标记为需要人工决策:
位于 [file]:[line] 的存活变异体没有 GWT 场景需要此行为。
选项: (a) 删除代码 —— 此行为可能不需要。 (b) 添加缺失的验收或领域场景 —— 规格说明不完整。 100% 的杀死率仍然适用;这明确了如何解决它。
对于未覆盖的变异体,不要继续到测试推荐。在没有场景的情况下编写测试,只是为了满足指标而测试,并没有测试真实行为。
对于每个有覆盖场景的存活变异体,建议一个具体的测试:
存活: src/money.rs:45 -- 在 Money::add() 中将 `+` 替换为 `-`
推荐: 测试 Money(50) + Money(30) 等于 Money(80),
而不是 Money(20)。当前测试未断言总和值。
存活: src/account.rs:78 -- 在 check_balance() 中将 `>` 替换为 `>=`
推荐: 测试精确边界 —— 余额恰好为零时的 check_balance。
当前测试仅检查正数和负数。
变异测试完成后,生成一个 MUTATION_RESULT 证据包:
{
"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"
}
PASS,否则为 FAIL.factory/audit-trail/slices/<slice-id>/mutation.json要求的变异体杀死率是 100%。所有变异体必须被杀死。
应做:
不应做:
当由流水线编排器调用时:
FAIL 裁决会自动路由回 tdd 技能,并附上存活变异体列表。流水线处理此返工路由 —— 变异测试仅报告结果。MUTATION_RESULT 包中的存活变异体详细信息必须足够具体(文件、行号、变异类型、描述),以便 TDD 对编写针对性测试,而无需重新运行变异工具来理解失败原因。mutation.json。硬性约束:
[H],独立模式下为 [RP](阻止 PR,用户可以用记录的原因覆盖)有关覆盖文档要求,请参阅模板目录中的 CONSTRAINT-RESOLUTION.md。
完成变异测试后,验证:
如果任何标准未满足,在继续之前重新审视相关实践。
此技能可独立工作,但作为 PR 前的质量门禁最有价值。它与以下集成:
缺少依赖项?使用以下命令安装:
npx skills add jwilger/agent-skills --skill tdd
每周安装次数
83
仓库
GitHub 星标数
2
首次出现
2026年2月12日
安全审计
安装于
claude-code74
cursor69
codex69
github-copilot67
amp67
kimi-cli67
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.
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%.
Detect the project type and run the appropriate mutation testing tool.
Check for project markers:
Cargo.toml -> Rust -> cargo mutantspackage.json -> TypeScript/JavaScript -> npx stryker runpyproject.toml or setup.py -> Python -> mutmut runmix.exs -> Elixir -> mix muzakVerify the tool is installed. If not, provide installation instructions:
cargo install cargo-mutantsnpm install --save-dev @stryker-mutator/corepip install mutmut{:muzak, "~> 1.0", only: :test} to depsRun mutation testing against the relevant scope. Prefer scoping to changed files or packages rather than the entire codebase when possible:
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
Extract from the mutation tool output:
For each surviving mutant, report three things:
+ with -")Common mutation types and what survival indicates:
+ -> -, * -> /): Calculations not verified> -> >=, == -> !=): Boundary conditions untested&& -> ||, ! removed): Logic branches not coveredBefore 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.
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.
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"
}
PASS if score is 100% on changed files, FAIL otherwise.factory/audit-trail/slices/<slice-id>/mutation.jsonThe required mutation kill rate is 100%. All mutants must be killed.
Do:
Do not:
When invoked by the pipeline orchestrator:
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.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.mutation.json for that slice.Hard constraints:
[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.
After completing mutation testing, verify:
If any criterion is not met, revisit the relevant practice before proceeding.
This skill works standalone but is most valuable as a pre-PR quality gate. It integrates with:
Missing a dependency? Install with:
npx skills add jwilger/agent-skills --skill tdd
Weekly Installs
83
Repository
GitHub Stars
2
First Seen
Feb 12, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code74
cursor69
codex69
github-copilot67
amp67
kimi-cli67
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
44,900 周安装
chartli:终端数据可视化工具,支持ASCII/Unicode/SVG图表生成
96 周安装
SLO实施指南:定义SLI、SLO与错误预算,实现可衡量的服务可靠性目标
83 周安装
GitNexus 指南:代码智能与影响分析工具,快速理解、调试与重构代码库
119 周安装
Git变更日志生成器:自动将技术提交转为用户友好的发布说明
115 周安装
Chargebee 集成指南:SDK、API 与 Webhook 实现订阅计费
116 周安装
高级 DevOps 工程师工具包 | 生产级 CI/CD、Kubernetes、Terraform、云架构与可观测性
109 周安装
true -> false, Ok -> Err): Return paths not checked