Plan

From melodic-software/claude-code-plugins · View interactive version

Plan is an AI agent skill from the GitHub repository melodic-software/claude-code-plugins. Produce structured implementation plans with goal, approach, test strategy, blast radius, parallelism, and a user approval gate before any code is written, persisted as PLAN.md for fresh-session handoff. Use when: 'plan this', 'architect this', 'how should we implement', 'implementation plan', 'writ

How to use this skill

Skill file

Arguments. [task description|review|close-out] [--unattended] [--reader guardrails|standard|step-by-step]. e.g., /planning:plan add caching to query handlers, /planning:plan #<map>, /planning:plan review, /planning:plan close-out --reader guardrails. Take --reader <depth> out of $ARGUMENTS before routing; it sets the "Reader depth" of the published copy.

Repository context. Gather first

<!-- BEGIN GENERATED: gather-block. Edit docs/conventions/gather-block/block.md, then run scripts/sync-gather-block.py -->

Run each command below as its own Bash call, all sent together in one message (worktree isolation).

Keep any bound in the command's own pipe (output limits).

Unless this section says otherwise, treat a failure (not a repository, git unavailable) as an unknown value and carry on. Keep these as body calls, never ## Pre-computed context lines (gather-block convention).

<!-- END GENERATED: gather-block -->

Variables

Arguments: $ARGUMENTS

Purpose

Every implementation starts with a clear design, evidence, a test strategy, and user sign-off before any code is written. This is not Claude Code's built-in plan mode (what that mode does: Analyze before you edit with plan mode); this skill is a separate planning discipline that can run inside it. It consumes exploration, research, and /planning:design (types, interface contracts, module boundaries, package topology) and produces a plan the user approves before execution. A 2-minute plan prevents a 20-minute rework cycle. Match planning depth to blast radius: a one-file fix gets a brief plan; a cross-cutting architecture change gets a full plan with stress-testing and research-iterate loops.

Level this skill decides: files and symbols, which files change and which functions, types and tests each phase touches; behavior is the interview's Brief, and interfaces and interface contracts are /planning:design's.

Skip the plan when one sentence covers the change. First try to write the whole diff as one sentence. The test passes when no design question is open and that sentence describes every edit. How this skill was reached decides what happens next:

Emit checklist

For multi-step planning (almost always steps 1-5), copy ${CLAUDE_PLUGIN_ROOT}/skills/plan/templates/checklist.md to <memory_dir>/<topic-slug>/plan-checklist.md (default .work/) by reading the template with the Read tool and writing the copy with the Write tool, never cp, sed or a shell redirect from a plugin file, and tick each - [ ] as its step completes. Step 5 (present for approval) is a non-negotiable tick. Step 3 is ticked once the reviewer rule (Gates) is applied: the reviewer ran, or its skip and reason are recorded.

Skip when: the one-sentence skip (Purpose) applied, so no plan is written. On a mid-flight review replan, append a dated scope-change note and revise the PLAN phases instead; do not spawn a second checklist file.

For non-trivial / multi-layer plans, Step 2 walks its design-default checklist against the plan: confirm the plan carries the resolved threads in PLAN.md's ## Design section (and the design artifacts behind it) rather than re-deriving the axes. Configurability, extension points, observability, and testability are design threads owned by /planning:design's "Design defaults"; type-collaboration shape is its type modeling. The principle and lifecycle-and-reversibility threads /planning:design-handoff requires are audited the same way: resolved, directional or tagged-deferred (at quality bar prototype, named as deferred); a missing one routes back through /planning:design-handoff, except under an early-exit design-resolution.md, which carries neither. Audit that the plan carries their resolutions, don't re-open them. When a phase is tagged for a phase-boundary review, confirm the Brief carries a Quality bar: line: that review rates at it (context/plan-template.md "Phase Review tags"). Magic-literal hygiene stays plan's own review check against the consuming project's review conventions when it declares them.

Action Router

Parse $ARGUMENTS to determine the action, after taking out --unattended wherever it appears (the caller declaring that nobody is present; it governs the /plan offer under "Routing"):

| Argument | Action | Use case |

|----------|--------|----------|

| (empty) | Smart default | If a plan exists in conversation, offer to finalize/review; if exploration and research are done, start planning; otherwise suggest prerequisites |

| <task description> | Full planning | Run the complete planning process for the described task |

| #<map> [task description] | Plan from a map issue | Full planning with a tracker item (#<n>, qualified ID or URL) as its source; Step 1 reads its decisions |

| review | Plan review | Critique an existing plan for completeness, feasibility, and alignment with the project's conventions |

| close-out | Close-out | Run the PR-time close-out (below) for an approved plan: publish PLAN.md to the PR body and the linked issue, record durable decisions as an ADR, file follow-ups to the tracker |

Planning Process

Gates

These hold after a compaction re-attach. Later steps say how to carry them out.

Verification. These gates sit near the top so they stay inside the part of this skill that is re-attached after auto-compaction; tests/reattach-slice.test.sh stands in for that part with the first 20,000 bytes. How much is re-attached: Skill content lifecycle.

Step 4.7: Outcome gate (before Step 5. Verify the PLAN, not a recap)

Before presenting at Step 5, persist the composed plan as a draft to <memory_dir>/<topic-slug>/PLAN.md (default .work/; the final-persist step updates the same file after approval and applies plan_store; the draft is never published), then check the artifact against binary criteria read off it, not a holistic "is the plan good?" recap. Any FAIL → fix the PLAN before presenting.

Run bash "${CLAUDE_PLUGIN_ROOT}/scripts/check-plan-outcome.sh" <PLAN.md> and require exit 0. It prints one criterion=<name> status=<pass|fail> line per mechanical criterion:

Then run bash "${CLAUDE_PLUGIN_ROOT}/scripts/check-plan-citations.sh" --commit HEAD <PLAN.md> from the repository the plan cites and require exit 0: every path:line citation (a path from the repository root, then a line, a start-end range, or a comma list of them) names a file and lines that exist at that commit, and each one that does not prints a citation= line with its reason. Each outermost shape fence's anchor is checked at the same commit; a failing or warned anchor prints a shape= line with its reason, and only the shape-line warning passes (reasons: context/plan-template.md "Shape fences"). Cite lines as they stand at that commit, and cite a file outside it (a memory-slice file) without a line number. Write the commit= value it prints into PLAN.md's Citations checked at: line, so a reader knows which tree the line numbers describe. A deliberate example, or a host and port the script reads as a citation, carries <!-- citation-example --> on its line.

Checked by reading, or by their own script:

This self-check does not replace the human approval at Step 5; the user is the terminal gate.

The gate does not vanish when no human is present. On an unattended run (a routine, a dispatched worker, any session with nobody to answer), approval proceeds only under a standing mandate that covers this plan, recorded in PLAN.md's Approval: line: the mandate, who granted it and where, and the review surface that stands in for the human (for example the PR). With no such mandate, stop here and report the plan as unapproved. Listed changes stay uncleared either way ("Plan changes after the Brief", its "Unattended run" bullet). The default run above does not look for the Approval: line; the final persist step checks it with --approval-only.

Step 5: Present for Approval

The plan is a proposal, not a commitment. The user approves, modifies, or rejects it before execution begins. Unattended approval follows the Gates rule above.

Include in the presentation:

  1. The structured plan (Step 2, updated by Steps 3-4 if applicable)
  2. Blast-radius assessment (Step 3b)
  3. Reviewer line (Step 3): Reviewer: ran (<reason>) or Reviewer: skipped (<reason>), e.g. Reviewer: skipped (blast radius LOW, no trigger); then the stress-test summary (Step 4, if run), or "Skipped: blast radius LOW, no triggers matched", or "Skipped: plan_stress_test is reviewer"
  4. Execution shape (Step 4.5): the four-dimension table, parallelism shape and per-phase routing table, with each multi-shape phase's attempt constraints and selection rule. Skipped for single-phase plans
  5. Displaced answers and new external effects ("Plan changes after the Brief"). One bullet per changed answer, Q<N> (<plain name>): you answered <was>; the plan proposes <new>, then the new external effect and the source (reviewer fix, research update, or stress-test finding); a change with no answer behind it leads with none in place of Q<N>. Omit the block when empty. The approval request says one "approve" reconfirms every listed row, and a reply naming a row handles that row alone
  6. Decisions made (gate-passed) (Step 4.6). Table per context/tag-decisions.md "Presentation contract": Decision | What it changes in the plan | Basis (evidence) | Source, one row per gate-passed [EXEC-SHAPE] / [FALLBACK] tag and per deferred Brief question the plan resolved (Source deferred Q<N>), written for a cold reader (no session shorthand). Below-bar decisions never appear here. An empty section ("no unilateral decisions. Every PLAN item traces to brief") is valid
  7. Explicit approval request: "Approve this plan to proceed to execution, or provide feedback to revise. Anything tagged [EXEC-SHAPE] or [FALLBACK] above is /planning:plan's discretion. Flag any you want changed." When item 5 lists rows, add: "One 'approve' also reconfirms every changed answer listed above; name a row to restore it instead." Then name each Brief deferred question still open with arbiter: USER-RESERVED, with the plan's proposal, as needing its own reply
  8. Highest-leverage replies: close with 2-4 pre-drafted one-line revision replies, one per flagged close call or gate-passed decision, each a copyable sentence that flips exactly that decision (e.g. "Switch phase 2 to the queue-based alternative"). The user's cheapest possible reaction is pasting one back; a presentation whose flagged decisions have no pre-drafted flip line makes the user compose the revision themselves

Presentation order: tweak-likelihood first. Lead with what the user is most likely to change: data-model/schema choices, type interfaces and public APIs, and user-facing surfaces (flag close calls with their alternatives); mechanical, low-judgment work goes last. Phase execution order stays as phase_order set it in Step 2. After the presentation, offer an interactive plan view built from the draft PLAN.md (its Brief, behaviors, acceptance criteria, decisions and phases, each linked from the page, and a reply that names the phases to change, sent to this session through session-bridge when connected). PLAN.md stays the record, and the view writes nothing back to it. Build it only with ${CLAUDE_PLUGIN_ROOT}/scripts/build-view.mjs plan --record <PLAN.md>, never hand-written; it runs the shared medium resolver and publish gate with this plugin's medium option ${user_config.medium}, or "" when that reads empty or unsubstituted (never put a ${user_config.*} string in a shell command), and you print the report line it prints. Procedure and what the page shows: CODE8. A pasted page-input block follows its "Reader input". The plan view's choices are the data-rv-choice selects in ${CLAUDE_PLUGIN_ROOT}/skills/plan/templates/plan-view.html; when page-input.mjs cannot run, Read that one file for them, and never search the plugin directory.

If 2–4 named alternatives surfaced during the stress-test, present them side by side via AskUserQuestion when the plugin's use_ask_user_question user config (${user_config.use_ask_user_question}; unexpanded or empty means off) is on, numbered inline prose otherwise. For open-ended approval (single proposal, no alternatives) use prose.

After approval. Branch-name check: verify the branch name matches the approved scope before handing off.

| Current branch | Action |

|----------------|--------|

| main or master | Stop. Cannot implement on the default branch. Suggest git checkout -b <type>/<topic-slug> derived from the plan topic + conventional prefix |

| Auto-generated or placeholder name | Derive the name from the plan: <type>/<topic-slug> (feat/, fix/, refactor/, chore/, etc.). Suggest the rename; let the user execute unless the environment is isolated (worktree or remote session), where renaming directly is safe |

| Matches a conventional prefix (feat/, fix/, etc.) | OK. No action needed |

Derive the type from plan content: new capability → feat/, bug fix → fix/, restructuring → refactor/, tooling/maintenance → chore/, docs-only → docs/, tests-only → test/, build config → build/, performance → perf/.

After approval: suggest the consuming environment's implementation workflow (a skill like /implementation:implement (if enabled) if it ships one, otherwise structured inline execution reading PLAN.md). If implementation diverges from the plan, chain back to /planning:plan review to re-plan rather than pushing through a broken approach.

Step 5, the approval gate, is placed with the gates above so a compaction re-attach keeps it. The approval gate is the point.

Step 1: Prerequisite Check

Before a step adds a mechanism (a branch, workflow, ruleset, app, service, dependency or check), name the existing control that already covers the same risk, saying whether you read its enforcing source or only a document, and drop the step if one does, listing each drop at Step 5: in the "Displaced answers and new external effects" block when it overturns a Brief answer, under "Decisions made" otherwise. A security control (the protected classes of /overengineering:justify (if enabled); when that list cannot be read or a mechanism's status is uncertain, any security, access-control or destructive-operation guard) is never dropped without the user's decision: an unattended run keeps it and reports the would-be drop as USER-RESERVED. An abstraction for a stated, known repetition stays when it passes the standards index's reference-dont-duplicate tests, or, with no such entry, when its second consumer is stated and its shape is namable and stable. For a non-trivial new mechanism, run /overengineering:justify (if enabled) on the proposal.

Prefer the simplest plan that works and keep each step's changes surgical. Before planning, verify:

| Tier | Signals | Requirement |

|------|---------|-------------|

| A. Design-significant | New types/contracts, new module or library, package topology change, cross-module integration, data model change, multi-tenant posture | Blocking: full or light /planning:design + its handoff gate (design-threads.md all RESOLVED / directional / TAGGED-DEFERRED) |

| B. Light design | 2–5 files, one new type, localized contract tweak | Blocking: design/design-resolution.md with outcome: early-exit, tier: B, and its type sketch (a type-inventory.md alone is not the gate artifact) |

| C. No design | Single-file bugfix, config/doc/markdown, rename, hook text, pure test addition | Blocking: design/design-resolution.md with outcome: early-exit + reason (gate always evaluated) |

Check <memory_dir>/<topic-slug>/design/ (default .work/) for design artifacts or design-resolution.md. If Tier A/B requirements are unmet, stop. Offer /planning:design or document the early-exit artifact; when you document it here, also write PLAN.md's one-line ## Design record naming the early exit and its reason, plus, for Tier B, a ### Contracts subsection quoting the type sketch. The user may override via AskUserQuestion only when they explicitly accept skipping design exploration. Do not re-derive design inline when design-significant.

If prerequisites are missing, state what's needed and offer to run the prerequisite skill; don't silently skip this step. The /planning:prd check is additive, not blocking: proceed if product intent is locked elsewhere or the work is engineering-internal.

Step 2: Formulate the Plan

Ground in consumer standards (first formulation input)

Before formulating, resolve the consumer's standards and load what this task touches:

Multi-angle panel (opt-in). For a hard or wide plan, when the user asks for it or /multi-agent:assess (if enabled) returns workflow, formulate through the planning:plan-panel workflow instead of one draft, behind a Workflow availability gate with this single-plan flow as the fallback. Read context/plan-panel.md before launching. Its synthesized plan still goes through Step 3 onward and the Step 5 approval gate.

Produce a structured plan using context/plan-template.md. What we're trying to achieve and why is the Brief's Goal, so the plan carries no Goal of its own:

Scale the plan to the task. The file counts below are the defaults of plan_size_bands (each band's largest count); resolve it per CODE1 "Convention-home keys" (no userConfig layer), read each band's counts from the resolved values, and report one line, e.g. plan_size_bands: trivial 1, small 5, medium 15 (default):

| Task scale | Plan depth |

|-----------|-----------|

| Trivial (1 file, well-understood) | 3-5 bullet points, when the one-sentence skip (Purpose) did not apply |

| Small (2-5 files, clear scope) | Brief plan. Steps, test strategy |

| Medium (5-15 files, some unknowns) | Full plan with alternatives and risks |

| Large (cross-cutting, architectural) | Full plan + stress-test + research-iterate |

Per-scale examples: context/plan-template.md "Choosing the Right Scale".

Tracker-write phases: when any phase ends in creating a work item (e.g. /work-items:track add (if enabled)), the plan body must follow context/plan-template.md "Phase-entry checks for tracker writes": search-before-create as the first work item, an explicit pivot path for the match case, and the search outcome captured in the phase Sanity Check.

Model-run phases: when a phase or test step spends model runs (evals, agent fan-outs, benchmark batches), it puts a graded reproduction check before any batch, sizes the run count from tokens measured on 1-2 runs, and carries a **Run budget:** line the runner enforces: context/plan-template.md "Model-run phases".

Pre-flight consumer check. When a phase migrates a contract (frontmatter schema, JSON schema, public API surface, env-var shape, file format, exported function signature), list "Identify consumers" as its first work item: Grep + Glob for scripts/hooks/workflows/sibling components parsing the contract surface; document parse paths. Migration work items follow. Full pattern: context/plan-template.md "Pre-flight consumer check".

Sub-topic promotion check. When a phase grows beyond any of (>5 distinct work items / >300 LOC delta / own exploration or research need / 2+ sub-phases of its own / independent commit boundary), recommend promoting it to its own topic directory with its own PLAN.md. Criteria: context/plan-template.md "Sub-Topic Promotion Trigger".

Phase merge floor. A phase of one file and a few lines with no verification need of its own merges into the adjacent phase it serves. Every phase pays a full dispatch, sanity-check, commit and plan-mark cycle, which a one-line phase does not earn. The threshold is judgment (nearest anchor: Step 4.5's ~100 LOC parallelism floor); keep a small phase separate when it is its own commit boundary or needs its own Sanity Check.

File inventory for large-scope plans. When a plan or phase touches plan_inventory_min_files or more files (default 10, resolved like plan_size_bands above and reported in the same line), emit a checkbox inventory table per phase (file, action, rationale), ticked as each file is processed. Include KEEP rows for files audited and deliberately left unchanged. Format: context/plan-template.md "File Inventory".

Sanity-check verifiable-criterion enforcement. Every phase ends with at least one **Sanity Check:** bullet that is mechanically verifiable (a specific grep, file Read assertion, build exit code, test exit code, or runtime probe). Never vague (~~"documented appropriately"~~, ~~"behaves as expected"~~, ~~"all cases covered"~~): rewrite as exact commands a fresh session can execute without inferential judgment, so each phase can be verified green at its own boundary rather than only at the end; this is what backs implementation's every-step-lands-green expectation. Format: context/plan-template.md "Sanity-Check Format".

Build-technique selection. Before ordering phases, pick the de-risking technique by the task's uncertainty type, not by habit. A design or viability unknown (might abandon) resolves upstream: /planning:design for design-significant questions, a throwaway /prototype:pressure-test (if enabled) spike or research for raw feasibility; the plan consumes that outcome rather than re-deriving it. For each prototype it consumes, fill PLAN.md's ### Prototype evidence section (context/plan-template.md) from that prototype's durable note: where its evidence lives and what it left unproven. Omit the section when the plan consumes no prototype. Plan's own call is the kept slice: a tracer bullet / walking skeleton when committed to ship and the risk is integration. When an upstream feasibility spike and ship-commitment both hold, sequence the kept tracer-bullet slice after the spike's outcome lands. Trivial / pure-horizontal work skips all techniques.

Design section audit. When PLAN.md carries a ## Design section (written by /planning:design-handoff), keep it as written and audit every phase against it: a phase that builds part of the design names the subsection it implements (module layout, contracts, variation verdicts), and no phase departs from a recorded contract, boundary, or verdict. A needed departure routes back to /planning:design. Every external integration has a verdict: list each external system a phase touches and check ### Variation verdicts names it with abstract now, contain now, or leave inline (CODE4); one without a verdict, or left inline, routes back to /planning:design, and so does a phase that puts a provider's name into domain code, storage, or a public contract under a contain verdict. Design-significant work (Step 1, Tier A or B) with no ## Design section goes back through /planning:design-handoff, which writes it from the tier's gate artifact: design-threads.md for Tier A, design-resolution.md for Tier B.

Phase order (phase_order). After build-technique selection, order the phases by the phase_order setting. Resolve it lowest layer first: the default composed; the plugin's phase_order user config (${user_config.phase_order}); then the phase_order key of the repository's docs/conventions/planning.yaml, which wins when set. Read that file only when the working directory's git root is neither $HOME nor an ancestor of it; otherwise skip the repository layer and say so. A literal unexpanded ${user_config.phase_order} means the user layer is unset. A value outside composed, subtraction-first and riskiest-first is named with its file (or user config), key and value, and that layer is dropped: a valid higher layer still wins, with none the key is composed, and a lower layer's value never replaces it. Report one line naming the value and its layer, e.g. phase_order: riskiest-first (docs/conventions/planning.yaml). Keys and layers: CODE14.

For the removal step, invoke /code-tidying:audit-dead-code (if enabled) through the Skill tool, scoped to the paths the change touches; otherwise list the candidates from the plan's own reads (unreferenced functions, files or exports in the touched paths, each with the search that found no caller). Removal stays its own phase. Dependencies still win: a phase that needs another's output follows it under every value. Pure-horizontal work (migration, lint, doc pass) has no integration slice to place.

Stub phase (scaffold_stubs). Resolve scaffold_stubs with the same layers, root rule and report line as phase_order: the default false, then ${user_config.scaffold_stubs}, then the scaffold_stubs key of docs/conventions/planning.yaml. Only the bare booleans true and false are valid; a quoted "true", yes or any other value is named with its file (or user config), key and value, and that layer is dropped: a valid higher layer still wins, otherwise false, never a lower layer's value. With true, add one phase that commits the stub files: right after phase_order's dead-code removal step, or first when the plan has none (riskiest-first, or a bug fix under composed). Take the files and signatures from the design's ## Stub scaffold section when /planning:design wrote one; otherwise derive them from the interfaces the plan introduces. Each stub body is the language's ordinary not-implemented form. When the stubs leave the build, the tests or the lint red (an existing test now reaches a stub that throws, a linter flags the unused parameters), the stub phase carries a **Planned breakage:** line naming the stub paths and the later phase that makes them pass (context/plan-template.md "Planned breakage"). With false, add no stub phase.

Redesign work items (integration_posture). This key belongs to the implementation plugin, whose user config this skill cannot read, so read only the repository layer: the integration_posture key of the consumer's docs/conventions/implementation.yaml, under the same root rule as phase_order (git root neither $HOME nor an ancestor of it; otherwise skip the file and say so). A missing file or key reads as by-kind. A value outside by-kind, day-one and minimal is named with its file, key and value and dropped, so the key reads as by-kind. Report one line naming the value and its source, e.g. integration_posture: day-one (docs/conventions/implementation.yaml). Apply it by the change's kind: under by-kind a feature takes a day-one redesign and a fix or config change stays minimal; day-one gives the redesign to features, fixes and config changes alike; minimal gives none of them a redesign; a refactor keeps the plan's scope with behavior unchanged under every value. A day-one redesign reshapes the code the change lands in so the result reads as though the new behavior had been in the original design (moving, renaming, merging or splitting existing parts rather than adding a branch beside them). When the kind takes it, write that reshaping as explicit work items in the phases that touch the code, each naming the files and the restructuring, so /implementation:implement (if enabled) executes it as plan work rather than deciding its own scope. Under minimal, or for a kind that stays minimal, write no reshaping beyond what the change needs.

Measurable-goal baseline capture. When the brief states a measurable goal (perf / latency / throughput / allocation / complexity / coverage keywords), capture a baseline by default before the change: invoke /verification:measure performance baseline (if enabled) (perf) or /verification:measure metrics baseline (if enabled) (code metrics) via the Skill tool, or measure the pre-change state manually; this skill routes, never reimplements. Store the raw capture under <memory_dir>/<topic-slug>/baselines/ (default .work/; machine-bound, never committed), then record the distilled baseline value + target in PLAN.md. After the change, re-measure and compare through the same route (its compare phase reads the stored baseline, or re-measure manually) and record the comparison in PLAN.md as distilled values only. PLAN never cites the memory-slice capture path, which would dangle outside the writing checkout. Never claim an improvement without a baseline.

Step 3: Plan Stress-Test

Which stress-tests run (plan_stress_test). Name the draft's mode (plan, proposal or incumbent), then resolve that mode's value per CODE4 "Convention-home keys", which defines the modes and values (no userConfig layer; the default is auto). Report one line, e.g. plan_stress_test.incumbent: both (docs/conventions/planning.yaml). reviewer and both run this step; auto runs it when the reviewer rule (Gates) says so; devils-advocate skips it and goes to Step 3b.

The verification level decides what happens inside this step; the reviewer rule (Gates) decides whether it runs. Resolve it with bash "${CLAUDE_PLUGIN_ROOT}/lib/read-verification.sh" --plugin planning --skill plan --file docs/conventions/planning.yaml and report its line (levels). Under light, and off, which acts as light here, skip items 2 through 5, dispatch no reviewer and never stress-test the plan inline in its place: the reply that reports this step, and the Step 5 presentation, state verification: skipped (<level>), and the run goes to Step 3b, which no level governs.

Whether the reviewer runs. Apply the reviewer rule (Gates). Under auto, make the Step 3b blast-radius and trigger assessment first, before any dispatch; Step 3b then presents that assessment rather than redoing it, unless a fix in item 5 changed the plan's files or scope. When the rule skips the reviewer, skip items 2 through 5, and the reply that reports this step, and the Step 5 presentation, state Reviewer: skipped (<reason>), e.g. Reviewer: skipped (blast radius LOW, no trigger), and a skip the verification level causes states verification: skipped (<level>) as above; the run goes to Step 3b. The producing main thread must not self-attack the plan inline: the model that just wrote the plan rubber-stamps it. Where the plan is high-stakes and correlated blind spots are the risk, prefer a cross-vendor advisor when one is enabled and set up (e.g. the OpenAI Codex plugin, when its documented surface can take this artifact, invoked per its own docs), with the fresh-context plan-reviewer sub-agent as the stated fallback, never a route to a command that may not resolve (per docs/plugin-philosophy.md "Fresh-eyes checkpoints" in the marketplace repository).

  1. Gather the plan draft + design artifacts (or design-resolution.md) + the Brief
  2. Surface the cost. Tell the user, in one sentence, that a fresh-context plan review runs now and why (Reviewer: ran (<reason>)): one bounded sub-agent (default effort: medium, capped turns).
  3. Dispatch the plugin's plan-reviewer agent (agents/plan-reviewer.md) with the prompt from context/plan-reviewer.md. Do not substitute a generic read-only sub-agent, and pass no effort on the call: the agent definition carries the reviewer's bounded effort and maxTurns (the effort record in agents/plan-reviewer.md). A complete report ends with its ### Summary counts, or is the literal No plan gaps found. for a clean pass; treat any other return as incomplete whether or not a partial marker is present (whether a maxTurns stop is marked depends on the client: the maxTurns record in agents/plan-reviewer.md): resume it (or re-dispatch with a narrowed brief); never treat a partial table as a clean pass.
  4. Verify reviewer findings against the actual code/files before applying fixes. Sub-agent findings are synthesis, not ground truth
  5. Fix every confirmed gap before proceeding; never present a plan with known gaps. A fix that displaces a user answer or adds an external effect follows "Plan changes after the Brief" below

When the reviewer runs on a trivial single-file plan (3–5 bullets, no new types), its brief may be shortened to structural-integrity checks only; still dispatch fresh context, never inline self-critique.

Step 3b: Assess Blast Radius

Every plan gets a blast-radius check. Read context/stress-test-triggers.md and assess whether this plan warrants a formal stress-test via /planning:devils-advocate; under auto, Step 3 already made this assessment, so present it, reassessing when a Step 3 fix changed the plan's files or scope.

Present the assessment:

Blast radius: [LOW / MEDIUM / HIGH / CRITICAL]
Reviewer: [ran / skipped] (<reason>)
Stress-test needed: [Yes — invoking /planning:devils-advocate / No — research validation is sufficient]
Reason: <1-2 sentences>

Under plan_stress_test's auto: if LOW and no triggers match, skip Step 4 (Formal Stress-Test) only and continue at Step 4.5, then Steps 4.6-4.7 before presenting; if MEDIUM or higher, or any trigger matches, proceed to Step 4, then Steps 4.5-4.7. Under reviewer, skip Step 4 and answer No on the Stress-test needed line, whatever the assessment says. Under devils-advocate or both, proceed to Step 4 and answer Yes, whatever the assessment says. Name the setting as the reason when it overrides the assessment.

Step 4: Formal Stress-Test and Research-Iterate (conditional)

Runs only when Step 3b sends the plan here; the deeper, formal version of Step 3.

  1. Surface the cost. Tell the user a formal /planning:devils-advocate run is starting in fresh context (another serial sub-agent, typically higher turn budget than Step 3) before dispatching.
  2. Dispatch /planning:devils-advocate via the Skill tool to a fresh-context sub-agent. Under plan_stress_test's devils-advocate or both, an incumbent draft runs the skill's incumbent mode, with incumbent <the tool or approach it decides on> as its arguments; every other run is plan-review mode. Keep the brief short: findings table, not a narrative. Hand it the plan (plus the Brief, the interview ledger <memory_dir>/<topic-slug>/interview-checklist.md when one exists, and any design artifacts), not your rationale for it. The producing main thread must not run the stress-test inline, for the same reason as Step 3. Verify its findings against the actual code/files before acting on them; sub-agent findings are synthesis, not ground truth

Audit judgment (untested): when both the reviewer and Step 4 run, Step 3 and Step 4 may dispatch against the same plan draft in one message when Step 4's criteria read off the draft rather than Step 3's findings. Document when used; default remains serial.

  1. Evaluate findings. If /planning:devils-advocate produces CRITICAL or HIGH findings:
  1. Iterate if needed. Repeat the Plan-Stress-Research cycle until the plan achieves HIGH confidence on all claims. Loop protocol: context/research-iterate.md
  1. Escalation guard. If 3 iterations haven't resolved the issues, present the remaining risks to the user explicitly. The user may accept known risks or redirect the approach entirely

Plan changes after the Brief

Applies to every change made after the Brief locked: Step 3 reviewer fixes, Step 4 research updates, and adopted /planning:devils-advocate mitigations. A change that (a) displaces an answer the user gave in the interview, or (b) adds a remote write, an irreversible action, or an externally visible artifact, is never folded into the plan silently:

Step 4.5: Execution-Shape Analysis (parallelism. Default on for multi-phase plans)

After the phase plan is locked but before Step 5 approval, compute the execution shape: which phases can run in parallel and which surface each phase runs on. Default on for any plan with ≥2 phases; emit a one-line "fully sequential. Phase X gates phase Y" note when no parallelism opportunity exists. Skip for single-phase plans or trivial fixes, stating in one line that execution is all main-session.

A multi-phase plan opens this analysis with the table below, its four rows in this order. Fill every row. A dimension with nothing to report gets n/a: <reason>; an empty cell or a removed row is incomplete.

| Dimension | What to write | Example n/a |

|---|---|---|

| Gates | The work the other phases wait on (a schema migration, a new interface), and the phases blocked behind it. | n/a: every phase can start from the base branch |

| Shared state | Each file, table or config key that two phases would both write. Split shared state before serializing: hand each phase its own file, key range or module, and make two phases wait on each other only for a rule that has to hold across both writes. | n/a: no file appears in two phases |

| Disjoint streams | Groups of phases that change separate modules, packages or processes, and so can run at the same time. | n/a: every phase edits the invoicing module |

| Worker count | The smallest number of workers that keeps every stream safe. A count of one names the reason, for example that every phase edits the same migration script. | Never n/a: the count is at least one. |

The analysis steps, the file-overlap matrix, and the composition risks: context/plan-template.md "Execution-shape analysis". Each routing row also carries a Model (sonnet, opus or frontier) that decides which implementer agent dispatch uses; eligibility rules are in that file's "Per-phase routing table".

Each routing row also carries an Attempts cell. Mark a phase multi-shape when this step finds more than one plausible shape the design left open for it; leave it blank otherwise (one attempt). A marked phase's body lists one stated constraint per attempt and the selection rule (first pass, rank all, or best-of with its criteria), both written now, before any dispatch. The mark reads no setting: whether a marked phase gets several attempts is decided at dispatch. Format: that file's "Per-phase routing table".

Step 4.6: Tag unilateral decisions

Before Step 5, walk the PLAN body + Execution shape + Handoff sections and classify every decision not explicit in the brief: [EXEC-SHAPE] (your discretion within briefed scope) or [FALLBACK] (an invented contingency the brief didn't anticipate, for the user to confirm or override); briefed decisions get no tag. Then apply the confidence gate: DECIDE only when the basis is evidence captured this session (a codebase pattern read, a research finding, or a directly-on-point project convention) with no surviving reasonable alternative; everything below the bar (judgment calls, sizing guesses, either-would-work placements) routes to an interview round before the plan locks; hard-to-reverse decisions escalate early, per the Gates rule. Full gate, taxonomy, and presentation contract: context/tag-decisions.md. Surface every gate-passed decision at Step 5 in the "Decisions made (gate-passed)" table (Decision | What it changes in the plan | Basis | Source). An adopted mitigation is classified per context/tag-decisions.md "Adopted mitigation".

Then apply the Step 4.7 outcome-gate criteria (under Planning Process, above) and present per Step 5. The approval presentation (Step 5) is with the gates at the start of Planning Process, so a compaction re-attach keeps it.

Plan Mode Integration

Built-in plan mode enforces read-only work during planning:

The skill does not enter plan mode itself; the user controls permission modes. Before planning a complex change outside plan mode, suggest it: "Consider entering plan mode for safe exploration while we design this." How the person switches modes: Switch permission modes.

Entering plan mode licenses a scoping confirm: a short round of questions that settle what this plan covers, no more than one AskUserQuestion call holds (the per-call question limit: <https://code.claude.com/docs/en/agent-sdk/user-input#limitations>), as one numbered round before proposing it. The round renders via AskUserQuestion only when the plugin's use_ask_user_question user config is on and the questions are independent. Inline prose otherwise.

Substantive rounds do not belong in plan mode. A question that resolves what we are building (real tradeoffs, contested requirements, anything whose answer changes the plan's shape) routes to /planning:interview via the Skill tool, run with plan mode off: that skill writes its open-question register to disk at ask time (what plan mode permits: Analyze before you edit with plan mode), and plan mode primes the run toward producing the plan when the job is still reaching shared understanding. Getting there is the user's move, not yours: when plan mode is active and a substantive round comes due, say why and ask the user to exit it, then invoke the interview once they have. Do not invoke it from inside plan mode.

Boundary, the built-in `/plan` command

The command and this skill share a name, so "plan this" can mean either.

Routing. Where Plan Mode Integration says to suggest plan mode, offer it to the person: If /plan is available in your session (gate basis: the records in reference/native-plan.md), you can run it alongside this skill (other ways to switch modes: Switch permission modes). Prefer this skill for the plan itself. When the caller passes --unattended, the run records the offer in its output instead of asking; without that flag it asks.

Mutation gate. This skill writes PLAN.md and its checklist; /plan changes the permission mode. This skill never toggles the mode on the person's behalf.

Availability is never assumed. This section states what to do when the person can run /plan, never that it is present. The four-part records live in reference/native-plan.md.

Boundary, the built-in `Plan` agent

Both produce an implementation plan, so "plan this" can also route to the subagent.

Routing. When the built-in Plan agent resolves in this session, dispatch it for a throwaway approach sketch or read-only context-gathering whose result feeds other work; use this skill when the plan needs the person's approval or must outlive the session. This skill may dispatch Plan to gather context, but the plan it presents is its own.

Mutation gate. This skill writes PLAN.md and its checklist; a dispatched Plan agent never writes them.

The four-part records live in reference/native-plan-agent.md.

Plan Review Mode

Read context/review-mode.md when invoked with review. It holds the review procedure, the re-plan branch for a review invoked after an implementation divergence, and how review differs from /planning:devils-advocate.

Final step: persist the approved plan for handoff

After the user approves in Step 5, update the draft <memory_dir>/<topic-slug>/PLAN.md (default .work/; persisted at Step 4.7) with any approval-round changes and its Approval: line (who approved and when, or the unattended basis Step 5 names), and write each superseded-by-plan row's result to the ledger once the user has replied to that row (an "approve" of the request that listed it counts; reconfirmed or restored, per "Plan changes after the Brief"). The plan is not approved while any listed change lacks its reply: when an interview ledger exists, rerun bash "${CLAUDE_PLUGIN_ROOT}/scripts/check-open-questions.sh" --ledger <ledger> before handing off and require exit 0 (no open or superseded-by-plan row left); with or without a ledger, a listed change still lacking its reply means asking for it and not handing off. After writing the Approval: line, run bash "${CLAUDE_PLUGIN_ROOT}/scripts/check-plan-outcome.sh" --approval-only <PLAN.md> and require exit 0 before handoff; on an unattended run a failure means reporting the plan as unapproved. The script checks only that the line exists and its value is neither empty, the template placeholder, nor TBD; whether the recorded mandate is adequate stays a judgment.

Derive <topic-slug> from the task or branch name (kebab-case, ≤40 chars; shared with /planning:prd, /planning:interview, /planning:design); placement per the lifecycle artifact protocol CODE4. PLAN.md lives in the self-ignored memory slice and is never staged; paste its published copy (see "Reader depth") into the pull request body or the linked issue so reviewers see it, and refresh that paste when an implementation phase changes the plan. Every link written to the tracker (that paste, the publish-plan comment, a close-out paste) is the item's title linked to its absolute URL, never a bare #<n>, so it resolves from any page that quotes it. It is the living source of truth for the stage: a fresh cleared session in this checkout must be able to execute the plan reading only this file (plus the exploration and research artifacts in <memory_dir>/<topic-slug>/, default .work/). Its ## Design section carries the design decisions, so neither that session nor a worker it dispatches needs the design/ directory.

Plan store. After the Approval: check passes, resolve plan_store, lowest layer first: the default local; the plugin's plan_store user config (${user_config.plan_store}); then the plan_store key of the repository's docs/conventions/planning.yaml, which wins when set (schema: CODE7). Read that key from the file in this checkout, under the same root rule as phase_order (Step 2); a missing file or key means the layer is unset. No ~/.claude file, .claude/ fallback or personal override sets this key. A user config value of local is reported as the default, since the two cannot be told apart, and a literal unexpanded ${user_config.plan_store} means the user config layer is unset, not invalid. A value other than local or tracker in either layer is named with its file (or user config), key and value, and that layer is dropped: a valid higher layer still wins, with none the key is local, and a lower layer's value never replaces it. Report one line naming the value and its layer, e.g. plan_store: tracker (docs/conventions/planning.yaml).

Reader depth. Before publishing or pasting, resolve plan_reader, lowest layer first: the default step-by-step; the plugin's plan_reader user config (${user_config.plan_reader}); the plan_reader key of docs/conventions/planning.yaml; PLAN.md's Reader depth: line, when an earlier publish wrote one; then a --reader <depth> argument on this run, which wins. Both config layers follow plan_store's root rule, unset and invalid-value handling, and report line. An argument outside guardrails, standard and step-by-step is named and dropped the same way, so it resolves the default, not a lower layer's value. Report e.g. plan_reader: guardrails (--reader), and write the value and its layer to PLAN.md's Reader depth: line, so close-out and a mid-flight refresh in a later session publish at the same depth. step-by-step publishes PLAN.md itself. guardrails and standard render PLAN.<depth>.md beside it, keeping its Approval: line, and that derived file is the published copy for publish-plan and the pull request paste; PLAN.md stays whole. Delete a derived file of any other depth. The sections each depth keeps: CODE20 "Reader-depth renders".

PLAN.md anatomy. PLAN holds Brief + Design + Plan; per-phase status lives in the phase tags ([TODO] / [DOING] / [DONE]), never in a separate status block. Copy the skeleton from CODE3 when first writing the file, the Step 4.7 draft (Read the template, then write PLAN.md with the Write tool; never cp, sed or a shell redirect from a plugin file), and read it again when a phase tag changes: it owns the section order, the tag grammar, and what each section must contain for a cleared session to execute the plan from this file alone.

PLAN.md is a multi-turn shared artifact: re-read it from disk before every write, since another turn or agent may have modified it. Prefer appending or refining sections over wholesale rewrites.

Write the plan even for small changes; only the one-sentence skip (Purpose) writes none.

Close-out (PR time). Read context/close-out.md when invoked with close-out. It holds the three-step procedure, the ADR handoff to /architecture:adr (if enabled), and the spec-container ship ritual.

Mid-flight pivots: when scope changes after approval, append a dated scope-change note to the affected PLAN.md section capturing the rationale, and strikethrough+link the obsolete content. PLAN.md is never committed, so these notes are its only history; re-render any derived copy ("Reader depth") and refresh the pull request body or linked issue paste so the published copy carries them (under plan_store: tracker, rerun publish-plan, which edits its comment in place). Do not silently rewrite history.

After writing, recommend: begin implementation in a fresh session. The implementing session reads PLAN.md for the execution roadmap. /session-flow:workflow (if enabled) names how that session starts (/clear, or on the desktop app a new session the user starts from the handoff); otherwise clear context.

What This Skill Does Not Do

Next

Gotchas

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.