Table of Contents
Prompt chaining divides a complex job into focused prompts and passes structured output from one step to the next. It is useful when intermediate results need validation, different stages require different instructions, or several independent analyses can run in parallel.
The mechanism of creating prompt chains
In the previous lesson, you learned about the production line metaphor – each step handles a task and passes the result to the next step. Now let's delve into how this process actually works.
A prompt chain consists of three components:
1. individual prompts - each prompt performs a single, focused task. For example: "Extract key information from this document" or "Use that information to write a summary." It's that simple.
2. Connection - The output of this prompt becomes part of the input for the next statement. You actually copy the response from Step 1 and paste it into the statement in Step 2 (or if using a tool, the software will do this automatically).
3. Process Flow Logic - How do you decide which step to run next? Always follow a fixed sequence? Based on the results generated by the AI? Or perform multiple steps simultaneously? This is where prompt chain types come into play.
4 types of prompt chains
Not all sequences follow a straight line. Here are four patterns you'll use most often:
Sequential Chain
The simplest and most straightforward model: Step 1 → Step 2 → Step 3. Each step is performed in order, and the output is passed on to the next step.
Example - Blog post writing process:
- Step 1 : "Research topic [X] and list 5 key points along with their sources."
- Step 2 : "Based on this information: [output of Step 1], create an outline for your blog post consisting of 4 parts."
- Step 3 : "Write the entire blog post following this outline: [Output of Step 2]. Limit the length to under 1,200 words."
Each step is simple enough for AI to perform excellently. However, the final result—a well-researched and tightly structured blog post—is something that a single prompt would struggle to consistently produce.
Quick check : Why does this blogging process yield better results than using a single prompt like "Research and write a 1,200-word blog post on topic X"?
Answer : Try to think about which aspect each step allows the AI to focus on.
Conditional Chain
Here, the output of a step determines which prompt is executed next. Think of it like an "if. then." logical branch.
Example - Categorizing customer support requests :
- Step 1 : "Categorize this customer message as: payment, technical, or general inquiry. Message: [input content]"
- If it's "payment" → Step 2A : "Compose a payment-specific response to address [input]"
- If it's "technical" → Step 2B : "Diagnose this technical problem: [input]. List diagnostic questions."
- If it's a "general question" → Step 2C : "Compose a friendly general response for: [input content]"
The first step serves to guide the conversation. Each subsequent prompt is tailored to that category—resulting in a much higher quality response than using a generic prompt for all situations.
Parallel chain
The same input data is sent to multiple prompts simultaneously. The results are then checked and combined.
Example - Product evaluation analysis :
- Send the same review to three prompts simultaneously:
- Command A : "Analyze the emotional tone: positive, negative, or mixed. Explain your reasoning."
- Statement B : "Extract the specific product features mentioned and their corresponding ratings."
- Statement C : "Identify the factors influencing the reviewer's purchasing decision."
- Synthesis step: "Combine these three analysis results into a detailed product information report: [Result A], [Result B], [Result C]"
Parallel sequencing is very effective when you need multiple independent perspectives on the same dataset. each prompt operates independently and does not depend on other statements.
Iterative chain
The output is then fed back one step earlier, creating an iterative refinement process.
Example - Text refinement :
- Step 1 : "Write a first draft on [topic]"
- Step 2 : "Comment on this draft. List 3 specific areas for improvement: [Result of Step 1]"
- Step 3 : "Edit the draft based on these comments: [Result of Step 1 + Result of Step 2]"
- Repeat Steps 2 and 3 until the comments section concludes that "there are no major issues remaining."
Iterative structures provide gradual improvements—something difficult to achieve with a single prompt. However, it's important to note: set a limit on the number of iterations (usually 2-3 times) to avoid wasting tokens on insignificant improvements.
Quick test : Match each scenario with the most appropriate type of sequence: (a) translating a document and then proofreading the translation, (b) forwarding a support request form to the correct department, (c) asking three different AI models to review an essay.
Answer : (a) sequential, (b) conditional, (c) parallel.
Prompt chaining and internal reasoning are different
Prompt chaining is an observable workflow: separate prompts produce separate outputs, and the application or user decides how those outputs move between steps. A model's internal reasoning is not another workflow stage and should not be treated as a reliable audit trail.
When a step needs justification, ask for a concise rationale, assumptions, evidence, or a verifiable calculation—not hidden chain-of-thought. The important distinction is control: prompt chaining lets you inspect intermediate artifacts, apply validation rules, and rerun only the failed stage.
When is a chaining method more efficient than a single prompt?
Chaining isn't always the best solution. Here are some cases where this method is actually useful:
Use strings when:
- The task has three or more distinct phases (e.g., research, analysis, formatting).
- You need to verify the output before proceeding to the next step.
- Different parts of the task require different prompt styles.
- Output quality is more important than speed.
- You are building a workflow that can be repeated many times.
Use a single prompt when:
- Simple and clearly defined tasks (e.g., translate this sentence, summarize this paragraph)
- Speed is more important than quality.
- The current prompt has yielded results with a quality level above 90%.
- Adding extra steps only increases complexity without improving the output.
A helpful rule from Anthropic: "Start with the simplest solution possible and only increase complexity when absolutely necessary." Don't create prompt chains just because you want to. Use prompt chains when a single prompt doesn't produce satisfactory results.
Try this now: Classify your own prompt chain
Choose a practical task that you frequently perform and determine which type of prompt chain is appropriate. Open ChatGPT, Claude, or Gemini, and copy and paste the sample command below.
My earlier description was unclear. Here is a representative input:
[paste a non-sensitive example]
The required output format is:
[paste the desired structure]
Revise the workflow so that every step maps explicitly from this input to that output.
How to use it: Replace each bracketed placeholder with specific, non-sensitive information from your actual workflow. Define what a correct output must contain.
The response should provide a pattern choice, a workflow outline, exact prompts, data handoffs, and a verification strategy for the weakest link.
Next step: Test the workflow with one representative, non-sensitive input. Check the weakest stage before adopting it for repeated work.
If the result is too general: Add a real input example, an explicit output schema, and objective acceptance criteria. Do not paste confidential material unless the tool and data policy are appropriate for it.
If the workflow misunderstands the task, replace abstract descriptions with a representative input and an exact target format:
Tôi nhận thấy mình đã diễn giải chưa rõ ràng. Dưới đây là định dạng dữ liệu đầu vào thực tế: [dán một ví dụ thực tế]. Và đây là định dạng dữ liệu đầu ra mong muốn: [dán một ví dụ thực tế]
Concrete examples reduce ambiguity, but remove private or regulated data before using them with an external AI service.
Prompt-chaining checklist
- A prompt chain consists of three components: individual prompts, the connections between them, and the processing logic.
- There are four types of sequences: sequential (step-by-step), conditional (threading), parallel (branching), and iterative (refinement).
- The thought process takes place within a single prompt; the chain of commands connects multiple prompts—they complement each other, not compete.
- Prompt chains are most useful when tasks have several stages, require intermediate verification, or demand different types of prompts for each step.
- Keep simple tasks in one prompt when extra stages add no measurable benefit.
-
Question 1:
What type of string sends the same input to multiple prompts at the same time?
EXPLAIN:
Parallel sequencing distributes the same input to multiple prompts simultaneously, then aggregates the results. This method is useful when you need multiple perspectives or independent analyses of the same dataset.
-
Question 2:
In a conditional sequence, what factor determines which prompt will be executed next?
EXPLAIN:
Conditional sequences check the output of the previous step and navigate to different prompts based on the results obtained. For example, a customer support sequence might navigate to the "payment support" or "technical support" department depending on how the first step categorized the customer's request.
-
Question 3:
What is the main difference between chain-of-thought (CoT) and prompt chaining?
EXPLAIN:
Co-inference chaining (CoT) requires AI to infer each step within a statement. A prompt chain uses multiple separate statements, where the output of one statement becomes the input for the next. They complement each other – you can use CoT at each step of a prompt chain.
Reader Comments 0
Sign in with email or Google to join the discussion.