// Foundations · ~12 min
Plan-and-Execute
Reach for it when: When you can sketch the whole plan before touching tools.
// 60-second mental model
How to hold it in your head
Write the whole plan first. Then run the steps. Only replan when a step actually fails — not after every tool call.
Plan-and-Execute separates a planner (decompose goal → ordered steps) from an executor (run tools per step), with optional replanning on failure.
// Mini architecture
Plan once → execute steps → replan only on failure
┌──────────────┐
│ User goal │
└──────┬───────┘
▼
┌──────────────┐
│ Planner │ → step list (1..n)
└──────┬───────┘
▼
┌──────────────┐ tool / MCP ┌────────────┐
│ Executor │ ─────────────► │ Step result│
│ (next step) │ ◄───────────── │ │
└──────┬───────┘ └────────────┘
│ step failed?
├─ yes → back to Planner
└─ no → next step or Final answerUnlike ReAct, reasoning between every tool call is optional — the plan carries the sequence until reality breaks it.
// Mini-project
Multi-step research brief (stub)
Claude Code + stub planner/executor
Goal: Produce a short brief from a fixed plan: search → outline → draft — replan only if a stub step returns failure.
- Accept a topic (e.g. “MCP auth patterns”).
- Planner stub returns three steps: `search`, `outline`, `draft`.
- Executor runs each step via stub tools (canned payloads).
- If `search` returns `{ ok: false }`, planner inserts a `narrow_query` step and continues.
- Stop when all remaining steps succeed; emit the brief.
- Log plan vs. executed steps so you can see replans.
Stubs are enough. The lesson is the contract: plan up front, execute in order, replan only on explicit failure.
// Common failure
What goes wrong
Symptom
Replanning after every tool call — Plan-and-Execute collapses into expensive ReAct.
Fix
Replan only on hard failure or a missing prerequisite. Soft uncertainty stays on the current plan.
// Self-reflection
Sit with this
Where do you already know the steps — and still pay for a reason-loop on every call?
Session only. Nothing is saved.