Prompt template
A prompt template is a parameterised prompt — a string with named slots (e.g. {{name}}, {{context}}) that get filled at runtime so the same skeleton can serve many requests.
Prompt templates separate the static prompt skeleton (instructions, examples, tags) from the per-request variables (user input, retrieved documents, current date). Modern frameworks (LangChain ChatPromptTemplate, Jinja-style prompts, PromptLayer, Braintrust) standardise the format. Templates enable prompt versioning, A/B testing, and centralised prompt registries. The simplest template is f-string interpolation; the most sophisticated supports conditional sections, looped few-shot, and validated variables. Treating prompts as templates is the gateway to treating prompts as code.
When to use prompt template
- Any production LLM feature with variable input.
- Multi-tenant or multi-language prompts.
- Centralised prompt registry + versioning.
Common mistakes
- Hard-coding inline strings everywhere instead of using a template.
- Letting untrusted user input land directly inside the template without escaping.
FAQ
What is prompt template?
A prompt template is a parameterised prompt — a string with named slots (e.g. {{name}}, {{context}}) that get filled at runtime so the same skeleton can serve many requests.
When should I use prompt template?
Any production LLM feature with variable input. Multi-tenant or multi-language prompts. Centralised prompt registry + versioning.
What are the most common mistakes with prompt template?
Hard-coding inline strings everywhere instead of using a template. Letting untrusted user input land directly inside the template without escaping.
Related terms
- Prompt engineering — Prompt engineering is the practice of designing input text that reliably steers a large language model toward a specific output.
- Prompt versioning — Prompt versioning is the discipline of treating prompts as source-controlled artefacts — each prompt has a versioned ID, a deploy history, and a regression-tested change log.
- System prompt — A system prompt is the high-priority instruction block that defines a model's role, constraints, and default behaviors for an entire conversation.
- Evals (LLM evaluations) — Evals are systematic tests that measure how well a language model or LLM-powered system performs on a defined task using a golden set of inputs and reference outputs.
Last updated: 2026-06-01. Raw markdown: https://promtable.com/glossary/prompt-template.md.