1---2name: plan-23description: Strategic planning with optional interview workflow4---56<Purpose>7Plan creates comprehensive, actionable work plans through intelligent interaction. It auto-detects whether to interview the user (broad requests) or plan directly (detailed requests), and supports consensus mode (iterative Planner/Architect/Critic loop with RALPLAN-DR structured deliberation) and review mode (Critic evaluation of existing plans).8</Purpose>910<Use_When>11- User wants to plan before implementing -- "plan this", "plan the", "let's plan"12- User wants structured requirements gathering for a vague idea13- User wants an existing plan reviewed -- "review this plan", `--review`14- User wants multi-perspective consensus on a plan -- `--consensus`, "ralplan"15- Task is broad or vague and needs scoping before any code is written16</Use_When>1718<Do_Not_Use_When>19- User wants autonomous end-to-end execution -- use `autopilot` instead20- User wants to start coding immediately with a clear task -- use `ralph` or delegate to executor21- User asks a simple question that can be answered directly -- just answer it22- Task is a single focused fix with obvious scope -- skip planning, just do it23</Do_Not_Use_When>2425<Why_This_Exists>26Jumping into code without understanding requirements leads to rework, scope creep, and missed edge cases. Plan provides structured requirements gathering, expert analysis, and quality-gated plans so that execution starts from a solid foundation. The consensus mode adds multi-perspective validation for high-stakes projects.27</Why_This_Exists>2829<Execution_Policy>30- Auto-detect interview vs direct mode based on request specificity31- Ask one question at a time during interviews -- never batch multiple questions32- Gather codebase facts via `explore` agent before asking the user about them33- Plans must meet quality standards: 80%+ claims cite file/line, 90%+ criteria are testable34- Consensus mode outputs the final plan by default; add `--interactive` to enable execution handoff35- Consensus mode uses RALPLAN-DR short mode by default; switch to deliberate mode with `--deliberate` or when the request explicitly signals high risk (auth/security, data migration, destructive/irreversible changes, production incident, compliance/PII, public API breakage)36</Execution_Policy>3738<Steps>3940### Mode Selection4142| Mode | Trigger | Behavior |43|------|---------|----------|44| Interview | Default for broad requests | Interactive requirements gathering |45| Direct | `--direct`, or detailed request | Skip interview, generate plan directly |46| Consensus | `--consensus`, "ralplan" | Planner -> Architect -> Critic loop until agreement with RALPLAN-DR structured deliberation (short by default, `--deliberate` for high-risk); outputs plan by default |47| Consensus Interactive | `--consensus --interactive` | Same as Consensus but pauses for user feedback at draft and approval steps, then hands off to execution |48| Review | `--review`, "review this plan" | Critic evaluation of existing plan |4950### Interview Mode (broad/vague requests)51521. **Classify the request**: Broad (vague verbs, no specific files, touches 3+ areas) triggers interview mode532. **Ask one focused question** using `AskUserQuestion` for preferences, scope, and constraints543. **Gather codebase facts first**: Before asking "what patterns does your code use?", spawn an `explore` agent to find out, then ask informed follow-up questions554. **Build on answers**: Each question builds on the previous answer565. **Consult Analyst** (Opus) for hidden requirements, edge cases, and risks576. **Create plan** when the user signals readiness: "create the plan", "I'm ready", "make it a work plan"5859### Direct Mode (detailed requests)60611. **Quick Analysis**: Optional brief Analyst consultation622. **Create plan**: Generate comprehensive work plan immediately633. **Review** (optional): Critic review if requested6465### Consensus Mode (`--consensus` / "ralplan")6667**RALPLAN-DR modes**: **Short** (default, bounded structure) and **Deliberate** (for `--deliberate` or explicit high-risk requests). Both modes keep the same Planner -> Architect -> Critic sequence. The workflow auto-proceeds through planning steps (Planner/Architect/Critic) but outputs the final plan without executing.68691. **Planner** creates initial plan and a compact **RALPLAN-DR summary** before any Architect review. The summary **MUST** include:70 - **Principles** (3-5)71 - **Decision Drivers** (top 3)72 - **Viable Options** (>=2) with bounded pros/cons for each option73 - If only one viable option remains, an explicit **invalidation rationale** for the alternatives that were rejected74 - In **deliberate mode**: a **pre-mortem** (3 failure scenarios) and an **expanded test plan** covering **unit / integration / e2e / observability**752. **User feedback** *(--interactive only)*: If running with `--interactive`, **MUST** use `AskUserQuestion` to present the draft plan **plus the RALPLAN-DR Principles / Decision Drivers / Options summary for early direction alignment** with these options:76 - **Proceed to review** — send to Architect and Critic for evaluation77 - **Request changes** — return to step 1 with user feedback incorporated78 - **Skip review** — go directly to final approval (step 7)79 If NOT running with `--interactive`, automatically proceed to review (step 3).803. **Architect** reviews for architectural soundness using `ask_codex` with `agent_role: "architect"`. Architect review **MUST** include: strongest steelman counterargument (antithesis) against the favored option, at least one meaningful tradeoff tension, and (when possible) a synthesis path. In deliberate mode, Architect should explicitly flag principle violations. **Wait for this step to complete before proceeding to step 4.** Do NOT run steps 3 and 4 in parallel.814. **Critic** evaluates against quality criteria using `ask_codex` with `agent_role: "critic"`. Critic **MUST** verify principle-option consistency, fair alternative exploration, risk mitigation clarity, testable acceptance criteria, and concrete verification steps. Critic **MUST** explicitly reject shallow alternatives, driver contradictions, vague risks, or weak verification. In deliberate mode, Critic **MUST** reject missing/weak pre-mortem or missing/weak expanded test plan. Run only after step 3 is complete.825. **Re-review loop** (max 5 iterations): If Critic rejects or iterates, execute this closed loop:83 a. Collect all feedback from Architect + Critic84 b. Pass feedback to Planner to produce a revised plan85 c. **Return to Step 3** — Architect reviews the revised plan86 d. **Return to Step 4** — Critic evaluates the revised plan87 e. Repeat until Critic approves OR max 5 iterations reached88 f. If max iterations reached without approval, present the best version to user via `AskUserQuestion` with note that expert consensus was not reached896. **Apply improvements**: When reviewers approve with improvement suggestions, merge all accepted improvements into the plan file before proceeding. Final consensus output **MUST** include an **ADR** section with: **Decision**, **Drivers**, **Alternatives considered**, **Why chosen**, **Consequences**, **Follow-ups**. Specifically:90 a. Collect all improvement suggestions from Architect and Critic responses91 b. Deduplicate and categorize the suggestions92 c. Update the plan file in `.omx/plans/` with the accepted improvements (add missing details, refine steps, strengthen acceptance criteria, ADR updates, etc.)93 d. Note which improvements were applied in a brief changelog section at the end of the plan947. On Critic approval (with improvements applied): *(--interactive only)* If running with `--interactive`, use `AskUserQuestion` to present the plan with these options:95 - **Approve and execute** — proceed to implementation via ralph+ultrawork96 - **Approve and implement via team** — proceed to implementation via coordinated parallel team agents97 - **Request changes** — return to step 1 with user feedback98 - **Reject** — discard the plan entirely99 If NOT running with `--interactive`, output the final approved plan and stop. Do NOT auto-execute.1008. *(--interactive only)* User chooses via the structured `AskUserQuestion` UI (never ask for approval in plain text)1019. On user approval (--interactive only):102 - **Approve and execute**: **MUST** invoke `$ralph` with the approved plan path from `.omx/plans/` as context. Do NOT implement directly. Do NOT edit source code files in the planning agent. The ralph skill handles execution via ultrawork parallel agents.103 - **Approve and implement via team**: **MUST** invoke `$team` with the approved plan path from `.omx/plans/` as context. Do NOT implement directly. The team skill coordinates parallel agents across the staged pipeline for faster execution on large tasks.104105### Review Mode (`--review`)1061071. Read plan file from `.omx/plans/`1082. Evaluate via Critic using `ask_codex` with `agent_role: "critic"`1093. Return verdict: APPROVED, REVISE (with specific feedback), or REJECT (replanning required)110111### Plan Output Format112113Every plan includes:114- Requirements Summary115- Acceptance Criteria (testable)116- Implementation Steps (with file references)117- Risks and Mitigations118- Verification Steps119- For consensus/ralplan: **RALPLAN-DR summary** (Principles, Decision Drivers, Options)120- For consensus/ralplan final output: **ADR** (Decision, Drivers, Alternatives considered, Why chosen, Consequences, Follow-ups)121- For deliberate consensus mode: **Pre-mortem (3 scenarios)** and **Expanded Test Plan** (unit/integration/e2e/observability)122123Plans are saved to `.omx/plans/`. Drafts go to `.omx/drafts/`.124</Steps>125126<Tool_Usage>127- Before first MCP tool use, call `ToolSearch("mcp")` to discover deferred MCP tools128- Use `AskUserQuestion` for preference questions (scope, priority, timeline, risk tolerance) -- provides clickable UI129- Use plain text for questions needing specific values (port numbers, names, follow-up clarifications)130- Use `explore` agent (Haiku, 30s timeout) to gather codebase facts before asking the user131- Use `ask_codex` with `agent_role: "planner"` for planning validation on large-scope plans132- Use `ask_codex` with `agent_role: "analyst"` for requirements analysis133- Use `ask_codex` with `agent_role: "critic"` for plan review in consensus and review modes134- If ToolSearch finds no MCP tools or Codex is unavailable, fall back to equivalent OMX prompt agents -- never block on external tools135- **CRITICAL — Consensus mode agent calls MUST be sequential, never parallel.** Always await the Architect result before issuing the Critic call.136- In consensus mode, default to RALPLAN-DR short mode; enable deliberate mode on `--deliberate` or explicit high-risk signals (auth/security, migrations, destructive changes, production incidents, compliance/PII, public API breakage)137- In consensus mode with `--interactive`: use `AskUserQuestion` for the user feedback step (step 2) and the final approval step (step 7) -- never ask for approval in plain text. Without `--interactive`, auto-proceed through planning steps without pausing. Output the final plan without execution.138- In consensus mode with `--interactive`, on user approval **MUST** invoke `$ralph` for execution (step 9) -- never implement directly in the planning agent139</Tool_Usage>140141<Examples>142<Good>143Adaptive interview (gathering facts before asking):144```145Planner: [spawns explore agent: "find authentication implementation"]146Planner: [receives: "Auth is in src/auth/ using JWT with passport.js"]147Planner: "I see you're using JWT authentication with passport.js in src/auth/.148 For this new feature, should we extend the existing auth or add a separate auth flow?"149```150Why good: Answers its own codebase question first, then asks an informed preference question.151</Good>152153<Good>154Single question at a time:155```156Q1: "What's the main goal?"157A1: "Improve performance"158Q2: "For performance, what matters more -- latency or throughput?"159A2: "Latency"160Q3: "For latency, are we optimizing for p50 or p99?"161```162Why good: Each question builds on the previous answer. Focused and progressive.163</Good>164165<Bad>166Asking about things you could look up:167```168Planner: "Where is authentication implemented in your codebase?"169User: "Uh, somewhere in src/auth I think?"170```171Why bad: The planner should spawn an explore agent to find this, not ask the user.172</Bad>173174<Bad>175Batching multiple questions:176```177"What's the scope? And the timeline? And who's the audience?"178```179Why bad: Three questions at once causes shallow answers. Ask one at a time.180</Bad>181182<Bad>183Presenting all design options at once:184```185"Here are 4 approaches: Option A... Option B... Option C... Option D... Which do you prefer?"186```187Why bad: Decision fatigue. Present one option with trade-offs, get reaction, then present the next.188</Bad>189</Examples>190191<Escalation_And_Stop_Conditions>192- Stop interviewing when requirements are clear enough to plan -- do not over-interview193- In consensus mode, stop after 5 Planner/Architect/Critic iterations and present the best version194- Consensus mode outputs the plan by default; with `--interactive`, user can approve and hand off to ralph/team195- If the user says "just do it" or "skip planning", **MUST** invoke `$ralph` to transition to execution mode. Do NOT implement directly in the planning agent.196- Escalate to the user when there are irreconcilable trade-offs that require a business decision197</Escalation_And_Stop_Conditions>198199<Final_Checklist>200- [ ] Plan has testable acceptance criteria (90%+ concrete)201- [ ] Plan references specific files/lines where applicable (80%+ claims)202- [ ] All risks have mitigations identified203- [ ] No vague terms without metrics ("fast" -> "p99 < 200ms")204- [ ] Plan saved to `.omx/plans/`205- [ ] In consensus mode: RALPLAN-DR summary includes 3-5 principles, top 3 drivers, and >=2 viable options (or explicit invalidation rationale)206- [ ] In consensus mode final output: ADR section included (Decision / Drivers / Alternatives considered / Why chosen / Consequences / Follow-ups)207- [ ] In deliberate consensus mode: pre-mortem (3 scenarios) + expanded test plan (unit/integration/e2e/observability) included208- [ ] In consensus mode with `--interactive`: user explicitly approved before any execution; without `--interactive`: output final plan after Critic approval (no auto-execution)209</Final_Checklist>210211<Advanced>212## Design Option Presentation213214When presenting design choices during interviews, chunk them:2152161. **Overview** (2-3 sentences)2172. **Option A** with trade-offs2183. [Wait for user reaction]2194. **Option B** with trade-offs2205. [Wait for user reaction]2216. **Recommendation** (only after options discussed)222223Format for each option:224```225### Option A: [Name]226**Approach:** [1 sentence]227**Pros:** [bullets]228**Cons:** [bullets]229230What's your reaction to this approach?231```232233## Question Classification234235Before asking any interview question, classify it:236237| Type | Examples | Action |238|------|----------|--------|239| Codebase Fact | "What patterns exist?", "Where is X?" | Explore first, do not ask user |240| User Preference | "Priority?", "Timeline?" | Ask user via AskUserQuestion |241| Scope Decision | "Include feature Y?" | Ask user |242| Requirement | "Performance constraints?" | Ask user |243244## Review Quality Criteria245246| Criterion | Standard |247|-----------|----------|248| Clarity | 80%+ claims cite file/line |249| Testability | 90%+ criteria are concrete |250| Verification | All file refs exist |251| Specificity | No vague terms |252253## Deprecation Notice254255The separate `/planner`, `/ralplan`, and `/review` skills have been merged into `$plan`. All workflows (interview, direct, consensus, review) are available through `$plan`.256</Advanced>