Prompt Chaining
Prompt chaining is an orchestration pattern in which a complex task is decomposed into a sequence of smaller sub-tasks, each handled by a separate LLM call whose output is passed as input to the next step, forming a pipeline. Unlike a single monolithic prompt, chaining lets each call focus on one well-defined operation - extraction, classification, drafting, critique - which improves reliability because errors at one stage can be caught and corrected before propagating. The pattern is the backbone of most production AI agents and multi-step reasoning workflows.
Think of it like an assembly line in a factory: rather than one worker attempting to build an entire car alone, each station receives a half-finished part, performs one precise operation, and hands it to the next - the finished product emerges at the end, and a defect at station three is caught before it reaches station ten.
A practical example - summarise a document, translate the summary, then format it as bullet points:
import anthropic
client = anthropic.Anthropic()
# Step 1: summarise
summary = client.messages.create(
model="claude-opus-4-5", max_tokens=256,
messages=[{"role": "user", "content": f"Summarise: {long_doc}"}]
).content[0].text
# Step 2: translate
translation = client.messages.create(
model="claude-opus-4-5", max_tokens=256,
messages=[{"role": "user", "content": f"Translate to French: {summary}"}]
).content[0].text
# Step 3: format
bullets = client.messages.create(
model="claude-opus-4-5", max_tokens=256,
messages=[{"role": "user", "content": f"Reformat as bullet points: {translation}"}]
).content[0].text
Prompt chaining builds directly on Prompt Engineering - the quality of each link depends on well-crafted instructions - and is frequently combined with Chain of Thought reasoning within individual steps. It also underpins RAG pipelines, where retrieval and generation are distinct chained stages. The Context Window limit is the main engineering constraint: each intermediate result must fit within the next call's window.
You will encounter prompt chaining whenever you use an AI coding assistant that reads a file, proposes a plan, then writes code in separate steps, or whenever you build a workflow tool that automates research, writing, or data processing across multiple LLM calls.