Breaking Tasks into Steps and Prompt Chaining

Updated · 4 min read
mediumPython 3.13aipromptsprompt-chainingprompt-engineeringinterview

Why does "write my whole talk" go wrong so often? Srihitha asks an assistant to turn her messy notes into a five-minute talk in one prompt. The result sounds polished, but it skips her best point and adds a statistic that isn't in her notes. One big step hid two mistakes.

This lesson shows a better way: break the task into steps, and chain small prompts together.

Prompt Chaining

Prompt chaining means splitting a task into smaller prompts, where the output of one becomes the input of the next. Each step is simple enough for the model to do well and for you to check.

Four small prompts instead of one big one

Clear Steps Inside One Prompt

Sometimes you don't need separate prompts, just clear steps inside one prompt:

text
Help me decide between two laptops for school.
Step 1: List what matters for a student who writes essays and runs small Python programs.
Step 2: Compare the two laptops below on each point, in a table.
Step 3: Recommend one, in two sentences, and say what would change your mind.
[laptop details pasted here]

Numbered steps make the model work through the problem in order, and make it easy for you to see where its reasoning went wrong. Reasoning models do some of this on their own, but explicit steps still help you check the work.

When to Chain

Chain when...Example
The task has distinct stagesResearch, outline, draft, edit
Each stage needs checkingExtracting facts before writing about them
Different stages need different instructionsA strict extraction step, then a creative writing step
You will reuse a stageThe same "extract key points" step for many documents

Common Mistakes

Passing a bad output to the next step. Check each output before you feed it forward.

Chaining a simple task. A one-line question doesn't need four steps.

Losing the original source along the way. Give the final check step the original notes, not just the latest draft.

Interview Corner

What is prompt chaining?

Splitting a task into a sequence of smaller prompts, where each output becomes the next input. It improves quality and makes each step easier to check and fix.

What is the difference between task decomposition and prompt chaining?

Task decomposition is breaking a problem into steps, which can happen inside one prompt. Prompt chaining runs those steps as separate prompts, passing outputs along.

Practice

Exercise: chain a real task. Pick a task you would normally do in one prompt, such as planning a trip or writing a cover letter. Design a three- or four-step chain, run it, and check each output before the next step. Which step needed fixing, and would you have noticed in a single prompt?

Check your understanding:

  1. What is prompt chaining?
  2. Why is the final "check" step useful?
  3. When is chaining not worth it?

Quick check: prompt chaining

4 questions
1What is prompt chaining?
2Why does chaining help?
3What should the final step of a writing chain often be?
4When is chaining usually unnecessary?

Key Takeaways

Quick reference

TermMeaning
Task decompositionBreaking a task into steps
Prompt chainingRunning steps as separate prompts, passing outputs along
Check stepA final prompt that compares the result with the source

Was this tutorial helpful?

Lesson 38 of 186