一键导入
mutant
Run mutant, read mutation reports, fix alive mutations, and verify coverage. Use when running mutation testing or responding to alive mutations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Run mutant, read mutation reports, fix alive mutations, and verify coverage. Use when running mutation testing or responding to alive mutations.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | mutant |
| description | Run mutant, read mutation reports, fix alive mutations, and verify coverage. Use when running mutation testing or responding to alive mutations. |
bin/mutant run, never
bundle exec mutant.bin/mutant run 'Markbridge::Parsers::BBCode::Scanner*') or
--since origin/main. Full runs are for CI.mutant.yml. Two lists matter:
matcher.ignore (whole subjects) and mutation.ignore_patterns
(AST node patterns). Every entry needs an inline comment naming the
surviving mutation and why it cannot be killed — no bare entries.A surviving mutation is an evil: line (evil:SUBJECT:FILE:LINE:ID)
followed by a diff of original vs mutated code. The console shows only
the first mutation per subject; list every alive diff from the latest
run via .mutant/results/*.json:
ruby -rjson -e '
j = JSON.parse(File.read(Dir[".mutant/results/*.json"].max_by { File.mtime(_1) }))
j["subject_results"].each do |sr|
sr["coverage_results"].each do |cr|
next if cr["criteria_result"].values.any? { |v| v == true }
puts sr["identification"], cr["mutation_result"]["mutation_diff"]
end
end'
Timeouts are not failures here: mutations that drop a while body
loop forever and die on the clock — the accepted kill for
non-terminating mutants. Don't add loop-progress guards to appease
them: they cost real time on hot loops and add mutation surface of
their own.
Ask, in this order:
[a], [z], [`], [{] for
an a–z check).expect(x).to be(y)
kills mutants that eq cannot.to_i → Integer() looks equivalent on digit strings but parses
leading zeros as octal and raises — the correct form was
Integer(value, 10, ...), not reverting.#initialize examples for
Foo#initialize). A killing example in the wrong describe block is
invisible to the run — it passes rspec and the mutation stays alive.
Put behavior-pinning examples under the describe of the method they
kill mutations in.send/__send__ to reach private methods
and no test-only subclasses that publicize them. If a mutation is
only observable by calling a private directly, that is what the
ignore list is for.ignore_patterns are global. Scope them by giving locals
unique names (span_end) so a pattern cannot hit unrelated code.COVERAGE=1 bin/rspec
before and after.Test additions and code changes go in separate commits — the killing test first (it must pass against the unmutated code), the simplification second. Tests-only work can be a single commit. Run the full suite before every commit; subject-scoped runs miss cross-cutting consumers.
Lead with the verdict per mutation — killed how, simplified why, or unkillable with the reasoning — so the decision can be reviewed without rereading the diffs. When something is unkillable, say what was tried; that is the evidence the ignore-list comment needs anyway.
Upstream's own playbook: https://github.com/mbj/mutant/blob/main/SKILL.md