// 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 answer

Unlike 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.

  1. Accept a topic (e.g. “MCP auth patterns”).
  2. Planner stub returns three steps: `search`, `outline`, `draft`.
  3. Executor runs each step via stub tools (canned payloads).
  4. If `search` returns `{ ok: false }`, planner inserts a `narrow_query` step and continues.
  5. Stop when all remaining steps succeed; emit the brief.
  6. 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.