flowchart TD
DEV([Developer
Terminal + tmux]) -->|"/plan_to_build_v2
'add feature X'"| PTB
DEV -->|"/build_v2 specs/plan.md"| BUILD
subgraph PLAN_PHASE ["Plan Creation — plan_to_build_v2.md"]
PTB["Analyze codebase directly
no subagents — understand patterns"] --> DESIGN
DESIGN["Design solution
task type · complexity
architecture decisions"] --> TEAM_COMP
TEAM_COMP["Compose team from agents/team/*.md
builder count · workstream split
every task MUST have Assigned To"] --> WRITE_SPEC
WRITE_SPEC["Write exhaustive spec to specs/*.md
task IDs · deps · full descriptions
Assigned To = Team Member name"] --> HOOK_STOP
HOOK_STOP["Stop hook fires
validate_new_file.py
validate_file_contains.py
7 required sections?
file created this session?"]
end
HOOK_STOP -->|"PASS → allow stop
FAIL → block + fix"| REPORT1
REPORT1["Plan report
+ EXECUTION DIRECTIVE
FORBIDDEN: direct implementation
REQUIRED: /build_v2 only"]
REPORT1 -->|"'/build_v2 specs/plan.md'"| BUILD
subgraph BUILD_PHASE ["Build Orchestration — build_v2.md"]
BUILD["Team Lead
reads spec
disallowed: Write, Edit, NotebookEdit"] --> TEAM_CREATE
TEAM_CREATE["TeamCreate
name = plan-YYYYMMDD-HHMM
timestamp prevents collision"] --> TASK_GRAPH
TASK_GRAPH["TaskCreate x N
one per plan task + addBlockedBy deps
auto spec-updater task blocked by all"] --> DEPLOY
subgraph DEPLOY ["Parallel Deploy — run_in_background: true"]
B1["builder-1
standing orders include:
Assigned To: builder-1 filter
poll indefinitely — no retry limit"]
B2["builder-2
Assigned To: builder-2 filter
poll indefinitely — no retry limit"]
VAL_A["validator
on FAIL: names target builder
creates fix task Assigned To: builder-N
sends wakeup via leader"]
SPEC_U["spec-updater
runs last — blocked by all
re-runs commands
writes Build Evidence to spec"]
end
DEPLOY --> MONITOR
MONITOR["Team Lead monitors
receives SendMessage reports
tracks last_seen per agent
does NOT poll — event-driven"]
MONITOR -->|"Validation FAILED
fix_cycle less than 2"| FIX_TASK
FIX_TASK["validator names builder:
fix task Assigned To: builder-N
leader sends wakeup to builder-N
builder re-checks immediately"]
FIX_TASK -->|"builder wakes and claims"| DEPLOY
MONITOR -->|"FAILED max cycles"| ESCALATE
ESCALATE["Escalate to user
collect failure details
do NOT create more fix tasks"]
MONITOR -->|"agent silent 10+ min"| LIVENESS
LIVENESS["Leader pings agent
no response in 2 min?
Escalate: agent hung on task-ID
await user decision"]
end
BUILD_PHASE --> SHUTDOWN
SHUTDOWN["SendMessage shutdown_request
to all agents
wait shutdown_response
TeamDelete"] --> BUILD_REPORT
BUILD_REPORT["Build Report
agents · tasks · assigned vs actual owner
validation results · fix cycles
spec evidence · files changed"]
subgraph HOOKS ["Hooks — Python via uv run"]
H1["PreToolUse — 7 guards
dangerous cmd · team lead writes · team before tasks
plan format · task quality · merge gate · branch discipline"]
H2["PostToolUse
enforce_test_evidence · validate_bug_report
validate_pr_test_evidence"]
H3["Stop
validate_new_file.py + validate_file_contains.py
blocks if spec incomplete"]
H4["Session lifecycle
SessionStart: load CONTEXT.md
SubagentStart/Stop: audit log"]
end
style DEV fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style PLAN_PHASE fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style PTB fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style DESIGN fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style TEAM_COMP fill:#edf2fb,stroke:#2a5fa5,color:#1a1a1a
style WRITE_SPEC fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style HOOK_STOP 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 TEAM_CREATE fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style TASK_GRAPH fill:#f3f0fa,stroke:#6450b4,color:#1a1a1a
style DEPLOY fill:#f0ecfc,stroke:#6450b4,color:#1a1a1a
style B1 fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style B2 fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style VAL_A fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style SPEC_U fill:#f0ecfc,stroke:#2d7a4f,color:#7a7468
style MONITOR fill:#fdf6e3,stroke:#b08a2e,color:#1a1a1a
style FIX_TASK fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style LIVENESS fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style ESCALATE fill:#fdf0ec,stroke:#c84b2f,color:#1a1a1a
style SHUTDOWN fill:#eef7f1,stroke:#2d7a4f,color:#1a1a1a
style BUILD_REPORT 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
style H4 fill:#fdf6e3,stroke:#b08a2e,color:#7a7468