build
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseArguments: $FEATURE
Read CLAUDE.md before doing anything else.
Read the acceptance criteria for "$FEATURE" in docs/PRD.md.
━━━ STEP 1: SPEC AGENT (isolated subagent) ━━━
Spawn a subagent with ONLY this context:
- The acceptance criteria for $FEATURE from PRD.md
- CLAUDE.md (for naming conventions and patterns)
- The relevant wireframe from wireframes/ if a UI feature
Subagent instruction:
"Write failing tests for $FEATURE to:
tests/unit/$FEATURE.test.ts
tests/integration/$FEATURE.integration.test.ts
Tests must be RED. Do not write any implementation code.
Write tests that would pass if the feature worked exactly as described
in the acceptance criteria — not tests that are easy to make pass."
━━━ STEP 2: CONFIRM RED ━━━
Run: npm run test -- $FEATURE
If tests pass (shouldn't happen yet): something is wrong. Inspect and fix.
If tests fail with import errors only: fix imports, this is not real RED.
If tests fail because the feature doesn't exist: this is correct RED. Proceed.
━━━ STEP 3: IMPLEMENT AGENT (fresh subagent, isolated context) ━━━
Spawn a new subagent with ONLY this context:
- The failing test files
- CLAUDE.md
- Relevant wireframe
Subagent instruction:
"The test files contain failing tests for $FEATURE.
Implement the minimum code necessary to make ALL tests pass.
Read CLAUDE.md for patterns and conventions.
Do not add any functionality that is not tested."
━━━ STEP 4: CONFIRM GREEN ━━━
Run: npm run test -- $FEATURE
If GREEN: proceed to refactor.
If RED: spawn FIX AGENT:
"Tests are still failing. Error output: [paste exact output].
Fix the implementation only. Do not change test assertions.
The tests are correct. The implementation is wrong."
Re-run. If still RED after 3 attempts: stop and report the issue.
━━━ STEP 5: REFACTOR ━━━
Spawn REFACTOR AGENT:
"All tests are GREEN for $FEATURE.
Refactor the implementation for clarity, performance, and consistency
with CLAUDE.md patterns.
Tests must remain GREEN after every change.
Run tests after each significant change."
━━━ STEP 6: HAND OFF ━━━
For web applications (UI features), run BOTH:
/test-ui $FEATURE — interactive browser testing via Playwright MCP
/qa-run $FEATURE — full 8-agent QA loop
/test-ui explores the live app and generates initial Playwright test files.
/qa-run then runs the complete QA pipeline including those generated tests.
For non-UI features (API, data layer, utilities):
/qa-run $FEATURE — skip /test-ui, go straight to QA loop
参数:$FEATURE
在执行任何操作前,请先阅读CLAUDE.md。
阅读docs/PRD.md中关于"$FEATURE"的验收标准。
━━━ 步骤1:SPEC AGENT(独立子代理)━━━
生成仅包含以下上下文的子代理:
- 来自PRD.md的$FEATURE验收标准
- CLAUDE.md(用于命名规范和模式)
- 若为UI特性,需包含wireframes/中的相关线框图
子代理指令:
"为$FEATURE编写失败的测试,保存至:
tests/unit/$FEATURE.test.ts
tests/integration/$FEATURE.integration.test.ts
测试必须处于RED状态。请勿编写任何实现代码。
编写的测试应在功能完全符合验收标准描述时通过——而非编写易于通过的测试。"
━━━ 步骤2:确认RED状态 ━━━
运行命令:npm run test -- $FEATURE
若测试通过(此时不应发生):存在问题,请检查并修复。
若测试仅因导入错误失败:修复导入问题,这不属于真正的RED状态。
若测试因特性未实现而失败:这是正确的RED状态,继续执行。
━━━ 步骤3:IMPLEMENT AGENT(全新独立子代理)━━━
生成仅包含以下上下文的新子代理:
- 失败的测试文件
- CLAUDE.md
- 相关线框图
子代理指令:
"测试文件中包含$FEATURE的失败测试。
编写最少必要代码以让所有测试通过。
阅读CLAUDE.md以遵循模式和规范。
请勿添加任何未被测试覆盖的功能。"
━━━ 步骤4:确认GREEN状态 ━━━
运行命令:npm run test -- $FEATURE
若为GREEN状态:进入重构步骤。
若为RED状态:生成FIX AGENT:
"测试仍然失败。错误输出:[粘贴准确输出]。
仅修复实现代码,请勿修改测试断言。
测试是正确的,问题出在实现上。"
重新运行。若3次尝试后仍为RED状态:停止并报告问题。
━━━ 步骤5:重构 ━━━
生成REFACTOR AGENT:
"$FEATURE的所有测试均为GREEN状态。
对实现代码进行重构,提升可读性、性能,并与CLAUDE.md中的模式保持一致。
每次修改后必须保持测试为GREEN状态。
每次重大修改后运行测试。"
━━━ 步骤6:交接 ━━━
对于Web应用(UI特性),同时运行以下两个命令:
/test-ui $FEATURE —— 通过Playwright MCP进行交互式浏览器测试
/qa-run $FEATURE —— 完整的8代理QA循环
/test-ui会探索实时应用并生成初始Playwright测试文件。
/qa-run随后会运行完整的QA流水线,包括这些生成的测试。
对于非UI特性(API、数据层、工具类):
/qa-run $FEATURE —— 跳过/test-ui,直接进入QA循环