Prompt Templates: Build Reusable AI Prompts
A prompt template is a reusable prompt with placeholders that get swapped out for different inputs. Instead of writing a fresh prompt every time, you design one template that works across dozens β or thousands β of use cases.
From One-Off to Reusable
Real-world usage rarely means crafting one prompt at a time. You might need to summarize 500 customer tickets, extract data from 200 resumes, or classify emails all day. Writing a unique prompt for each is impractical.
Templates separate the instructions (what to do) from the input (what to do it on):
Summarize the following support ticket in 2-3 sentences.
Focus on the customer's core issue and urgency level.
Ticket: {{TICKET_TEXT}}
The {{TICKET_TEXT}} placeholder is a variable β it gets replaced with actual content at runtime. The instructions stay constant; only the input changes.
Anatomy of a Good Template
Effective templates have three layers:
- Role and context β Who the model is and what itβs doing
- Instructions β The task, constraints, and output format
- Input variables β Clearly marked placeholders for dynamic content
<role>You are a senior technical recruiter.</role>
<instructions>
Evaluate the candidate profile below. Rate fit on a scale
of 1-5 for each requirement. Return results as JSON.
</instructions>
<requirements>{{JOB_REQUIREMENTS}}</requirements>
<candidate>{{CANDIDATE_PROFILE}}</candidate>
Using delimiters to separate these layers makes templates easier to read, debug, and maintain.
Including Examples in Templates
Templates become more powerful with embedded few-shot examples β sample input-output pairs showing the model exactly what you expect:
Classify the support ticket into one of: billing, technical, account, other.
<examples>
<example>
Input: "I was charged twice for my subscription"
Output: billing
</example>
<example>
Input: "The app crashes when I open settings"
Output: technical
</example>
</examples>
Ticket: {{TICKET_TEXT}}
Two to five diverse examples typically give the best balance of accuracy and token efficiency.
Tips
- Name variables descriptively β
{{CUSTOMER_FEEDBACK}}is clearer than{{INPUT}} - Version your templates β small wording changes can shift output quality, so track what changed and when
- Test with edge cases β try your template with unusual inputs to catch failure modes early
Templates handle single tasks well. But what about tasks too complex for a single prompt? Thatβs where chaining comes in.