SKILL.md 3.23 KB

name: test-gate description: MR 创建前的唯一硬闸门。子会话执行 scripts/test.sh(setup-test-db.sh 清库后,Spring Boot 启动时 Flyway 自动 apply 当前 sql/migrations/V*.sql),任一失败则停止。 user-invocable: false

allowed-tools: Read Write Skill Agent Bash(git add *) Bash(git commit *)

所有输出必须使用中文。

test-gate

执行步骤

  1. 派发子会话Agent,general-purpose)运行 ./scripts/test.sh
   任务:运行项目本地测试闸门。不要修改任何代码或数据。步骤:
   1. cd 到仓库根目录。
   2. 执行:./scripts/test.sh
   3. 仅返回 JSON:{"command":"./scripts/test.sh","exit_code":<int>,"passed":<int>,"failed":<int>,"stdout_excerpt":"<最后 30 行,包含 FAIL 摘要>"}
   不要输出任何描述性文字。
  1. Read 读取 ${CLAUDE_SKILL_DIR}/templates/test-gate-result-template.md,用结果填充槽位。

  2. 写入 docs/superpowers/module-reports/<module_id>-test-gate.md

3b. commit evidence 到 module 分支(确保 test-gate.md 随 MR 合并进默认分支,审计可追溯):

   git add docs/superpowers/module-reports/<module_id>-test-gate.md
   git commit -m "chore(<module_id>): add local test-gate evidence"
  1. 如果 exit_code = 0 → 交接给 module-report(输出 test-gate: 通过)。

  2. 否则打印以下横幅并停下(不自动重试、不自动修复——失败分类需人工判断):

   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    [test-gate] ⚠️ 未通过

    失败清单: <失败测试清单(来自子会话 JSON)>
    stdout 摘录: <最后 30 行 / FAIL 摘要>
    详细证据: docs/superpowers/module-reports/<module_id>-test-gate.md

    请根据失败类型选择下一步:

    ① 测试脆弱(flakey,偶发)
       → 重新运行 /erp-workflow:coding-start
         (module-start 幂等:reviews 已全 approve 会跳过功能循环,直接重新执行本闸门)

    ② 真有回归(某个 REQ 破坏了其他 REQ/已合并模块)
       → 定位到具体 REQ,删除其 review 记录:
         rm docs/superpowers/reviews/*-<REQ-id>.md
       → 重新运行 /erp-workflow:coding-start
         (module-start 把该 REQ 视为未完成,重走 brainstorm→...→review 循环修复)

    ③ 环境/依赖问题(DB 连不上、外部 API 失败、证书失效)
       → 触发中断 #3(外部接口不可达)
       → 调用 Skill(interrupt-check) 追加 Blocker 到本模块任一 plan 文件
       → 修复环境后重新运行 /erp-workflow:coding-start
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

然后停止,不调用下游 skill(module-report / mr-create)。

护栏

  • 绝不在主会话直接执行 ./scripts/test.sh
  • 绝不通过 git push --no-verify 绕过(hook deny-no-verify.sh 会拦截)。

衔接

立即调用 Skill(module-report) 生成模块报告。

参考

  • ${CLAUDE_SKILL_DIR}/templates/test-gate-result-template.md