Prompt Chaining: Split Complex AI Tasks Into Steps
What prompt chaining is, when a chain beats one big prompt, common patterns and a worked business example, plus how to design handoffs, test and control cost.
Prompt chaining means splitting a complex task into a sequence of smaller prompts, where the output of one step becomes the input of the next. Instead of asking a model to read, analyse and write in one go, each prompt does one job, such as extracting facts, checking them or drafting a text. The result is usually more reliable, easier to debug and easier to improve, because you can see and test every intermediate result.
This article explains when a chain beats a single prompt, the patterns that cover most business tasks, a complete worked example and how to design the handoffs between steps. It builds on the method in our prompt engineering guide for business.
How a prompt chain works
A chain is a fixed sequence of steps. A typical one looks like this:
- Extract: pull the relevant facts from the source material.
- Check: verify the extracted facts, by code, by a second prompt or by a person.
- Draft: write the output using only the checked facts.
- Review: compare the draft against rules or a checklist.
Each step gets its own prompt with its own instructions, and receives only what it needs from the previous step. Some steps do not need a model at all: counting, sorting, looking up data in a database or validating a format is often better done by ordinary code.
One prompt or a chain?
| Single prompt | Prompt chain | |
|---|---|---|
| Setup effort | Low | Higher: several prompts and handoffs |
| Reliability on complex tasks | Varies, steps get skipped or mixed | Higher, each step is simple |
| Transparency | Only the final output is visible | Every intermediate result can be inspected |
| Fixing errors | Hard to tell where it went wrong | You can see which step failed |
| Speed | One call | Several calls, unless steps run in parallel |
| Cost | One larger call | Several smaller calls, partly on cheaper models |
When chaining helps
Consider a chain when you notice any of these:
- The prompt has several verbs. "Read these documents, find the risks, rate them and write a memo" is four tasks.
- Quality varies between runs. Sometimes the model covers everything, sometimes it skips parts.
- Instructions conflict. The extraction needs to be exhaustive, the final text needs to be short. One prompt struggles to do both.
- You need to check facts before they are used. A separate extraction step gives you something to verify. This is one of the most effective ways to reduce AI hallucinations.
- Different steps need different settings. One step needs strict JSON, another a natural writing style.
- The input is too long. Long documents can be processed section by section and then combined.
For a short email, a summary of one document or a simple classification, a single well-built prompt is enough. Chaining adds moving parts, so use it where it solves a real problem.
Common chain patterns
| Pattern | How it works | Business example |
|---|---|---|
| Extract, then write | Step 1 pulls facts into a fixed structure, step 2 writes from that structure only | Contract summary from extracted clauses |
| Classify, then route | Step 1 assigns a category, the next step depends on the category | Customer emails sent to different reply prompts |
| Draft, critique, revise | Step 1 drafts, step 2 checks against criteria, step 3 revises | Proposal text checked against a style guide |
| Split, process, combine | A long input is split into parts, each part is processed, results are merged | Summarising a long report chapter by chapter |
| Generate, then validate | Step 1 produces output, step 2 (code or prompt) validates format and content | Product data in JSON, validated before import |
Most real chains combine two or three of these.
Worked example: from customer feedback to a management summary
A company collects a few hundred free-text comments from a customer survey each month. Someone currently reads them all and writes a one-page summary for management. A single prompt ("summarise these comments") produces a fluent text, but it is hard to tell whether the themes are weighted correctly or whether a quote is real.
The chain:
Step 1: classify each comment. Run in batches, with a fixed list of topics.
Classify each customer comment below.
Topics (use only these): delivery, product quality, price, customer service, website, other.
Sentiment: positive, neutral or negative.
Return one JSON object per line:
{"id": "...", "topic": "...", "sentiment": "..."}
Comments:
"""
[ID 101] Delivery took nine days, nobody told me why.
[ID 102] ...
"""
Step 2: count. A spreadsheet or a few lines of code count comments per topic and sentiment. No model needed, and the numbers are exact.
Step 3: extract details for the top topics. For the three topics with the most negative comments, pass only those comments to the next prompt.
Below are customer comments about one topic: [topic].
List the specific problems mentioned, how many comments mention each,
and one short verbatim quote per problem with its comment ID.
Only use what is in the comments. Do not combine quotes.
"""
[comments for this topic]
"""
Step 4: write the summary. The writing prompt receives only the counts from step 2 and the details from step 3, not the raw comments.
Write a one-page summary for the management team.
Audience: managing director and department heads. Tone: factual, no marketing language.
Structure: three key findings, then one section per top topic with the main problems
and one quote each, then two to three suggested next steps.
Use only the figures and quotes provided. Do not add numbers.
Figures: """[output of step 2]"""
Details: """[output of step 3]"""
Step 5: check. Before the summary goes out, a person or a final prompt checks that every number and quote in it appears in the step 2 and step 3 outputs, using the comment IDs.
Every step is simple enough to test on its own. If a theme is missing in the final summary, you can see whether it was misclassified in step 1, dropped in step 3 or left out in step 4. Each step's prompt can be built with the AI prompt generator, which separates task, context, format and rules.
Designing the handoffs
The handoff between steps is where chains break. Some rules help:
- Use a fixed structure between steps. JSON, a table or fixed headings make the output of one step predictable input for the next. Plain prose between steps invites drift.
- Pass only what the next step needs. Sending everything defeats the purpose and increases cost.
- Keep the source available for checks. A verification step needs both the claim and the original text.
- Mark inputs clearly. Put material from earlier steps between delimiters and label it, so the model does not treat it as instructions.
- Define what happens on failure. If a step returns invalid output, retry once, then stop and flag the case instead of passing errors downstream.
Examples help a lot for the structured steps. A few labelled examples in the classification prompt make the categories far more consistent; see few-shot prompting.
Chaining in a chat tool versus in an automation
You do not need software to use a chain. In a chat assistant, you can run the steps manually: ask for the extraction, check it, then paste the checked result into a new prompt for the draft. This is a good way to design and test a chain before automating it.
In an automation platform or in code, each step becomes a node or a function call, intermediate results are stored, and validation runs automatically. At that point the chain is a workflow with AI steps, which is the approach compared in AI agents vs. workflow automation.
Testing a chain
- Test each step separately with a small set of realistic inputs, including difficult ones.
- Test the whole chain end to end on the same cases.
- Log intermediate outputs so you can trace any bad result to the step that caused it.
- Change one step at a time and re-run the test set, because an improvement in one step can break the next.
Cost and speed
A chain makes more model calls than a single prompt, so it is tempting to assume it costs more. Often it does not by much: each call is smaller, simple steps such as classification can run on a smaller, cheaper model, and steps without a model cost almost nothing. Speed can suffer if steps run strictly one after another; independent steps, such as processing several chapters, can run in parallel. To compare variants, estimate tokens per step and enter them in the LLM API cost calculator.
Common mistakes
- Chaining for its own sake. If one prompt works reliably, keep it.
- Free text between steps. Use a fixed structure for every handoff.
- Letting the writing step see the raw data. Then it can bypass the checked facts.
- Using a model for counting or lookups. Code is exact and cheaper.
- No failure handling. One bad step silently spoils everything after it.
- Testing only the final output. You lose the main advantage of a chain: knowing where things go wrong.
Summary
Prompt chaining turns one overloaded prompt into a series of simple, checkable steps. Use it when a task mixes different jobs, when quality varies, or when facts need checking before they are used. Design clear handoffs, let code do what code does better, and test each step. Start by writing down the steps of a task you already do manually, then build one prompt per step with the AI prompt generator.
FAQ
What is prompt chaining?
Prompt chaining splits a complex task into a sequence of smaller prompts. The output of one step becomes the input of the next, so each prompt has a single job and intermediate results can be checked.
When should I use prompt chaining instead of one prompt?
When one prompt has to do several different things, such as extracting facts, analysing them and writing a text, when quality varies from run to run, or when you need to check intermediate results. For simple, single-purpose tasks one good prompt is enough.
Does prompt chaining cost more?
It usually means more model calls, but each call is smaller and simple steps can run on a cheaper model. Whether the total rises or falls depends on the task; measure tokens per step and compare.
What is the difference between prompt chaining and an AI agent?
In a chain, you define the steps and their order in advance. An agent decides for itself which steps to take and which tools to use. Chains are more predictable and easier to test; agents are more flexible.
Related articles
- Prompt Engineering for Business: A Practical GuidePrompting8 min
- Few-Shot Prompting: When and How to Use ExamplesPrompting7 min
- How to Write a System Prompt (With Examples)Prompting7 min