Build a Prompt Template Library for Your Team
Hands-on lab · IDE in your browser

Build a Prompt Template Library for Your Team

Turn a team's copied-around prompts into one shared prompt library, without code: templates with declared variables, a shared house-style partial so rules live in one place, customer text fenced off against prompt injection, and an optional channel variable with a default, all run against the team's test cases and new ones the library has never seen.

Time
45 min
Checked steps
5
Level
Beginner
Setup
None
Read step 1

Hands-on labs require Pro · $29.99/mo · cancel anytime

Lab cockpit45 min · 5 stepsSession running
3 / 5 steps passingOne template, two channels · step 4 of 5
templates.yaml▶ Run✓ Check
partials:  house_style: |    You write replies for Brightline Books customer care.    Rules for every reply:    - Address the customer by name and quote the order number.    - Apologise once, plainly. Never use exclamation marks.    - Never promise money: no refunds, vouchers, discounts, compensation or free items, and no amounts      or percentages. Do not mention them at all, even to say no. Say a colleague will review the order      and reply within two working days.      Reply with the message only. templates:  late_order:    description: A parcel is late; the customer has asked where it is.    variables:      customer_name: {required: true}      order_id: {required: true}      days_late: {required: true}     prompt: |      {{> house_style}}      Write a reply to {{customer_name}}, whose order {{order_id}} is {{days_late}} days late.      Say we have asked the courier to trace it.   damaged_item:    description: Something arrived damaged.    variables:      customer_name: {required: true}      order_id: {required: true}      item: {required: true}     prompt: |      {{> house_style}}      Write a reply to {{customer_name}}: {{item}} in order {{order_id}} arrived damaged.      Name the item. Ask them to reply with a photo of the damage.   reply_to_message:    description: Reply to whatever the customer wrote.    variables:      customer_name: {required: true}      order_id: {required: true}      customer_message: {required: true} 
TerminalOutput

The job

Brightline Books' customer care team answers a hundred emails a day with an AI assistant, each person using prompts copied from their own notes. Replies sound different, and last week Mr Okafor received an apology addressed to Mrs Patel. You build the team one shared library of prompt templates, with the house rules in one place and customers' own words fenced off from the instructions.

5 steps, each checked when you finish it

A check runs your work at the end of every step. Hints and the full solution are there if you get stuck.

  1. 1

    Variables, not copies

    Brightline Books' customer care team answers a hundred emails a day with an AI assistant.

  2. 2

    One house style

    Every reply has to follow policy.md: name and order number, one plain apology, no exclamation marks, no promises of money, at most 110 words, and the team sign-off.

  3. 3

    The customer's own words

    The most useful template puts what the customer actually wrote into the prompt.

  4. 4

    One template, two channels

    The team now answers some customers by text message.

  5. 5

    The team uses it

    The library goes to the whole team.

Step 1 as it appears in the lab

The lab’s own text. The hint and the solution stay inside the lab.

Step 1: Variables, not copies

Brightline Books' customer care team answers a hundred emails a day with an AI assistant. Each person keeps their own prompts in a notes file and copies them around, so every reply sounds different, and last week a customer called Mr Okafor received an apology addressed to Mrs Patel. You will build one shared prompt library: templates with named blanks that anyone on the team can fill. There is no code: you edit templates.yaml.

A template is a prompt with variables: {{customer_name}} is replaced by the value for each customer. run_tests.py fills the templates with the team's test cases in team_cases.jsonl, sends them to the model and checks each reply.

Do this:

  1. Open templates.yaml. late_order is a prompt copied from one real reply to Mrs Patel.
  2. Replace her details with {{customer_name}}, {{order_id}} and {{days_late}}, and declare each one under variables:, as in customer_name: {required: true}.
  3. Click Run. It fills the template for three customers.

The check needs all three replies to name their own customer and order, and none to mention Mrs Patel or her order.

templates.yaml, the file you edit14 lines
# The customer care team's prompt library. Each template turns a few values into a prompt;
# run_tests.py fills them with the team's test cases and checks every reply against policy.md.
#   {{name}}        a variable: declare it under variables (required unless it has a default)
#   {{> name}}      a partial: a shared block from the partials section

templates:
  late_order:
    description: A parcel is late; the customer has asked where it is.
    variables:
      # TODO (Step 1): declare the variables this template needs, e.g.  customer_name: {required: true}
    prompt: |
      # TODO (Step 1): this prompt was copied from one real reply. Replace the details with variables.
      Write a reply to Mrs Patel, whose order BL-40211 is 5 days late.
      Say we have asked the courier to trace it.
Provided for you:library.pypolicy.mdrun_tests.pyteam_cases.jsonl

Frequently asked questions

Do I need to code for this lab?

No. You edit templates.yaml, a text file, and click Run. A small harness fills the templates, calls the model and checks each reply against the team's policy.

What is a partial in a prompt template?

A block written once and included in many templates, such as the house style rules. Changing the partial changes every template that uses it.

How do templates defend against prompt injection?

By putting the customer's text between clear delimiters and saying that anything inside is from a customer, never an instruction. In the lab, messages with planted refund approvals and admin tags get ordinary replies.

Why give a variable a default?

So existing callers keep working. Adding channel with a default of email lets the team send text messages through the same templates without changing any email case.

Prompt templates a whole team can reuse

Teams that use AI every day end up with dozens of copied prompts that drift apart. A prompt library fixes that: templates with named variables, shared blocks for rules that apply everywhere, and test cases that show a template still works after someone edits it. In this lab you build one without code. You replace copied details with declared variables, move the house style into a shared partial, fence customer text off from your instructions so planted instructions cannot take over, add an optional channel variable with a default, and run the library against cases it has never seen.