--- name: test-gate description: MR 创建前的硬闸门。子会话跑 scripts/test.sh 全量测试,绿则进入 module-report,红则停下并按失败类型引导用户。 user-invocable: false allowed-tools: Read Write Skill Agent Bash(git add *) Bash(git commit *) --- **所有输出必须使用中文。** # test-gate 模块所有 REQ 完成后的硬闸门:子会话跑 `./scripts/test.sh`(含本模块新增 + 已合并模块回归),按模板渲染证据并 commit 到 module 分支。绿色继续,红色停下,按失败类型给用户恢复路径。 ## 执行步骤 1. 派发 Agent 子会话(general-purpose)运行 `./scripts/test.sh`,子会话只返回结构化 JSON(不输出描述文字): ```json { "command": "./scripts/test.sh", "exit_code": , "passed": , "failed": , "stdout_excerpt": "<最后 30 行,含 FAIL 摘要>" } ``` 2. 按 `${CLAUDE_SKILL_DIR}/templates/test-gate-result-template.md` 渲染证据,写入 `docs/superpowers/module-reports/-test-gate.md`。 3. Commit evidence 到 module 分支(保证证据随 MR 合并进默认分支可审计): ```bash git add docs/superpowers/module-reports/-test-gate.md git commit -m "chore(): add local test-gate evidence" ``` 4. **`exit_code = 0`** → 调用 `Skill(module-report)`。 5. **失败** → 打印以下横幅并停止,不调用下游 skill;不自动重试、不自动修复(失败分类需人工判断): ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [test-gate] ⚠️ 未通过 失败清单: <子会话 JSON 的 failed 摘要> 详细证据: docs/superpowers/module-reports/-test-gate.md 按失败类型选恢复路径: ① 测试脆弱(偶发 flakey)→ 重跑 /erp-workflow:coding-start (module-start 幂等:reviews 已全 approve 会跳过功能循环,直接重跑本闸门) ② 真有回归(某 REQ 破坏其它 REQ 或已合并模块) → rm docs/superpowers/reviews/*-.md → 重跑 /erp-workflow:coding-start(module-start 视该 REQ 未完成,重走功能循环) ③ 环境/依赖问题(DB 连不上 / 外部 API 失败 / 证书失效) → Skill(interrupt-check) 追加 Blocker 到任一 plan 文件 → 修复环境 → 重跑 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ``` ## 护栏 - **绝不**在主会话直接执行 `./scripts/test.sh`,必须通过子会话 - **绝不**通过 `git push --no-verify` 绕过(hook `deny-no-verify.sh` 会硬拦) ## 参考 - `${CLAUDE_SKILL_DIR}/templates/test-gate-result-template.md` - 上游:`module-start`(本模块 REQ 全 approve 后派发到此) - 下游:`module-report`(绿色时)