CONCEPT One hard prompt → a sequence of simple ones
Prompt chaining is breaking a complex task into a sequence of simpler subtasks, where each prompt is a separate API call and each step's output feeds the next step's input. The alternative — cramming everything into one giant prompt ("summarize, then fact-check, then translate, then format") — forces the model to juggle every requirement at once, and quality degrades as instructions compete for attention.
Anthropic's guidance is nuanced for current models: with adaptive thinking and subagent orchestration, Claude handles much multi-step reasoning internally. Explicit chaining (separate API calls) is still valuable when you need to inspect intermediate outputs or enforce a specific pipeline structure — logging, evaluating, or branching at each hop.
CONCEPT Why chains are more reliable and debuggable
| Property | One mega-prompt | Chained prompts |
|---|---|---|
| Accuracy | Requirements compete; each is done "okay" | Full attention per subtask → higher quality |
| Debuggability | A wrong final answer — but which step? | Inspect each step's output; isolate the failing hop |
| Traceability | One opaque call | Log / evaluate / branch at any point |
| Reuse | Monolithic, hard to repurpose | Steps recombine into new pipelines |
The most common chaining pattern is self-correction: generate a draft → have Claude review it against criteria → have Claude refine based on the review. Because each step is a separate call, you can capture and gate on the review before spending tokens on the refinement.
<draft>…</draft> so the next prompt knows exactly what it's operating on.DIAGRAM The self-correction chain
generate first pass"] S1 -->|"<draft> … </draft>"| S2["Step 2: REVIEW
check draft vs. criteria"] S2 -->|"<feedback> … </feedback>"| S3["Step 3: REFINE
apply the review"] S3 --> OUT["🟢 Final output"] S2 -.->|"inspect / log /
branch here"| DBG["🟠 Human or eval gate"] classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class OUT ok; class DBG gate;
CODE A three-step chain in code
Each step is its own messages.create call; the output of one is interpolated into the next,
wrapped in XML tags. You can inspect, log, or gate between any two hops.
import anthropic client = anthropic.Anthropic() def step(prompt): r = client.messages.create(model="claude-opus-4-8", max_tokens=2048, messages=[{"role":"user","content":prompt}]) return next(b.text for b in r.content if b.type == "text") # Step 1 — DRAFT draft = step(f"Draft a product-launch email from these notes:\n{notes}") # Step 2 — REVIEW (feeds on step 1's output, wrapped in XML) feedback = step(f"Review this draft for tone, clarity, and factual accuracy. " f"List concrete fixes.\n<draft>{draft}</draft>") # --- inspect / log / gate here before spending tokens on step 3 --- # Step 3 — REFINE (feeds on both prior outputs) final = step(f"Rewrite the draft applying every fix.\n" f"<draft>{draft}</draft>\n<feedback>{feedback}</feedback>")
TRADE-OFFS Explicit chain vs. one call (or internal reasoning)
✅ Explicit prompt chain
- Inspectable intermediate outputs — easy to debug
- Enforces a fixed pipeline; gate/branch per step
- Higher accuracy on genuinely multi-stage tasks
⚠️ Cost of chaining
- More API calls → more latency and tokens
- Orchestration code to write and maintain
- Often unnecessary — adaptive thinking handles many multi-step tasks in one call
EXAM TRAPS
<draft>, <feedback>) so the next step cleanly separates the carried
content from its new instruction.PRACTICE
Q1 · A single prompt that summarizes, fact-checks, and translates produces mediocre results. Why does splitting it into three calls help?
Each subtask gets Claude's full attention instead of competing with the others, so quality per step rises. Just as important, you can inspect each intermediate output and see exactly which step (summary, check, or translation) is failing — impossible with one opaque call.
Q2 · Describe the self-correction chain and why each step is a separate API call.
Draft → review against criteria → refine from the review. Keeping the steps as separate calls lets you log, evaluate, or branch at any point — e.g. gate on the review before paying for the refine step, or loop the review until it passes.
Q3 · When is explicit chaining not worth it on current models?
When the multi-step reasoning is internal and you don't need to see or enforce the intermediate structure — adaptive thinking and subagent orchestration handle it in one call, saving the extra latency, tokens, and orchestration code that explicit chaining adds.