--- name: plan description: 'Enter Claude Code planning mode with RLM decomposition. Analyzes codebase, designs approach, creates step-by-step plan. Use when: starting a new feature, refactoring, or complex task. Use when before implementing anything non-trivial — a feature, a refactor, a migration. Produces a step-by-step plan in .claude/plans/, validated against the project''s constraint ledger.' metadata: short-description: Enter Claude Code planning mode with RLM decomposition generated-from: plugins/*/skills/plan argument-hint: [--context[=]] [--goal [--fast]] [--auto] --- > Paths below are rooted at `${CODEX_HOME:-$HOME/.codex}/plugins/cache/kodflow/kodflow-workflow/0.0.0-re61d6d4f6f77`, where Codex installs this plugin. If that directory is missing, the plugin root is the directory two levels above this SKILL.md. # /plan - Claude Code Planning Mode (RLM Architecture) the arguments ## Overview Planning mode with **RLM** patterns: - **Peek** - Quick codebase scan - **Decompose** - Split into subtasks - **Parallelize** - Multi-domain exploration - **Synthesize** - Structured plan **Principle**: Plan -> Validate -> Implement (never the reverse) --- ## Arguments | Pattern | Action | |---------|--------| | `` | Plans the implementation of the feature/fix | | `--auto` | Auto mode: no questions, AI reasons internally and presents final plan | | `--context` | Auto-detect most recent `.claude/contexts/*.md` | | `--context=` | Load specific `.claude/contexts/{name}.md` | | `--goal` | After plan write, chain `/review` (plan gate) → `/refine` (contract) → suggest `/goal` | | `--goal --fast` | Skip the `/review` gate — chain straight to `/refine` (trivial plans) | | `--help` | Show help | ### `--goal` flag (PR5a — Skills Architecture v1.3) ```yaml goal_chain: trigger: "--goal in the arguments" after_plan_write: # skills-cleanup C3 (DD1): gate the plan through /review BEFORE /refine. primitive: | the /review skill # gate — review the plan in place the /refine skill # then compact to a /goal CONTRACT fast_bypass: trigger: "--goal --fast" message: "skips the /review gate; runs /refine directly (trivial plans only)." fallback_when_review_absent: message: "fall back to --fast (plan → refine) with a warning." fallback_when_refine_absent: message: "plan written; run /goal with the explicit condition manually." ``` --- ## --help ``` ═══════════════════════════════════════════════════════════════ /plan - Claude Code Planning Mode (RLM) ═══════════════════════════════════════════════════════════════ Usage: /plan [options] Options: What to implement --auto No questions — AI reasons internally, presents final plan --goal After plan write, chain /review (gate) → /refine → /goal --goal --fast Skip the /review gate, chain straight to /refine --context Load most recent .claude/contexts/*.md --context= Load specific .claude/contexts/{name}.md --help Show this help RLM Patterns: 1. Peek - Quick codebase scan 2. Decompose - Split into subtasks 3. Parallelize - Parallel exploration 4. Synthesize - Structured plan Workflow: /search → /plan → /review → /refine → /goal Examples: /plan "Add user authentication with JWT" /plan "Refactor database layer" --context /plan "Fix memory leak in worker process" ═══════════════════════════════════════════════════════════════ ``` --- ## Phase Reference | Phase | Module | Description | |-------|--------|-------------| | 1.0-3.0 | Read `explore.md` | Peek + Decompose + Parallelize | | 4.0 | Read `patterns.md` | Pattern consultation + DTO convention | | 5.0-6.0 | Read `synthesize.md` | Plan generation + complexity check + validation | --- ## Execution Mode Detection (Agent Teams) @../_shared/team-mode.md Before Phase 3.0 (Parallelize), determine runtime mode: ```bash source "${CODEX_HOME:-$HOME/.codex}/plugins/cache/kodflow/kodflow-workflow/0.0.0-re61d6d4f6f77/skills/_shared/scripts/team-mode-primitives.sh" MODE=$(detect_runtime_mode) ``` Branch: - `TEAMS_TMUX` / `TEAMS_INPROCESS` → **TEAMS exploration** (below) - `SUBAGENTS` → legacy parallel Task-tool dispatch in `explore.md` (unchanged) ### TEAMS exploration Lead: `developer-orchestrator`. Spawn up to 4 exploration teammates via `developer-specialist-review` (one per axis), each with a read-only task-contract v1 block: ```text TaskCreate × 4: explorer-backend → scope: backend/domain explorer-frontend → scope: UI/assets explorer-test → scope: tests/ + conventions explorer-patterns → scope: ~/.claude/docs/ pattern consultation Each task: access_mode=read-only, owned_paths=[], acceptance_criteria=["return 5-10 essential files + findings"] ``` Wait for all 4 TeammateIdle → synthesize in Phase 5.0. Token ceiling ≤ 2x legacy (exploration is cheap). Fallback is byte-functionally equivalent. --- ## Auto Mode (`--auto`) When `--auto` is passed, ALL interactive checkpoints are skipped: - Phase 1.5 (validate scope) → AI decides scope internally - Phase 2.5 (validate objectives, explore.md) → AI decides decomposition internally - Phase 3.5 (propose approaches, synthesize.md) → AI picks the best approach itself - Phase 5.9 (risk review) → AI assesses risks internally - Plan is presented at the end for user review via ExitPlanMode The plan file gives a short rationale for each choice, one or two lines, under a "## Rationale" section so the user can review why choices were made. A rationale, not a transcript of the reasoning. **When to use `--auto`:** When you trust the AI's judgment and want speed over interaction. You always review the final plan before `/refine → /goal`. --- ## Project documents Before Phase 2, read the documents of `docs/manifest.json` (state: `bash "${CODEX_HOME:-$HOME/.codex}/plugins/cache/kodflow/kodflow-workflow/0.0.0-re61d6d4f6f77"/skills/docs/scripts/docs.sh compute`, the `ok` ones) that concern the subject, as well as the ADRs: requirements for a feature, data schema for storage, threat model for auth or secrets, quality and testing for the acceptance criteria. A plan that contradicts one says so under `## Contradictions`, citing `fichier:ligne`, and proposes either amending the document or changing the plan; it never silently wins. --- ## Architecture decisions → `/adr` When the plan settles a non-obvious architectural trade-off (a new dependency or service, a layering/pattern choice, a public-contract or wire-format change, a notable perf-vs-simplicity call), record the *why* before implementing. After the plan is written, emit a textual `Suggested next step: /adr ` so the decision is captured as `docs/adr/NNNN-*.md` rather than lost. Routine implementation choices evident from the code do NOT warrant an ADR. --- ## Auto-Grouping (Parallelization Table) When generating the Parallelization table, the AI MUST: 1. Scan all files to modify 2. Map import/dependency chains between them 3. Group files that share NO dependencies into parallel steps 4. Flag shared files (package.json, go.mod, config) as sequential 5. Present groups with confidence level Auto-grouping is the PRIMARY method. Manual `worktree: yes/no` tags in the Parallelization table (see synthesize.md) serve as OVERRIDES when the AI's automatic grouping needs correction. Precedence: manual tags > auto-grouping. --- ## Execution Flow ``` Phase 1.0: Peek (RLM Pattern) → Recover context from .claude/contexts/ → Scan project structure → Identify relevant patterns Phase 2.0: Decompose (RLM Pattern) → Extract objectives from description → Categorize by domain → Order by dependency Phase 3.0: Parallelize (RLM Pattern) → Launch 4 parallel exploration agents → backend, frontend, test, patterns Phase 4.0: Pattern Consultation → Consult ~/.claude/docs/ for applicable patterns → DTO convention reminder (if Go) Phase 5.0: Synthesize (RLM Pattern) → Generate structured plan document → Persist to .claude/plans/{slug}.md → Persist context to .claude/contexts/{slug}.md → Add worktree parallelization table (if applicable) → Each exploration agent MUST return 5-10 essential files list Phase 5.5: Spec Self-Review (before submitting plan) → Placeholder scan: Any TBD, TODO, incomplete sections? → Internal consistency: Do sections contradict? → Scope check: Focused enough for single implementation? → Ambiguity check: Could any requirement be interpreted two ways? Phase 5.7: Complexity Check → If > 15 files, ask user to split Phase 5.8: Frontend Guidelines (conditional) → IF plan involves HTML, CSS, React, Vue, or frontend code: - "Commit to a BOLD aesthetic direction before coding" - "Choose distinctive fonts (AVOID: Arial, Inter, Roboto)" - "Use CSS variables for color consistency" - "Prioritize one well-orchestrated animation over scattered micro-interactions" - "FORBIDDEN unless the user or the project's design system requires it, named styles rather than 'avoid a generic AI look': purple gradients on white, predictable centered layouts, a cream or off-white background, italic accent words in headlines, numbered 01/02/03 section labels, monospace labels, pill-shaped buttons" - "Check the styles of the first result against that list, and add to the list (in the plan) every recurring default it shows that nothing requires, before the next iteration" - "Each design must feel context-specific, never cookie-cutter" Phase 6.0: Validation Request → Wait for user approval before /refine → /goal ``` --- ## HARD GATE (ABSOLUTE) ``` Do NOT invoke /refine → /goal, write any code, scaffold any project, or take ANY implementation action until the plan is approved by the user. This applies to EVERY task regardless of perceived simplicity. Anti-pattern: "This is too simple to need a plan" — EVERY task gets a plan. ``` --- ## Model allocation (mandatory, not negotiable) Read `../_shared/model-policy.md` and resolve the tiers **before** writing the plan: ```bash bash "${CODEX_HOME:-$HOME/.codex}/plugins/cache/kodflow/kodflow-workflow/0.0.0-re61d6d4f6f77"/skills/_shared/scripts/detect-models.sh ``` Every plan carries the allocation, in one line under its constraints: ``` Models: orchestrator @medium · code workers Sonnet @medium (@medium on a defect or hook code, Opus @medium across modules) · review workers Opus @high · mechanical workers Sonnet @low · workers never inherit the orchestrator model · worktree isolation wherever workers write concurrently. ``` Four rules the plan may not weaken: - **Resolve, never hardcode.** A hardcoded top model is wrong the day a better one ships. - **Never let a worker inherit.** On a top-tier orchestrator that silently runs every worker at the top rate — the single most expensive mistake available. Effort too: a worker with none runs at the session's. - **No gated model without the user's yes** (`gated-models.txt`, policy §6). - **The orchestrator never does the work.** If it is editing, the allocation has collapsed. A plan that omits, reworders or weakens this is rejected and rewritten. ## Guardrails (ABSOLUTE) | Action | Status | |--------|--------| | Skip Phase 1 (Peek) | **FORBIDDEN** | | Sequential exploration | **FORBIDDEN** | | Skip Pattern Consultation | **FORBIDDEN** | | Implement without approved plan | **FORBIDDEN** | | Plan without concrete steps | **FORBIDDEN** | | Plan without rollback strategy | **WARNING** | | Skip spec self-review | **FORBIDDEN** | | Start /refine → /goal before user approval | **FORBIDDEN** |