# Prompt Chains and Templates

> How to split a big job into a chain of short prompts. How a template with blanks lets code send the same tested prompt each time.

**Course:** [Prompt Engineering](https://learn.benibix.com/learn/ai-working-with-ai)  
**Time:** 12 min

**After this lesson you can:**

- Split a task into a chain of short prompts
- Write a prompt template with blanks
- Check what goes into a blank before it is sent

## How a chain of short prompts beats one long one

Prompt chaining splits a big task into steps, each with its own short prompt. The output of one step becomes the input of the next. A prompt template is a prompt with blanks that code fills in. Together they let an app run the same tested steps thousands of times a day.

One long prompt that does everything is hard to fix. When the answer is wrong, you cannot tell which part failed. A chain of three short prompts can be tested one step at a time. Each step has one job, so each one is easier to get right.

A program runs the chain, and it can check the result between steps. Did step one return a list? Is every date real? If a check fails, the program can try that step again or stop, before a bad result flows down the rest of the chain.

A template keeps the fixed part of a prompt in one place and marks the parts that change. Blanks are often written in curly brackets, such as {name} or {question}. The code fills them in for each request. Fix the template once, and every request gets the fix.

Check what goes into a blank. A blank meant for a name can receive 5,000 words, nothing at all, or a line that sounds like an order. Put filled-in text inside tags, and set a length limit before the prompt is sent.

Chains also let you mix models. A small, fast model can sort or pull out facts in the early steps. A bigger model can do the one step that needs careful writing. Each step pays only for the model it needs.

The cost of a chain is time. Three steps in a row means three waits. If two steps do not depend on each other, run them at the same time. And keep the chain short, because every step you add is one more place to fail.

```text
You write short replies for {shop_name}.
Reply to the customer message in the message tags.
Keep it under {max_words} words. Sign it {signature}.

<message>
{customer_message}
</message>
```
Four blanks in curly brackets. The code fills them in, and the customer's words stay fenced inside their tags.

![Three prompt boxes in a row: sum up the meeting, pull out the tasks, and write an email for each task. The output of each box feeds the next, with a check between the steps.](https://learn.benibix.com/diagrams/pr-prompt-chain.svg)

### Example: Emma turns meetings into tasks

Emma's tool runs three prompts on each meeting. One sums it up, one pulls out each task and its owner, and one writes an email to each owner.

When some tasks came back with no owner, she fixed step two alone. The other two prompts did not change, and her 12 test meetings all passed again.

**Words in this lesson:** [Prompt Chaining](https://learn.benibix.com/term/ai/prompt-chaining), [Prompt Template](https://learn.benibix.com/term/ai/prompt-template)

**Question:** Why split one big AI task into a chain of smaller prompts?

**Answer:** Each step can be tested and checked on its own. Short steps with one job each are easier to test and fix. A check between steps stops a bad result before it reaches the end.

---

Source: https://learn.benibix.com/learn/ai-working-with-ai/prompt-chains-and-templates
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
