What it is
Prompt chaining decomposes a task into a fixed sequence of steps, where each LLM call processes the output of the previous one. You can add a programmatic 'gate' between steps — a check that the intermediate result is good enough before continuing.
How it works
Input
└─▶ [ LLM call 1 ] ──▶ (Gate: pass?) ──no──▶ stop / fix / branch
│ yes
▼
[ LLM call 2 ] ──▶ ... ──▶ OutputThe whole path is written in code. The LLM only fills each step; it never decides the order. That is exactly what makes this a workflow, not an agent.
When to use it
Ideal for situations where the task can be easily and cleanly decomposed into fixed subtasks. — Anthropic
- The subtasks are known up front and always run in the same order.
- You're willing to trade extra latency for higher accuracy on each step.
- A later step depends on a clean, validated result from an earlier one.
Trade-offs
- More calls = more latency and cost than a single prompt.
- Rigid: the path is fixed, so it can't adapt to inputs it wasn't designed for.
- Errors propagate — a bad early step poisons the rest, which is why gates matter.
Concrete examples
- Generate marketing copy, then translate it into another language.
- Write a document outline, validate it against criteria, then write the full document.
- Anthropic's appendix: drafting then editing follows the same shape.