Regimenta
Language: en

Prompt Chaining: What It Is, Examples and Patterns

Prompt chaining splits a large task into smaller, connected prompts. With six worked examples, common patterns and rules for handoffs, testing and 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, five more short examples 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:

  1. Extract: pull the relevant facts from the source material.
  2. Check: verify the extracted facts, by code, by a second prompt or by a person.
  3. Draft: write the output using only the checked facts.
  4. 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.

More prompt chaining examples

Five short chains you can try by hand in a chat assistant. In each, the output of one prompt is the input of the next.

Task Prompt 1 Prompt 2 Prompt 3
Answering a complaint Extract order number, product and reason as JSON With the returns policy pasted in, state which option applies and quote the clause Draft the reply using only the data and the option
Meeting minutes From the transcript, list decisions, tasks, owners and dates Flag tasks without an owner or a date Write the minutes and a follow-up email from the corrected list
Sales proposal Summarise the customer's needs from their emails Map each need to a service in your catalogue and mark the gaps Draft the proposal along that mapping
Blog article Propose an outline with the question each section answers Write each section separately, following the outline Check the full text against the style guide and list the changes
Contract review Extract deadlines, amounts, penalties and renewals into a table Compare each clause with your list of acceptable terms Write a risk summary for the person who has to sign

The first chain in full, with all three prompts:

Prompt 1
From the email below, extract: order number, product, reason for the
complaint and what the customer is asking for. Return JSON with these four
keys. If a detail is missing, write null.

Prompt 2
Case data: [JSON from prompt 1]
Returns policy: """[policy text]"""
State which option applies (refund, exchange, repair or none) and quote the
sentence of the policy you rely on.

Prompt 3
Draft a friendly reply to the customer, 120 words at most.
Use only this data: [JSON from prompt 1] and this decision: [result of prompt 2].
Do not promise anything that is not in the decision.

Between prompt 2 and prompt 3 there is a natural checkpoint: a person can approve the decision before anything is drafted.

Frameworks such as LangChain and no-code automation platforms take care of the plumbing around the prompts: passing results on, validating formats, retrying and logging. You do not need them to design a chain. Anthropic's guide Building effective agents lists prompt chaining as the first of its workflow patterns and recommends starting with direct model calls, because abstraction layers can hide the prompts and responses.

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

  1. Test each step separately with a small set of realistic inputs, including difficult ones.
  2. Test the whole chain end to end on the same cases.
  3. Log intermediate outputs so you can trace any bad result to the step that caused it.
  4. 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. If you want the model to reason more carefully inside a single step, that is a different technique: chain-of-thought prompting.

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.

What is an example of prompt chaining?

Answering a complaint in three prompts: the first extracts the order number and reason from the email, the second checks the returns policy for the option that applies, and the third drafts the reply using only those two results.

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

  1. Chain-of-Thought Prompting: How It Works, With ExamplesPrompting9 min
  2. Prompt Engineering for Business: A Practical GuidePrompting8 min
  3. Few-Shot Prompting: When and How to Use ExamplesPrompting7 min