flowchart TD
DEV([👤 Developer
VS Code]) -->|"/plan_to_build
'add feature X'"| PWT
DEV -->|"/bug_to_pr
'describe bug'"| BUG
subgraph PREREQ ["🔍 Prerequisites (plan_to_build.prompt.md)"]
PWT["Read codebase
read project.json"] --> BRAIN
BRAIN["Prerequisite 1:
Explore Before Planning
— one question, multiple choice
— technical approach"]
BRAIN --> TEAM_Q
TEAM_Q["Prerequisite 2:
Team Composition
— single / two / three builders?
— workstream split?"]
end
TEAM_Q --> PLAN_WRITE
subgraph PLAN_PHASE ["📋 Plan Creation"]
PLAN_WRITE["Write spec to
specs/*.md
(exhaustive task descriptions)"]
PLAN_WRITE --> VERIFY
VERIFY["Step 8: Self-verify
ls -la specs/file.md
grep -c sections = 7"]
VERIFY --> HOOK_POST
HOOK_POST["postToolUse hook
post_tool_validator.py
— 7 required sections?
— validator frequency?
— ruff / tsc on code files"]
end
HOOK_POST -->|"PASS → continue
FAIL → block + fix"| REPORT1
REPORT1["Plan report
+ EXECUTION DIRECTIVE
in spec file"]
REPORT1 -->|"'execute the plan
in specs/file.md'"| BUILD
subgraph BUILD_PHASE ["⚙️ Build Orchestration (build.prompt.md)"]
BUILD["Orchestrator
reads spec
builds todo list"]
BUILD --> TASK_LOOP
subgraph TASK_LOOP ["Task loop — sequential"]
BLD["runSubagent
'builder'
TDD preamble
+ task description verbatim"]
BLD --> VAL
VAL["runSubagent
'validator'
run commands
PASS / FAIL"]
VAL -->|"PASS"| NEXT["next task"]
VAL -->|"FAIL ≤2"| FIX
FIX["runSubagent
'builder'
DEBUG: reproduce→isolate
→root cause→fix"]
FIX --> VAL
VAL -->|"FAIL >2"| ROLLBACK
ROLLBACK["runSubagent
'builder'
git checkout rollback
log + continue"]
ROLLBACK --> NEXT
NEXT --> BLD
end
TASK_LOOP -->|"every 3 tasks"| CKPT["Checkpoint
report to user
course-correct?"]
CKPT --> TASK_LOOP
end
BUILD_PHASE --> FINAL_VAL
FINAL_VAL["validate-all
runSubagent validator
all commands + criteria
actual output required"]
FINAL_VAL --> DONE["Build Complete
task table
actual command output
files changed"]
subgraph BUG_PIPE ["🐛 Bug-to-PR Pipeline (bug_to_pr.prompt.md)"]
BUG["Phase 0: Setup
BUG-NNN · branch · todo"] --> TRIAGE
TRIAGE["Phase 1: Triage
bug-creator → report.md
bug-router → project.json
routes to module fixer"]
TRIAGE --> FIX2A
FIX2A["Phase 2a: Fix Planning
bug-fixer-{module}
reads report + project.json
writes specs/fix-NNN.md"]
FIX2A --> FIX2B
FIX2B["Phase 2b: Fix Execution
build protocol inline
builder + validator per task
TDD + rollback same as /build"]
FIX2B --> FIX2C
FIX2C["Phase 2c: Test Evidence
run module test command
capture to bugs/NNN/test-results.md"]
FIX2C --> PR_CREATE
PR_CREATE["Phase 3: PR Creation
gh pr create
gh pr comment → bug report
branch: fix/bug-NNN"]
PR_CREATE --> REVIEW
REVIEW["Phase 4: Adversarial Review
reviewer-alpha (isolated)
reviewer-beta (isolated)
hold verdicts in memory"]
REVIEW --> MERGE_GATE
MERGE_GATE["Phase 5: Merge Gate
gh pr review --approve/--request-changes
both approve → ask user
reject → fix cycle ≤2 → retry"]
end
BUG_PIPE --> PR_ARTIFACT["PR Artifact
bug report as comment
alpha verdict as review
beta verdict as review
test evidence committed"]
subgraph HOOKS ["🪝 Hooks — system-enforced (hooks.json)"]
H1["sessionStart
setup.sh
pip install + npm install"]
H2["postToolUse
post_tool_validator.py
ruff / tsc / spec 7 sections
bug report 8 sections
CI bypass flag"]
H3["agentStop
validate_spec.py
7 sections check"]
end
style DEV fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style PREREQ fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style PWT fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style BRAIN fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style TEAM_Q fill:#edf2fb,stroke:#2a5fa5,color:#7a7468
style PLAN_PHASE fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style PLAN_WRITE fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style VERIFY fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style HOOK_POST fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a
style REPORT1 fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style BUILD_PHASE fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a
style BUILD fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a
style TASK_LOOP fill:#f0ecfc,stroke:#6450b4,color:#1a1a1a
style BLD fill:#f0ecfc,stroke:#6450b4,color:#1a1a1a
style VAL fill:#f0ecfc,stroke:#2d7a4f,color:#1a1a1a
style NEXT fill:#f0ecfc,stroke:#6450b4,color:#7a7468
style FIX fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style ROLLBACK fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style CKPT fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a
style FINAL_VAL fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style DONE fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style BUG_PIPE fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style BUG fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style TRIAGE fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style FIX2A fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style FIX2B fill:#f0ecfc,stroke:#6450b4,color:#1a1a1a
style FIX2C fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style PR_CREATE fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style REVIEW fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a
style MERGE_GATE fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a
style PR_ARTIFACT fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style HOOKS fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a
style H1 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468
style H2 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468
style H3 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468