/spec-autopilot:autopilot-test-fixfrom spec-autopilot
Use when the user wants to consume the test-rot candidate list at .cache/spec-autopilot/test-rot-candidates.json and generate repair artifacts — deterministic sed-style patches for R1 orphan references and .suggestion.md files (including weak-assertion templates) for the rest. Typical triggers: '/autopilot-test-fix scan', '修复测试腐烂'. Does not directly modify tests/*.sh; application is a separate manual step via apply-fix-patch.sh.
Ships in spec-autopilot. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
autopilot-test-audit 产出的 .cache/spec-autopilot/test-rot-candidates.json<project>/.cache/spec-autopilot/tests-fix-patches/(绝不写入 tests/*.sh).suggestion.md(R5 附弱断言补强模板)/autopilot-test-fix scan — 扫描候选并生成修复产物/autopilot-test-fix apply --patch-id <id> — 应用单个 patch若 .cache/spec-autopilot/test-rot-candidates.json 不存在,提示先执行:
bash ${CLAUDE_PLUGIN_ROOT}/runtime/scripts/detect-test-rot.sh \
--changed-files "<files>" --deleted-files "<files>"
或直接触发 autopilot-test-audit skill。
| Rule | 类型 | 产物 | 说明 |
|---|---|---|---|
| R1 | auto / manual | .R1.patch 或 .suggestion.md | 删除 tests 中对失效脚本 basename 的引用行 |
| R3 | manual | .suggestion.md | 提示该 symbol 已不存在,建议删除 case |
| R4 | manual | .suggestion.md | hook 修改提示对应 test 回归 |
| R5 | manual | .suggestion.md | 弱断言模式 + assert_contains / assert_json_field 补强模板 |
# 扫描生成
bash ${CLAUDE_PLUGIN_ROOT}/runtime/scripts/generate-test-fix-patch.sh \
--candidates-file .cache/spec-autopilot/test-rot-candidates.json \
--output-dir .cache/spec-autopilot/tests-fix-patches/
# 应用 (manual 需 --force-manual)
bash ${CLAUDE_PLUGIN_ROOT}/runtime/scripts/apply-fix-patch.sh \
--index .cache/spec-autopilot/tests-fix-patches/INDEX.json \
--patch-id <id> [--force-manual]
tests/*.sh(测试有断言守护)git stash push -u + git apply --check,失败 git stash pop 回滚.suggestion.md 中的 R5 模板片段:
# 推荐
assert_contains "case 名" "$OUTPUT" "期望子串"
assert_json_field "case 名" "$JSON_OUT" "field" "期望值"
# 避免(恒真模式)
assert_exit "x" 0 0
[ "a" = "a" ]
grep -q . .
详见 references/patch-strategies.md。
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub stoicatom/claude-autopilot --plugin spec-autopilot22 skills in this plugin
/autopilotUse when the user requests an end-to-end spec-driven delivery pipeline (requirements → OpenSpec → implementation → testing → archive); orchestrates Phase 0-7./autopilot-agentsUse when the user wants to discover, install, list, hot-swap, or get recommendations for phase-specific autopilot sub-agents sourced from community catalogs (OMC, Anthropic official, VoltAgent, etc.), or when the autopilot setup flow needs to resolve a missing agent for a given phase./autopilot-dispatchUse when the autopilot orchestrator main thread is about to dispatch a phase-specific sub-agent via the Task tool and needs the JSON envelope contract, explicit path injection, and parameterized prompt templates. Not for direct user invocation; skip when the current context is not the autopilot orchestrator.