Workflows
Prompt Chaining
Prompt chaining is breaking a task into a sequence of smaller prompts, where the output of each step becomes the input to the next. Each step does one job well, and you can inspect, test or fix any link without rewriting the whole thing.
- Best for
- Multi-stage work: research → outline → draft → edit
- Difficulty
- Intermediate
- Updated
What is Prompt Chaining?
A single prompt that says “research this, outline it, write it and fact-check it” asks the model to juggle four jobs at once, and when the result is weak you cannot tell which job failed. A chain gives each job its own prompt, its own output and its own check.
The most valuable part of a chain is often not the prompts but the gates between them: a cheap check (does the JSON parse? are there at least five quotes? does every claim cite a source?) that stops a bad intermediate result before it contaminates everything downstream.
When to use it — and when not to
Use it when
- The task has natural stages with different goals: extract, analyse, write, review.
- You need to check or edit intermediate results — an outline approved before the draft is written.
- Different steps suit different models or settings: a cheap model to extract, a stronger one to write.
- One long prompt keeps dropping instructions.
Skip it when
- A single clear prompt already gets it right — each extra step adds latency and cost.
- Steps that need each other’s full context to make good decisions; splitting them loses information.
- Open-ended exploration where you don’t know the steps in advance — that is an agent loop, not a chain.
Copyable template
STEP 1 — EXTRACT
From the source below, extract every [ITEM, e.g. customer quote about pricing] as JSON:
[{"quote": "...", "source": "...", "theme": "..."}]
Source: [PASTE SOURCE]
GATE: valid JSON, at least [N] items. Otherwise stop and fix.
STEP 2 — ORGANISE
Group these items into 3–6 themes. For each theme give a name, a count and the 2 strongest quotes. Use only the items provided.
Items: [OUTPUT OF STEP 1]
GATE: every theme has at least one quote.
STEP 3 — WRITE
Goal (repeated from the start): [ORIGINAL GOAL AND AUDIENCE]
Write [DELIVERABLE] using only the themes and quotes below. No facts that are not in them.
Themes: [OUTPUT OF STEP 2]
STEP 4 — CHECK
List every claim in the draft and the quote that supports it. Mark any unsupported claim and rewrite or remove it.
Draft: [OUTPUT OF STEP 3]
Evidence: [OUTPUT OF STEP 1]
Two habits make chains reliable: pass structured data (JSON, numbered lists) between steps, and repeat the original goal in later steps so it is not lost.
Replace everything in [SQUARE BRACKETS] before you run it.
Worked example: Twelve customer interviews into a product brief
A product manager has twelve interview transcripts and needs a two-page brief on why customers churn, with evidence for every claim.
Step 1 (cheap model, run per transcript): extract quotes about leaving or nearly leaving, as JSON with speaker and theme. Step 2: cluster all quotes into themes with counts. Step 3 (strong model): write the brief for the leadership team from the clusters only. Step 4: claim-by-claim check against the quotes.
Step 1: 61 quotes from 12 transcripts (gate passed)
Step 2: 5 themes — onboarding confusion (19), missing integrations (14), price per seat (12), slow support (9), other (7)
Step 3: 2-page brief, "Onboarding is our biggest churn driver..."
Step 4: 14 claims checked; 1 unsupported ("most customers churn in month one") removed — no quote mentions timing.
Why it works: Each step is small enough to verify, the gate in step 4 caught a plausible but unsupported claim, and if the themes look wrong you rerun step 2 only.
Common mistakes
- No checks between steps. Errors compound: a bad extraction becomes a confident brief. Add a cheap gate after every step that can fail.
- Free-text handoffs. Prose between steps is hard to validate and easy to misread. Use JSON or numbered lists.
- Losing the original goal. By step four the model only sees step three’s output. Repeat the goal and audience in later prompts.
- Chaining what one prompt can do. Every link adds latency and cost. Split only where a step has a different job or needs a check.
- Passing everything forward. Sending all prior outputs into every step bloats context. Pass only what the next step needs.
Origin & sources
The term was popularised by Tongshuang Wu, Michael Terry and Carrie Cai (Google Research) in “AI Chains” at CHI 2022, which defined primitive LLM operations that can be linked, and found in a 20-person study that chaining improved output quality as well as users’ sense of transparency and control. Anthropic’s 2024 engineering essay “Building effective agents” describes prompt chaining with programmatic gates as one of the core agent workflows.
Try it on The Prompt Index
Frequently asked questions
What is the difference between prompt chaining and an AI agent?
In a prompt chain you decide the steps in advance and the order never changes. An agent decides its own next step at run time based on what it observes. Chains are more predictable; agents are more flexible.
How many steps should a prompt chain have?
As few as the task needs. Most useful chains have three to five steps; split a step only when it has a different goal or needs its own check.
Is prompt chaining the same as chain-of-thought?
No. Chain-of-thought is reasoning inside one response. Prompt chaining is several separate prompts, where each output is passed to the next prompt.
Do I need code to chain prompts?
No. You can run a chain by hand in any chat tool by pasting each output into the next prompt. Code helps when you run it often, because it can apply the checks automatically.