Documentation
README
Plan
One chain-starter that folds three phases โ amplify (sharpen the prompt), design (brainstorm and spec the approach), decompose (write the batched task file) โ into a single flow, then stops at a build-location gate (Step 12). Each phase skips itself when the request doesn't need it: a clear task bounces straight to decomposition; an already-structured prompt skips amplify.
Plan never implements. It is thinking, not building โ no source code is written here, and it does not silently chain into /hyperflow:dispatch. The only writes are to .hyperflow/specs/, .hyperflow/tasks/, .hyperflow/features/, .hyperflow/memory/, and (another-session mode) the committed .hyperflow-handoff/ package. When the task file is ready, plan always asks where to build it (this session / another session / stop) โ that gate fires on every run, and the user's choice is the only thing that ever starts a build. It drives Layer 0.5 (Triage), Layer 4 (Brainstorming/Spec), Layer 0 (Project Analysis), Layer 6 (Memory), and Layer 7 (Task Templates).
Plan runs at maximum thinking depth. Engage extended / ultra reasoning across triage, analysis, design, and decomposition โ plan is the chain's one think-heavy front door and pays the reasoning cost once so the build runs faithfully. Every substantive step uses tools (Agents to do the work, Write to persist artefacts); a plan that exists only in chat is a violation.
Every agent runs on the current session model โ there is no model-tier routing and no model configuration. Roles (Classifier, Searcher, Writer, Analyst, Planner, Reviewer) differ by responsibility, not by model.
Iron Rules
- Plan never implements. It always stops at the build-location gate (Step 12) and asks where to build โ this session / another session / stop. It does NOT silently chain into
dispatch. The gate fires every run, even when asession=/commit=/branch=arg was somehow propagated โ never skip it. - Max thinking, always. Run at maximum reasoning depth (ultrathink) through triage, analysis, design, and decomposition. Plan is the one think-heavy phase; do not shortcut the reasoning to save tokens.
- Always produce the artefacts on disk. Every run that reaches decomposition uses tools to
Writethe spec (when the design phase ran) and the task file + briefs. A plan described only in chat โ no.hyperflow/tasks/<slug>.mdwritten โ is a failed run, not a plan. - No code in the design phase. Plan produces a prompt, a spec, and a task file;
dispatchexecutes them. - Author build-ready briefs (
briefs=auto). Every non-trivial sub-task gets a full, self-contained implementation brief at plan time (Step 9c), stored at.hyperflow/tasks/<slug>/T<id>.md. The strong planning model pays the authoring cost once so the build runs faithfully on a cheaper model or a second session โ dispatch transcribes, it doesn't re-derive. Trivial sub-tasks stay terse. - Project rules win on conflict. A rule in
CLAUDE.md/AGENTS.md/.hyperflow/memory/overrides a generic persona standard โ it is the user's explicit instruction. - Economy is mandatory. Amplify enhances to the task's level, never inflates a one-line ask into a spec (rubric dim 8).
- Names responsible specialists; never runs their web-research. The
Responsible specialists:annotation is an announcement โ each specialist's web-research-first pass fires later insidedispatch, not here. - No AI attribution in any prompt, spec, task file, or memory entry โ describe the work, never the author.
- Failure recovery (rule 14). Worker/Reviewer errors, malformed output, and NEEDS_REVISION cadence follow
../hyperflow/failure-recovery.md. Retry โ escalate โ abort. Chain budget: 3 cumulative aborts.
Per-Step Agent Map (DOCTRINE rule 12 + 12.2)
Every substantive step dispatches at least one Agent; trivial steps (ยง12.1) and single-pair atomic steps (ยง12.2.8) run as noted. All roles run on the session model โ the table assigns responsibility, not tier.
| Step | Sub-phase | Workers | Reviewers / decision agents | Notes |
|---|---|---|---|---|
| 0 โ Setup | atomic | โ | โ | Silent: parse flags, set max-thinking. NO startup gate, NO questions |
| 1 โ Triage | atomic | Classifier | Triage Reviewer | P4-skip Reviewer; P3-concurrent with Step 3 |
| 2 โ Amplify (skippable) | atomic | Writer โ rewrite prompt | Reviewer โ 8-dim rubric, one revision | Skips on clear/structured prompt |
| 3 โ Context | 3a + 3b (P1) | Searcher ร2 per sub-phase | Reviewer per sub-phase | 3a surface map ยท 3b semantic + convention scan |
| 4 โ Multi-dim analysis (P4) | 4a + 4b + 4c (P1) | Writer ร1โ2 per sub-phase | Reviewer per sub-phase + Analyst synthesis | Skips when ambiguity < 0.6 โง complexity โ high |
| 5 โ Clarify (gate) | atomic | โ | โ | AskUserQuestion; design path floor 2 ยท bounce path 0โ3 |
| 6 โ Synthesis + approaches (P4) | 6a + 6b | Writer ร1โ2 per sub-phase | Reviewer (batched) | Skips approaches when ambiguity < 0.6 โง complexity โ high |
| 7 โ Design sections (P1+P2) | 7a + 7b + 7c | Writer ร1โ2 per sub-phase (architect authors 7a ยง1/ยง2 on architect-typed / high-complexity / multi-subsystem tasks โ embeds Mermaid graphs; designer authors the visual/experiential decisions on ui/creative-typed tasks โ grounds them in .hyperflow/design/system.md; mobile authors the platform/device decisions on mobile/native-typed tasks โ grounds them in ../hyperflow/mobile.md) |
Reviewer per sub-phase + 1 batched | File-first; one combined approval gate |
| 8 โ Spec finalize | atomic | Writer | Reviewer (final-integration) | Renames draft โ .hyperflow/specs/<slug>.md |
| 9 โ Decompose | 9a + 9b + 9c | Planner ร1 (9a) ยท Searcher ร2 (9b) ยท brief Writer ร1 per non-trivial sub-task (9c) | Reviewer per sub-phase | 9a batch graph โ 9b sizing โ 9c authors a full build-ready brief per non-trivial sub-task (briefs=auto) |
| 10 โ Write task file (P3 w/ 11) | 10a + 10b + 10c | Writer ร2 per sub-phase | Reviewer per sub-phase + 1 final verify | Flat task file or feature/phase tree |
| 11 โ Memory (P3 w/ 10) | atomic | Writer appends | Reviewer dup/contradiction check | Concurrent with Step 10 |
| 12 โ Build-location gate | atomic | โ | โ | AskUserQuestion (ALWAYS fires): this session โ Skill dispatch ยท another session โ write handoff package ยท stop |
Skippable / bounce summary: Step 2 skips for clear prompts; Step 4 and Step 6-approaches are P4-skippable; Step 5 bounces the design phase (Steps 6โ8) entirely when the request is clear, jumping to Step 9. --thorough / depth=max disables P1/P2/P4 (sequential, every step runs, per-section reviewers, standalone final-integration pass added); P3/P5 stay on. No step is a startup gate โ plan asks the user nothing until the Step 5 clarify questions, and the build decision waits until Step 12.
Approval Gates
| Gate | When | Format |
|---|---|---|
| Smart questions | Step 5, design path | AskUserQuestion โ 2โ5 questions (floor 2) |
| Synthesis + approach | Step 6, after batched review | AskUserQuestion โ confirm synthesis ยท pick approach |
| Design section approval | Step 7, one combined gate | AskUserQuestion โ approve all / revise ยงN |
| Build location | Step 12, after the task file is written โ ALWAYS | AskUserQuestion โ this session / another session / stop (+ handoff: review / deploy when another session) |
The build-location gate fires on every run (it is the only thing that ever starts a build); the design-phase gates fire at most once each and are skipped on the bounce path. Plan asks no startup gates โ the session/build decision and the operational choices (commit cadence ยท branch ยท push) are no longer front-loaded. When the user picks "this session," dispatch fires its own operational gate (its Step 0.5) before building. Markers follow DOCTRINE rule 8: multi-option/named-workflow choices carry (Recommended); binary action gates (Approve/Revise) carry none.
Flow
Step 0 โ Setup (silent ยท max thinking ยท NO gate)
Plan asks the user nothing at startup. There is no session-strategy gate and no operational gate here โ both decisions move to the Step 12 build-location gate (and dispatch owns the operational gate when a build actually starts). Defaulting silently is correct: plan is think-only, so there is nothing to decide until a task file exists.
At Step 0, the orchestrator only:
- Engages maximum thinking depth (ultra reasoning) for the whole run โ triage, analysis, design, and decomposition all reason at full depth.
- Parses flags from the args:
--thorough/depth=max(disable P1/P2/P4 โ see the skippable summary),noamplify(skip Step 2),briefs=auto|terse(Step 9c). Record them; do not ask about them. GitHub-native pass-through:gh_issue=/pr=/comment=(set by/hyperflow:issue) andspec=(a pre-built spec path, e.g. from/hyperflow:issueor the audit fix-gate) are recorded verbatim โ plan never acts on them, it forwards them to dispatch at Step 12.
Then proceed straight to Step 1. Any session= / commit= / branch= / push= args that happen to be present are ignored for gating โ the build decision is always made fresh at Step 12.
Step 1 โ Triage (Layer 0.5 ยท P3-concurrent with Step 3)
Step 1 (Classifier) and Step 3 (context Searchers) are independent โ dispatch both in one message, wait for both. Under --thorough, run Step 1 first, then Step 3.
Dispatch Classifier โ triaging request per ../hyperflow/task-triage.md, producing { types[], complexity, risk, scope, ambiguity, flow, personas[], specialists[] }. This drives: the P4 gates (Steps 4/6) and bounce gate (Step 5); the question budget at Step 5 (0.0โ0.5 โ 2, 0.5โ0.8 โ 3, 0.8โ1.0 โ 4โ5); the downstream flow profile (../hyperflow/flow-profiles.md); and persona/specialist stitching. On a gated flow the responsible specialist roster is finalized once via the Brain (DOCTRINE rule 17) and inherited by every later phase. Persist and propagate as triage=<base64-json>.
Triage Reviewer (rule 15). P4-skip when ALL of complexity == low, ambiguity < 0.2, scope โ {0-file, 1-file}, risk != high โ consume the Classifier output as-is and print the skip line. Otherwise dispatch **Triage Reviewer** โ validating classification against request and project profile (reads the request + .hyperflow/profile.md). Verdict โ {PASS, RECLASSIFY (use corrected triage, print one line), ESCALATE (add ambiguity to Step 5's queue)}. On Reviewer error follow failure-recovery ยง5 โ never consume unvalidated triage.
Step 2 โ Amplify / prompt hygiene (atomic ยท skippable)
Skip when ambiguity < 0.4, OR the incoming prompt is already well-structured (role/task/constraints/output present), OR the noamplify flag is set โ print Amplify skipped โ prompt already specific. and proceed to Step 4 with the prompt as-is. Amplify exists to sharpen rough input before design; a sharp prompt gains nothing.
Otherwise a single Writer โ Reviewer pair with a one-shot revision loop:
Writer โ drafting the amplified promptrewrites the raw prompt into its single strongest version following the skeleton inreferences/prompt-rubric.md: role ยท task ยท context ยท constraints (persona doctrine from triagepersonas[]+ project rules) ยท output spec ยท out-of-scope. Economy is a constraint.**Reviewer** โ scoring against the prompt-quality rubricscores all 8 dimensions 1โ5. All โฅ 4 โPASS. Any < 4 โNEEDS_REVISIONwith specifics; the Writer revises once, then ships regardless (no infinite loop). The Reviewer also produces a 2โ4 line rationale naming the domain doctrine and project rules it injected.
The amplified prompt becomes the working prompt for analysis and design. Print it once in a copy-ready block with its rationale + a Responsible specialists: line (omit when no specialist applies).
Step 3 โ Context exploration (P1 sub-phases ยท P3-concurrent with Step 1)
Read .hyperflow/profile.md, architecture.md, conventions.md, .hyperflow/memory/index.md before dispatching to surface past learnings. Sub-phases are independent โ dispatch in one message, run per-sub-phase Reviewers, then advance. No Step-level coverage Reviewer; a downstream Writer flags MISSING CONTEXT: <subsystem> and the orchestrator redispatches the relevant Searcher (max 2 retries). Do not ask the user what the code reveals.
- 3a โ Surface mapping:
Searcher โ glob discovery: file tree + entry points;Searcher โ import-graph traversal: dependency edges. โ**Reviewer**. - 3b โ Semantic + convention scan:
Searcher โ type/symbol probe: interfaces, schemas, call sites, re-exports;Searcher โ test patterns + lint/config: naming, runner, lint rules. โ**Reviewer**.
Step 4 โ Multi-dimensional analysis (P4-skippable)
P4 gate: skip entirely (jump to Step 5) when ambiguity < 0.6 AND complexity != high โ round up on the border (0.59 โ run). --thorough always runs. If run, sub-phases fan out in parallel (P1), then the Analyst aggregates:
- 4a โ Intent + technical-fit:
Writer โ user-intent: real need + successโฅWriter โ technical-fit: how it fits existing architecture. โ**Reviewer**. - 4b โ Scope + risks:
Writer โ scope/constraints: MVP vs max, limitsโฅWriter โ risks: failure modes, irreversibility. โ**Reviewer**. - 4c โ Alternatives:
Writer โ alternatives: โฅ3 distinct solutions, brief notes(single canonical set). โ**Reviewer**. - 4d โ Analyst synthesis (sequential):
**Analyst** โ 6-dimension aggregationconsolidates 4a/4b/4c into the unified brief; unknowns become Step 5 questions.
Step 5 โ Clarify (AskUserQuestion ยท two modes)
Pre-flight: read .hyperflow/memory/project-decisions.md; skip any candidate already answered there (print one line) unless the cached answer conflicts with this task (then ask "decisions say X โ does this task change that?").
Bounce gate (decompose-only path): when ambiguity < 0.4 AND complexity == low, the request is clear โ skip the design phase (Steps 6โ8). Ask 0โ3 post-analysis questions tied to specific findings the Searchers surfaced (no floor โ zero when research is conclusive), then jump to Step 9. Print That's clear enough to skip the design phase โ decomposing directly.
Design path (everything else): ask via AskUserQuestion, floor of 2 questions always (the two minimums give the user a place to redirect even when the request looks unambiguous). Budget by triage depth: light 2 ยท standard 3 ยท deep 4โ5. Never stack more than 2 questions per call. Multi-option lists (3+) mark a (Recommended) choice (the Analyst's leading hypothesis first); binary lists carry no marker. Question order: intent โ constraints โ assumptions โ scope โ edge-case stance (pick the first N for depth N).
After answers, append structural decisions (database, auth, testing, framework defaults) to .hyperflow/memory/project-decisions.md under a category heading with date + source slug โ inline write, ยง12.1-trivial. Skip task-specific answers.
Step 6 โ Synthesis + approaches (P3 + P2 ยท P4-skippable)
Step 5 (synthesis) and 6a both depend on the answers but not on each other โ dispatch concurrently (P3); one batched Reviewer covers both (P2). --thorough runs them sequentially.
- Synthesis:
Writer โ requirement synthesisproduces a one-paragraph "the goal is X, constraints Y, excluding Z." - 6a โ Approach candidates (P4-skip when
ambiguity < 0.6 โง complexity != high):Writer โ lightweight candidatesโฅWriter โ heavyweight candidates. Each approach: Name ยท What ยท Pros ยท Cons ยท Fit. - 6b โ Trade-off eval (sequential on 6a):
Writer โ fit analysisโฅWriter โ risk analysisscoring each candidate.
**Reviewer** โ batched: synthesis + approaches (../hyperflow/reviewer-prompt-batched.md) returns per-draft verdicts; re-dispatch only the failing draft. When 6a/6b are P4-skipped, annotate "Approach: derived from synthesis (ambiguity low)". Then present synthesis + approaches and confirm via AskUserQuestion โ recommend one approach, the choice is the user's.
Step 7 โ Section-by-section design (P1 + P2 ยท file-first ยท one combined gate)
File-first (rule 8): each section Writer writes directly to .hyperflow/specs/<slug>.draft.md at a stable H2 anchor โ never returns content for inline paste. Pre-seed the file with 5 H2 headers before dispatching. Run python3 $PLUGIN_ROOT/scripts/resolve-mode.py $PROJECT_ROOT --from-args "$CHAIN_ARGS" once and propagate mode=<default|lean|thorough> (lean โ workers get the path-only Project Context block per ../hyperflow/worker-prompt-lean.md).
Sub-phases dispatch in ONE parallel message (P1), each with a per-sub-phase Reviewer firing as it returns; then one batched Reviewer (P2) reads all 5 sections for cross-section coherence. Each section Writer records a Responsible specialist(s): line from the Brain-finalized roster, carried into the Step 8 status block.
System-design tasks produce architecture graphs. On architect-typed / high-complexity / multi-subsystem work the architect agent owns ยง1/ยง2 and embeds a Mermaid component/container graph (ยง1) and a Mermaid data-flow diagram (ยง2) directly in the draft โ the diagram precedes the implementation. The Step 7 approval gate already points the user at the draft file, so the graphs are reviewed there with no extra gate.
Design-time consultation. Any decision agent in this phase may consult a peer directly (its own Agent tool, โค 3 consults, depth-1, allowlist = the agents/ registry) per ../hyperflow/consultation.md โ e.g. the architect asks motion whether a proposed interaction is feasible before committing it to ยง2, or the designer asks motion for a motion-heavy screen. Agent-agnostic: future decision agents inherit this without an edit here.
Design-typed tasks ground in the design system. On ui/creative-typed work the designer agent owns the visual/experiential decisions: it first ensures .hyperflow/design/system.md exists (creating it if missing, extending it if present per ../hyperflow/design-system.md), researches โฅ2 real-world references in the project's field and combines them with one deliberate signature, applies the matching local taste skill, and records the bound design-system tokens in ยง3. When a motion surface is in scope (animation / transition / scroll-driven / gesture), the designer brings in the motion agent to author the Motion-language decisions in ยง3 (compositor-only props, library choice, spring params, reduced-motion fallback per ../hyperflow/motion.md) โ composing within ยง3, not a separate section. No source code is written โ only the design system and the spec draft.
Mobile-typed tasks define the platform & device strategy. On mobile / native / responsive-app work the mobile agent authors the mobile decisions โ framework choice + rationale (React Native / Flutter / native iOS / Android), app architecture (navigation / offline-first / lifecycle-aware state), the platform accessibility floor (VoiceOver/TalkBack, 44pt/48dp targets, Dynamic Type), and the device-size test matrix + tooling (Maestro/Detox/XCUITest/Espresso) โ into ยง1 (architecture, composing with the architect) and ยง3 (decisions), grounded in ../hyperflow/mobile.md. No source code