Topic 2 of 5 · 4 min read
Chaining prompts output to input
Goal: Design a three-to-five step prompt chain for a real task, naming what each step receives and produces.
A prompt chain is a series of prompts where the output of one step becomes the input of the next, and each step has a clear job. It is how you do a big task with a tool that does best on one small task at a time.
Check yourself · 1 of 3
In a prompt chain, what does the second step normally receive?
Why it matters
A single prompt for "write a report on our customer churn" asks the model to find facts, decide a structure, write, and polish, all at once. A chain gives each of those a turn. Each reply is shorter, easier to read and easier to fix. Anthropic's article on building effective agents describes this pattern, called prompt chaining, as a way to trade a little speed for accuracy because every step is easier.
How to do it
- Name the stages. For writing, a common chain is: gather facts, outline, draft, edit. For analysis: extract data, check it, interpret it, write it up.
- Define each hand-off. For every step, write down what it receives and what it must produce. "Step 2 receives the list of facts from step 1 and produces an outline of five headings."
- Pass only what the next step needs. Paste the output, not the whole conversation. A clean input gives a clean next step.
- Fix a fixed format between steps. If step 1 returns a table, say so, so step 2 can rely on it.
- Keep it to three to five steps. Longer chains add more places for errors without adding much.
You can run a chain by hand in a chat window, one message at a time, or in code. A short engineer version:
facts = ask("List the key facts in these notes as bullets:\n" + notes)
outline = ask("Make a 5-heading outline from these facts:\n" + facts)
draft = ask("Write a 400-word brief from this outline:\n" + outline)
Before and after
Before: Read these reviews and write a polished report with recommendations.
After: Step 1: pull out every complaint as a bullet with the review number. Step 2: group the bullets into themes and count them. Step 3: write three recommendations, one per top theme. Step 4: edit for a manager audience, 300 words.
What goes wrong
- Vague hand-offs. If step 2 gets a messy blob, it must guess what matters.
- Context pile-up. Pasting every earlier reply into every step wastes space and distracts the model.
- Errors that travel. A wrong fact in step 1 is repeated confidently in step 4. The checkpoints topic shows how to catch that.
Examples
A blog post chain
- Research: list 8 facts about composting in small flats, with the source of each.
- Outline: from those facts, make an outline with 5 headings.
- Draft: write 500 words following the outline; use only those facts.
- Edit: shorten to 400 words and make the tone friendlier.
Each step names its input and its output.
A support-ticket chain
- Extract the customer's problem in one sentence.
- Classify it as billing, bug or how-to.
- Draft a reply using the matching template.
The label from step 2 decides which template step 3 uses.
Key points
- A prompt chain passes the output of one step into the next, with one job per step.
- Write down what each step receives and what it must produce before you start.
- Pass only the output the next step needs, not the whole conversation.
- Three to five steps is usually enough; more adds places for errors.
- A mistake in an early step is repeated by every later step.
Common mistakes
- Starting a chain without deciding what each step hands to the next.
- Pasting the whole chat history into every step.
- Making the chain long when three steps would do.
- Letting step 1 return free text when later steps need a list or table.
Check yourself · 2 of 3
Which is a good chain for writing a short article?
Check yourself · 3 of 3
Step 1 of a chain returns a long, messy reply. What is the best fix before step 2?
Practice items, not counted towards your mastery.
Start here
- Building effective agents (Anthropic) (opens in a new tab)ArticleFree
Describes prompt chaining as a workflow and shows where to put checks between steps.
- Prompt chaining (Prompt Engineering Guide) (opens in a new tab)CourseFree
A short worked example of splitting a document task into two linked prompts.
- Prompt engineering guide (OpenAI) (opens in a new tab)DocsFree
OpenAI's guidance on clear instructions and breaking work into smaller steps.