一键导入
phase-build
Use when entering Build phase of epic-stage-workflow - guides implementation planning, code writing, and verification
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when entering Build phase of epic-stage-workflow - guides implementation planning, code writing, and verification
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when creating new projects requiring structured phased development, bootstrapping epic/stage hierarchy, creating new epics, or creating new stages.
Use when implementing or working on existing epics and stages, after running /next_task, during Design/Build/Refinement/Finalize phases, or when session protocols apply.
Use when reviewing learnings and journal entries to identify improvement opportunities across skills, documentation, and processes
Use when entering Design phase of epic-stage-workflow - guides task discovery, context gathering, and approach selection
Use when entering Finalize phase of epic-stage-workflow - guides code review, testing, documentation, and final commits
Use when entering Refinement phase of epic-stage-workflow - guides user testing, feedback incorporation, and iteration
| name | phase-build |
| description | Use when entering Build phase of epic-stage-workflow - guides implementation planning, code writing, and verification |
The Build phase implements the selected approach from Design. It creates working code that can be tested in Refinement.
epic-stage-workflow skill has been invoked (shared rules loaded)Problem: Planner output doesn't automatically transfer to implementer subagents. Main agent context is NOT inherited by subagents.
Required workflow:
Planner/planner-lite agents MUST:
TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S) - NEVER estimate/tmp/spec-$TIMESTAMP.mdMain agent MUST:
Implementer agents (scribe/fixer) MUST:
CRITICAL: "I can describe the steps clearly" ≠ "Skip planner"
IF you can articulate the implementation steps:
→ Those steps ARE the spec
→ Write them to /tmp/spec-*.md via planner-lite
→ Takes 60 seconds, ensures scribe has written reference
ONLY skip spec file for:
Test: If scribe will use Read/Edit tools → Write a spec file first
CRITICAL: Spec BEFORE implementation. NO exceptions.
CORRECT: planner-lite → spec file → scribe implements spec
WRONG: scribe implements → write spec after "for documentation"
Why this matters:
If you already implemented before reading this:
Rationalizations that don't work:
Scenario: You started with what seemed trivial (no spec needed), but halfway through you realize it's complex.
This is NOT retroactive spec-writing. You're writing a PROSPECTIVE spec for remaining work.
Resolution workflow:
Key distinction:
Escalation triggers (any of these → STOP and write spec):
"Almost done" is NOT an exception:
There is NO completion percentage where you're "too far along" to need a spec.
Explicit examples that do NOT exempt you:
Why late-stage specs matter: A spec written at 99% documents the complexity you discovered. It's a "complexity warning label" preventing future developers from assuming the task was trivial.
IF YOU ALREADY IMPLEMENTED BEFORE READING THIS SKILL:
This is a sunk cost situation. The time spent is gone whether you keep or redo the code.
Correct recovery path:
DO NOT:
1. [CONDITIONAL: Planning]
IF complex multi-file feature OR architectural change:
→ Delegate to planner (Opus) for detailed implementation spec
→ Planner MUST save spec to /tmp/spec-YYYY-MM-DD-HH-MM-SS.md
ELSE IF simple single-file OR straightforward change:
→ Delegate to planner-lite (Sonnet) for simple spec
→ Planner-lite MUST save spec to /tmp/spec-YYYY-MM-DD-HH-MM-SS.md
ELSE (trivial change):
→ Skip planner, main agent instructs scribe directly (no spec file needed)
2. Delegate to scribe (Haiku) to write code from spec file
→ Pass spec file path explicitly: "Read and implement: /tmp/spec-YYYY-MM-DD-HH-MM-SS.md"
3. Add seed data if agreed in Design phase
4. Add placeholder stubs for related future features
5. Verify dev server works - feature must be testable
6. [PARALLEL] Delegate to verifier (Haiku) + tester (Haiku)
Run build/lint/type-check AND tests in parallel
7. [IF verification fails] → Error handling flow (see epic-stage-workflow)
8. [LOOP steps 2-7 until green]
9. Delegate to doc-updater (Haiku) to update tracking documents:
- Mark Build phase complete in STAGE-XXX-YYY.md
- Update stage status in epic's EPIC-XXX.md table (MANDATORY)
Use planner (Opus) when ANY of these apply:
CRITICAL: "Requirements are clear" does NOT mean "use planner-lite"
Example of Opus-level complexity:
Example of Sonnet-level simplicity:
Skip planner when:
Trivial ONLY includes:
NOT trivial (requires planner-lite at minimum):
Test: Would verifier/tester need to run? → Not trivial → Write spec
When implementing scaffolding or stub stages (stages that create structure for future work):
If you're adding code that will be used in a future stage, add an explicit comment:
// SCAFFOLDING: Used in STAGE-003-002 for entity selection
onSelect?: (entity: Entity) => void;
// STUB: Real implementation in STAGE-006-001
export function processRequest(): void {
// Placeholder - validates integration shape only
return;
}
Why this matters:
For props/parameters needed later:
// Used in [STAGE-ID]: [brief purpose]
onSelect?: (id: string) => void;
For stub implementations:
// STUB: Real implementation in [STAGE-ID]
// Current behavior: [what it does now]
// Future behavior: [what it will do]
For scaffolding structure:
// SCAFFOLDING: Framework for [feature] implemented in [STAGE-ID]
// SCAFFOLD TEST: Validates integration shape only
// Real behavior tests added in STAGE-006-001
Code reviewers should:
Before completing Build phase, verify:
IF USER SAYS: "We're behind schedule" / "Just ship it" / "Go fast" / "Skip the formality"
YOU MUST STILL:
Time pressure is not a workflow exception. Fast delivery comes from efficient subagent coordination, not from skipping safety checks. Exit gates take 2-3 minutes total.
Before exiting Build phase, run full test suite to detect pre-existing failures:
Why this matters:
Workflow:
npm test (or project equivalent)Common rationalizations (and counters):
| Rationalization | Reality |
|---|---|
| "Tests passed incrementally, no need for full run" | Incremental tests only cover changed code. Pre-existing failures in other areas remain hidden. |
| "Pre-existing failures can be fixed in Finalize" | Finalize is for verification, not debugging. Discovering 8+ failures during Finalize causes cascading fix-verify cycles. |
| "Not my code, not my problem" | Per CLAUDE.md: "Pre-existing failures that block verification are your responsibility to fix." |
| "This will delay Build completion" | Fixing now (5-10 minutes) prevents Finalize thrash (30+ minutes). Net time savings. |
Exit criteria:
Expected outcome:
Finalize phase becomes pure verification (run tests, commit, done) instead of debugging session. Pattern: "Finalize takes 5 minutes, not 30+."
CRITICAL: Before ANY exit gate steps, verification MUST be fully green.
Run verifier (Haiku) and confirm:
If this stage or any recent stage modified:
BEFORE declaring Build complete, you MUST:
Run pnpm type-check across ALL packages (not just packages you touched)
Search for stale test mocks/fixtures:
# Find mock objects that may reference the changed type
grep -r "mockEntity\|entityMock\|createEntity" packages/*/src/**/*.test.* --include="*.ts" --include="*.tsx"
Verify mocks include new required fields:
field?: Type) may still type-check with old mocksWhy this matters:
Common Rationalizations (All Invalid):
| Rationalization | Reality |
|---|---|
| "Verifier returned green" | Verifier checks touched packages. Other packages may have stale mocks. |
| "It's an optional field" | Optional fields type-check, but mocks should reflect realistic data. |
| "Tests are passing" | Tests pass with incomplete mock data. Doesn't mean mocks are correct. |
| "I only touched backend" | Frontend tests may mock backend types. Check ALL packages. |
| "This is a documentation-only stage" | Schema changes from recent stages affect all packages. Run full verification. |
If verifier returns ANY errors or warnings:
Type errors accumulate exponentially. 1 skipped verification = 9x cleanup in next stage.
There is NO "override" status. Either fully green or phase is blocked.
When encountering errors during Build phase, select the appropriate debugger:
| Error Type | Start With | Escalate To |
|---|---|---|
| Runtime errors (null ref, type errors at runtime) | debugger-lite (Sonnet) | - |
| Test failures with clear stack traces | debugger-lite (Sonnet) | debugger if 2+ attempts fail |
| Build/compilation errors | debugger (Opus) | - |
| Toolchain issues (bundler, transpiler, loader) | debugger (Opus) | - |
| Module resolution / import errors | debugger (Opus) | - |
| CI/environment configuration | debugger (Opus) | - |
Escalation trigger: If debugger-lite fails to identify root cause after 2 attempts, escalate to debugger (Opus).
Common Rationalizations (All Invalid):
| Rationalization | Reality |
|---|---|
| "Config errors are straightforward" | Toolchain subtleties (path resolution, loader config) need Opus-level reasoning |
| "Module resolution is just config" | Bundler/transpiler interactions are complex - use Opus |
| "I'll try debugger-lite one more time" | After 2 failures, escalate - more of the same won't work |
| "Opus is overkill" | Wasted cycles with wrong agent costs more than using Opus upfront |
Pattern from journal: debugger-lite missed compiler/tooling issues that required Opus-level analysis.
Discovery: You run verifier and find errors that existed before your work started.
Identification: Use git blame on error locations to confirm they pre-date your branch.
Options (choose ONE):
Fix now (recommended):
Document + Block (if fix requires architectural changes):
// TODO: [ERROR] Inherited from STAGE-XXX-XXX [brief description]
// Requires [architectural change] - blocked on [dependency]
NOT an option:
Reality: You inherit the debt when you touch the code. Fix it or block completion.
Watch for these thought patterns - they ALL lead to technical debt:
| Rationalization | Reality |
|---|---|
| "These are just test errors" | Test errors become production errors. Fix tests. |
| "Pre-existing, not my problem" | You inherited the debt. Fix it or block completion. |
| "Feature works, verification is bureaucracy" | 1 skip = 9x cleanup in next stage. Verification saves time. |
| "Warnings aren't errors" | Warnings accumulate. Treat as errors or they multiply. |
| "Authority says it's fine" | Authority can defer technical debt, not override it. Still needs TODO + tracking. |
| "I'm 90% done, verification would restart me" | Incomplete work + broken verification = 0% done. Run verifier. |
| "My code passes, these are someone else's errors" | Your stage, your responsibility. Fix or block. |
| "I can add @ts-ignore to make it green" | Suppression hides bugs. Fix the error, don't silence it. |
| "I'll .skip the failing tests" | Skipped tests don't pass. They hide failures. Fix or block. |
Once verification is fully green with zero errors and warnings, complete these steps IN ORDER:
lessons-learnedjournalWhy this order?
Lessons and journal need the full phase context, including final status updates. Running them before status updates means they lack complete information.
After completing all exit gate steps, use Skill tool to invoke phase-refinement to begin the next phase.
DO NOT skip any exit gate step. DO NOT proceed until all steps are done.
DO NOT proceed to Refinement phase until exit gate is complete. This includes:
Complete ALL exit gate steps FIRST. Then invoke phase-refinement.