Skip to content

Prompt Templates and Variables

Building reusable prompts with placeholders for repeated tasks, and keeping templates safe and maintainable.

Editorial team 1 min read

For recurring tasks — summarising tickets, drafting replies, classifying documents — a prompt template with variables keeps quality consistent.

What a Template Looks Like

You summarise customer support tickets for the {team_name} team.
Summarise the ticket below in {max_bullets} bullet points, then give a priority: low, medium or high.

<ticket>
{ticket_text}
</ticket>

Code fills in the variables for each request.

Benefits

  • Consistent instructions across every use.
  • Easy to improve once and apply everywhere.
  • Versionable and testable.

Good Practice

  • Keep fixed instructions separate from variable inputs.
  • Delimit inserted content clearly with tags.
  • Validate and limit inserted values (length, allowed characters).
  • Provide defaults for optional variables.
  • Name variables clearly.

Security

Inserted content — user input, documents, emails — may contain instructions. Treat it as untrusted: delimit it, limit the assistant's capabilities, and validate outputs.

Version and Test

Store templates in source control. When changing a template, run it against a test set of real inputs and compare results.

Share Templates

For teams, a small library of approved templates for common tasks spreads good practice and reduces risky improvisation.

More in Prompting

All Prompting guides →
Prompting Guide · 1 min

Anatomy of an Effective Prompt

The parts of a prompt that reliably produce good results, with a template you can adapt for almost any task.

Prompting 1 min read 1 Nov 2025

Prompting Guide · 2 min

Giving Models Context

Why most weak outputs come from missing context, and what background information to include in a prompt.

Prompting 2 min read 31 Oct 2025

Prompting Guide · 1 min

Role Prompting: When It Helps and When It Doesn't

Telling a model to act as an expert or a persona can shape tone and focus — but it isn't a substitute for clear instructions.

Prompting 1 min read 30 Oct 2025