with one click
forge-test
// Three-layer verification engine running property tests, unit tests, and integration smoke tests. Use when user runs `/forge test` / after build completes / needs verification that behavior matches the locked spec.
// Three-layer verification engine running property tests, unit tests, and integration smoke tests. Use when user runs `/forge test` / after build completes / needs verification that behavior matches the locked spec.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | forge-test |
| description | Test behavior against the locked spec through property tests, unit tests, and integration smoke tests. Use when user runs `/forge test`, after build completes, or needs verification that behavior matches the locked spec. |
| skeleton_exempt_legacy | true |
| disable-model-invocation | true |
Trigger: Step 4 of Standard path, Step 6 of Full path, or user input
/forge testResponsibility: Systematic three-layer verification ensuring code passes at unit test, browser QA, and pre-completion checklist levels Output Path:.forge/progress/<topic>.md(update verification status)
/forge test 通过三层验证(单元测试 → 浏览器级 QA → 完成前验证清单)对 build 和 review 阶段的产出进行系统化验证。每一层都有明确的通过标准,最终以 7 项完成前验证清单作为交付门禁。
验证铁律:没有运行验证命令 = 不能声明通过。→ 遵循 CLAUDE.md §2.3 验证铁律。拒绝"应该可以了"、"看起来没问题"、"和之前一样的逻辑"等非验证声明。唯一接受的完成证据是验证命令的实际输出。TDD 验证规则详见 ../forge-build/references/tdd-rules.md。
Not For:
运行项目测试套件(forge_exec + trim fallback),确认 0 failures。未通过 → 报告详情,修复后重跑 /forge test。
仅 Web 项目(检测前端框架/.html/.tsx/.vue 等)。读取 Spec 场景 → 模拟操作 → 截图 → 对比预期。非 Web → 跳过。
职责:逐项检查 7 项完成前验证清单,确保所有交付条件满足。
CI 检查命令优先级:
执行 Layer 3 清单前,读取 .forge/config.md YAML frontmatter 的 ci_check_command 字段:
forge_exec 执行该命令(server-side trimming)。当 MCP 不可用时,回退到 scripts/run-with-trim.sh 或直接执行。覆盖清单项 1-4。从合并输出中提取各项通过/失败状态。forge_exec)。7 项清单:
| # | Item | Method |
|---|---|---|
| 1 | Tests just ran | CI command or separate run |
| 2 | All tests pass | CI output or test output: 0 failures |
| 3 | Type check passes | CI output or tsc --noEmit |
| 4 | Lint passes | CI output or eslint/biome |
| 5 | Acceptance criteria confirmed | Item-by-item vs Spec scenario table |
| 6 | No leftover TODO/FIXME | Scan changed files |
| 7 | Progress updated | All tasks in progress file completed |
任一项未通过 → 报告详情,阻断 ship。
→ 遵循 CLAUDE.md §2.3。核心逻辑:识别命令 → 运行 → 阅读输出 → 验证声明 → 然后才能声明。
| Claim | Required | Not Evidence |
|---|---|---|
| "Tests pass" | Test output: 0 failures | Previous results |
| "Lint clean" | Lint output: 0 errors | Inference |
| "Build succeeds" | Build: exit 0 | Logs look normal |
| "Bug fixed" | Symptom test passes | Code was changed |
| "Requirements met" | Item-by-item comparison | Tests ≠ requirements |
IF 本次执行是从 conversation summary 恢复(上下文压缩后继续),THEN:
正常流程(无 compaction)忽略此段落。
/forge ship阻断条件:Layer 1 未通过 或 Layer 3 任一项未通过。
放行条件:Layer 1 通过 + Layer 3 所有 7 项通过。Layer 2(浏览器级 QA)为辅助验证,不阻断 ship。
.forge/ 目录存在?有代码变更?有测试配置?Skill(skill="forge", args="ship"),不输出确认提示。仅输出 ✅ test 完成 → 自动进入 ship,然后直接调用 Skill(→ 详见 shared/next-step-protocol.md)。未通过 → 停止,输出失败详情。--cli) [R5.1]Flag: /forge test --cli
Triggers CLI/TUI external verification harness. Automatically triggered when:
package.json has non-empty bin field, OR--cli flag is explicitly passed, OR.forge/config.md has cli_harness: trueExecution: delegates to skills/forge-control-cli/ which selects the best available tier (project > cmux > tmux > node-pty). Output written to .forge/findings/<topic>/cli-harness/.
UI variant: /forge test --ui delegates to skills/forge-control-ui/ for web/Electron testing.
| Condition | Handling |
|---|---|
| No test framework | ⚠️ 未检测到测试框架。Layer 1 无法执行 |
| Test timeout (>5 min) | ⚠️ 可能原因:未关闭的异步操作、数据量过大、死循环 |
| Some checklist items unverifiable | Mark as "unverifiable" not "passed", suggest configuring the corresponding tool |
No .forge/ directory | ⚠️ 请先运行 forge init |
$ /forge test
━━━ Layer 1 — 单元测试 ━━━ npx vitest run → 42/42 ✅
━━━ Layer 2 — 浏览器级 QA ━━━ 非 Web 项目,跳过
━━━ Layer 3 — 完成前验证清单 ━━━ ✅ 1-7 全部通过
✅ 验证通过 → /forge ship
Failing variant: Layer 1 → 2 failed · 列出失败测试名 · ❌ 修复后重跑 /forge test。
| 合理化 | 反驳 |
|---|---|
| "测试通过了就不测了" | 通过不代表覆盖所有场景,边界条件和集成路径常被遗漏 |
| "这个改动很小,不需要测试" | 小改更容易引入意外副作用,轻量路径也要求验证 |
| "CI 会帮我测" | CI 是最终验证不是开发反馈,本地快速验证能节省大量时间 |