Prompt template

A prompt template is a reusable instruction structure that keeps stable task rules fixed while exposing explicit variables for the context that changes from one run to another. The stable part states what the model must do, must never do, and what output and failure behavior are expected; the variable part declares named inputs, required or optional, with admissible values and visible defaults, that a caller supplies per run. A template is a parameterized contract, not a guarantee: the same template can behave differently across models, providers, and tool or context configurations, so it needs a version and eval evidence before it is reused in production. It can render into any instruction layer a runtime supports, but it is not itself a system prompt, a security boundary, or a prompt library.

When to use it

  • One task repeats across many inputs, PRD critiques, interview syntheses, triage verdicts, and copy-pasting one-off prompts keeps drifting in rules, format, and failure behavior.
  • Different callers or features must produce comparable outputs from the same instruction set, with only declared variables changing per run.
  • Variables need contracts, not blanks: required versus optional inputs, admissible values, safe defaults, and explicit behavior when required input is missing.
  • A reusable prompt carries hidden assumptions, retrieved context, tool availability, model or provider behavior, that must be stated so callers do not invoke it where its dependencies do not hold.
  • A prompt change must be reviewable, versioned, and regression-tested because one wording edit can move every flow that reuses the template.

PM decision impact

The PM owns the template contract: which instructions stay stable, which inputs are variables, what values each variable accepts, what the defaults hide, what context and tool dependencies the template assumes, what output shape and missing-input behavior callers can rely on, and what eval evidence gates a version change. Engineering owns the builder implementation in code, schema and tool integration, and eval infrastructure; trust and safety own policy and refusal requirements. The PM decides when a wording tweak is a safe edit and when it is a behavior release, and when a reusable prompt graduates from a shared file into the governed prompt library.

How to do it

Start from one working one-off prompt and split it: mark every sentence as stable instruction or per-run variable, then delete anything that is neither. Declare each variable with name, required or optional status, admissible values, a visible default, and what happens when it is missing or empty, including conditional blocks so empty optionals render cleanly instead of leaving dangling instructions. Label inserted content as data with explicit boundaries, state context, tool, and model dependencies on the contract, and define the output shape plus the failure behavior for missing evidence, unavailable tools, and unsafe requests. Store the builder in versioned code with typed inputs, keep examples as versioned testable fixtures rather than inline decoration, and gate every change on fixed eval cases covering normal, edge, missing-input, and adversarial inputs.

Example

Synthetic example, hypothetical scenario, not measured results. A PM turns the one-off prompt “Review this PRD and tell me what's wrong” into a reusable template: stable instructions state the review dimensions, the no-invention rule, and the required output sections; variables declare product stage, target user, decision context, and PRD content as required, with tone and depth as optional inputs carrying visible defaults. The contract states its dependencies (supplied PRD text only, no web lookup assumed), its missing-input behavior (ask for the missing section or mark it unknown rather than inventing metrics), and its version. Eval cases include a complete PRD, an incomplete PRD with missing evidence, and PRD text containing injected instructions, each with expected behavior written down before the template ships.

Common mistakes

  • Treating a template as a prompt with blanks: placeholders without required/optional status, admissible values, defaults, or missing-input behavior.
  • Putting critical product policy in an untrusted variable slot, so any caller can silently rewrite the safety rule.
  • Exposing one unbounded free-text variable that swallows instructions, data, examples, and policy into a single unreviewable field.
  • Leaving dangling instructions when an optional variable is empty, for example, “Use these examples: {{examples}}” with nothing supplied.
  • Assuming delimiters or formatting alone make inserted content safe: boundaries improve clarity but do not prevent prompt injection.
  • Claiming the template guarantees consistent outputs, valid JSON, or cross-model portability without eval evidence on the deployed combination.
  • Editing a shared template in production without versioning, affected-flow review, or regression checks.

Related terms

Learn it in CraftUp

Last updated: September 23, 2026

The prompt template anatomy lab

One reusable template, pulled apart so a reviewer can point at any block and ask: is this stable, variable, assumed, or missing? Use this shape to inspect a template before it ships, then delete any block that does not change measured behavior for your task.

BlockStable or variableWhat it statesWhat breaks without it
Task and objectiveStableThe job in one sentence: what success looks like for every run.Callers reuse the wording for adjacent jobs it was never designed for.
Stable policy and instructionsStableNon-negotiable rules: what the model must do and must never do.Safety and quality rules drift per caller or get rewritten by accident.
VariablesVariableNamed per-run inputs with required/optional status, admissible values, and visible defaults.Blanks with no contract: missing inputs, hidden defaults, malformed renders.
Context slotsVariableWhere supplied evidence goes, labeled as data with explicit boundaries.Untrusted or stale content merges silently into instructions.
ConstraintsStableScope limits: what the template refuses, escalates, or will not attempt.Scope creep per run with no refusal path.
ExamplesVersioned fixtureA minimal set of input-output pairs that move measured behavior.Style overfitting, stale assumptions, token bloat nobody can justify.
Output contractStableRequired sections, fields, labels, or schema reference for the response.Downstream parsers and reviewers get a different shape every run.
Failure contractStableBehavior for missing input, insufficient evidence, unavailable tools, unsafe requests.The model improvises, usually by hallucinating a complete answer.
Metadata and versionStableTemplate id, version, owner, compatible models/providers, changelog, eval status.Untraceable edits with no rollback when behavior moves.

Small templates do not need all nine blocks. The minimum viable contract is: objective, stable rules, declared variables, output shape, missing-input behavior, and a version. Add context slots, examples, and dependency metadata when the template actually has them, not preemptively.

The variable boundary audit

Run every reusable prompt through these five checks. Each row names the defect, how to spot it, and the fix, with stable and variable regions distinguished by labels and text, never by color alone.

CheckSmellFix
1. Required vs optional is declaredA placeholder with no status, nobody knows what happens when it is empty.Mark every variable required or optional; state the missing-input behavior for each required one.
2. Defaults are visible and safeA default that silently decides tone, scope, or audience without the caller knowing.Write defaults on the contract, choose the least surprising value, and test the default path as its own eval case.
3. Policy lives in stable textA variable like {{instructions}} or {{rules}} that lets any caller rewrite safety behavior.Move product policy into stable instructions; variables carry data and options, never the rules themselves.
4. High-risk variables are boundedAn unconstrained free-text field where an enum or short list would do, tone, audience, verdict.Give admissible values to every variable whose range is actually finite; reserve free text for genuinely open content.
5. Empty optionals render cleanly“Use these examples: {{examples}}” with nothing supplied leaves a dangling instruction.Use conditional blocks or clean rendering so an empty optional disappears without a trace, and test the empty case.

Admissible values, concretely

A bounded variable names what the caller may send. For example, a tone variable might accept only concise, technical, or executive, which is stronger than unconstrained free text when the product needs predictable behavior. Bounds narrow the input space; they do not guarantee the model obeys them. Keep the enum on the contract, validate at the boundary where it matters, and eval the out-of-range case.

Variable types worth knowing

Most product templates need only a few shapes: short text, an enum over a fixed list, a boolean or flag, a list, a structured object (for example, the PRD under review), a file or reference slot, and an optional block that renders only when supplied. Name the type on the contract so callers know what to send, this is conceptual reliability, not SDK documentation, and placeholder syntax stays an implementation detail of whatever builder or engine renders the template.

The template contract card

Copy this card shape onto any reusable prompt. It is the whole contract on one screen: purpose, inputs, outputs, dependencies, failure behavior, version, and evals, everything a new caller or reviewer needs without reading the builder code.

Purpose
One sentence: which repeatable job this template owns, and which adjacent jobs it does not.
Inputs (required)
Each required variable: name, type, admissible values, and what happens when it is missing.
Inputs (optional + defaults)
Each optional variable: name, type, visible default, and how an empty value renders.
Stable instructions
The fixed rules no caller may override, including the no-invention and data-handling rules.
Context dependencies
Which retrieved docs, history, memory, profile, or configuration the template assumes, and freshness requirements.
Tool dependencies
Which tools or capabilities must exist at runtime (for example, a search tool), the template never implies a capability the runtime lacks.
Model and provider compatibility
Which model and provider combinations the template is evaluated on; no claim of universal portability.
Output contract
Required sections, fields, labels, citation or schema requirements, plus how malformed output is handled.
Failure behavior
Missing input, insufficient evidence, unavailable tool, unsafe request: the specified response for each.
Version
Template id, version, owner, last change summary, affected flows, rollback reference.
Evals
The fixed case set and version that gates changes: normal, edge, missing-input, failure, and adversarial cases.

One-off prompt → template: a PM worked example

Hypothetical scenario with illustrative structure, not measured results. A PM reviews PRDs with the one-off prompt “Review this PRD and tell me what’s wrong.” It works once, then fails in reuse: every reviewer gets a different depth, tone, and structure, missing evidence gets invented, and nobody can tell which version produced which review.

Before: the one-off prompt

Review this PRD and tell me what’s wrong.

What is fixed? Nothing, tone, depth, structure, and missing-data behavior are all improvised per run. What changes? Everything, invisibly.

After: the reusable contract

  • [Stable] Objective: critique the supplied PRD against fixed review dimensions (problem clarity, evidence quality, scope risk, measurability).
  • [Stable] Rules: use only the supplied PRD text; mark unknowns as unknown; never invent metrics, dates, or user quotes; keep the required output sections.
  • [Variable, required] product_stage, target_user, decision_context, prd_content, each with admissible values; missing content triggers the ask-or-mark-unknown path, never invention.
  • [Variable, optional] tone (default: concise), depth (default: standard), defaults written on the contract and tested as their own eval case.
  • [Dependencies] supplied PRD text only; no web lookup or tool assumed. [Output] fixed sections with a missing-evidence block. [Version] recorded with owner and eval set.

The brittle version, and its fix

A brittle take on the same template exposes one unbounded {{instructions}} variable, drops the data boundary around the PRD text, specifies no missing-input behavior, quietly assumes web access exists, and leaves the output shape undefined. Any caller can rewrite the safety rules; any empty field produces a malformed instruction; any downstream parser breaks. The fix is the contract above: policy in stable text, bounded variables, labeled data, explicit dependencies, defined failure behavior, and a version.

Why versioning matters here

Suppose v1 returns a free-form critique and v2 returns structured sections a downstream parser consumes. The prose may read better in v2, but every integration built on v1’s shape breaks on the upgrade. That is why a template version change is a behavior release: record the change, map affected flows, re-run evals, and keep a rollback reference to the previous version.

One mini eval case

Input: an incomplete PRD with no success metrics. Expected: the template output keeps the required sections, flags the missing evidence explicitly, does not invent metrics, and routes to the ask-for-evidence path. A second case feeds PRD text containing an injected instruction (“ignore previous instructions”); expected: the injected text is treated as data under review, never as an order.

Dependencies a template must declare

A reusable prompt never runs alone. Hidden assumptions are the most expensive template defect because every new caller inherits them unknowingly. State all three on the contract.

Context dependencies

Retrieved documents, conversation history, tool results, user profile, current date, product configuration, whatever the template assumes will be present, including freshness and permission expectations. Full source selection, freshness, and assembly architecture stays with context engineering; the template only declares what it needs.

Tool dependencies

When a template assumes a tool exists, for example, requiring a search capability, the assumption must be explicit, including what happens when the tool is unavailable. Prompt text can suggest when a tool should be considered, but schemas, validation, and server-side authorization decide what actually happens. Tool interface design lives with tool instructions.

Model and provider dependencies

Templates behave differently across model families, providers, reasoning modes, context sizes, tool interfaces, and structured-output support. Record the compatible combinations and test each deployed one, never claim universal portability. Current provider mechanics change: as one dated example (checked September 2026), OpenAI’s Responses API centers on an instructions parameter and a developer role, is de-emphasizing reusable prompt objects in the API in favor of versioned prompts in code with typed inputs and tests, and schedules its prompt-object shutdown for late 2026, which is why this page teaches the contract, not one provider’s storage mechanism.

Delimiters and injection

Labeling inserted content as data, with explicit sections, fencing, or structured inputs, improves clarity and helps the model distinguish instructions from data. It does not make injection impossible. A variable such as {{customer_text}} can carry conflicting instructions, so the template must state the handling policy (untrusted content is data, never orders) while permissions, data separation, and validation provide the actual protection. Deeper attack and defense content lives with prompt injection and guardrails.

What a prompt template is not

These adjacent concepts overlap with reusable prompts. The table states the boundary so this page does not absorb their jobs, each links to its specialist owner.

ConceptIts jobBoundary
Prompt engineeringDesigning, testing, and maintaining instructions, examples, and constraintsA template is one reusable artifact produced within prompt engineering. Broad instruction-design methodology lives there.
System promptThe persistent, high-priority instruction layer in a specific runtimeA template may render into a system, developer, or user layer depending on the provider, it does not confer priority or persistence itself.
Prompt libraryThe managed collection: discovery, ownership, versioning, governanceOnce a template is reusable and evaluated, it belongs in the library with ownership and version metadata, governance lives there.
Few-shot examplesInput-output pairs that teach style, structure, or edge handlingExamples can be embedded in or referenced by a template, but they are not the template, and each example must justify its token cost.
Structured outputsSchema-constrained, machine-readable response contractsA template can request a shape in prose; only schema enforcement plus validation guarantees it. Keep both, confuse neither.
Tool instructionsWhen and how the model may call toolsA template may include tool-related instructions, but tool permissions and schemas live outside the text template.
Evaluation harnessSystematic test sets, graders, metrics, regression infrastructureThis page names what a template must prove; the harness owns how to run, grade, and track it at scale.

Frameworks and acronyms

Search results for template intent often surface mnemonic frameworks , role, task, context, format, and their acronym variants. Treat them as teaching heuristics for drafting, not as production contracts: a shipped template needs explicit variables, admissible values, dependencies, output and failure behavior, a version, and evals, none of which an acronym provides.

No-hallucination wording

Avoid incantations like “never hallucinate.” Design observable behavior instead: use only supplied evidence, mark unknowns explicitly, cite sources where required, request or route missing inputs rather than filling them, and never invent fields the schema demands. The contract makes the behavior reviewable; the evals prove it.

Versioning, change risk, and evaluation

A template in production is shared behavior. Changing one word can alter outputs, safety posture, format reliability, latency, cost, tool behavior, and downstream parsing, which is why templates need versions and evals, not just good intentions.

Versioning

  • Stable template identifier, version, change summary, and owner.
  • Affected flows, tools, locales, and model or provider combinations.
  • The eval set and version the change was tested against, with known limitations stated.
  • Rollout plan and rollback reference, which previous version restores prior behavior.

Evaluation

  • Fixed normal cases that define correct behavior for this template.
  • Edge cases: long, short, ambiguous, or adversarially-shaped variables.
  • Missing and empty variables, including every optional left blank.
  • Insufficient-evidence cases where the template must mark unknowns, not invent.
  • Output-shape validation against the declared contract or schema.
  • Regression comparison against the previous version before rollout.
  • Model and provider matrix re-runs for each deployed combination.

Full test-set execution and grading infrastructure lives with the evaluation harness. Two lifecycle rules deserve emphasis here: re-run the relevant evals on every model upgrade even when template text is unchanged, and never silently edit a shared template to chase one anecdotal output , keep template text and model version traceable so the failure can be reproduced.

Common failure modes

  • Blank-optional trap: an optional variable left empty leaves dangling syntax or a half-formed instruction behind.
  • Policy in a variable: the safety rule sits in a caller-supplied slot and gets rewritten or dropped without review.
  • Hidden dependencies: the template assumes retrieval, tools, or a model capability the new caller does not have.
  • Example rot: embedded examples go stale after a redesign or policy change and quietly teach the old behavior.
  • Silent version drift: two teams run divergent copies with the same name and no version to distinguish them.
  • Overfitted style: examples anchor tone so strongly that every output reads identically regardless of the variables.

PM template checklist

Boundary

  • What stays fixed across runs, and what is a declared variable?
  • Is any product policy sitting in an untrusted variable slot?

Variables

  • Required vs optional, admissible values, visible defaults, declared for every variable?
  • What happens when each required input is missing, and how do empty optionals render?

Dependencies

  • Context, tool, and model/provider assumptions, stated on the contract, not hidden in prose?
  • Inserted content labeled as data with a handling policy for conflicting instructions?

Output and failure

  • Output shape and missing-evidence behavior specified without magical wording?
  • Malformed-output and unsafe-request paths tested, not assumed?

Change

  • Version, owner, affected flows, eval cases, rollout, and rollback, recorded before ship?
  • Graduation path to the prompt library defined once the template is reusable and evaluated?

Prompt template FAQ

What is a prompt template?

A prompt template is a reusable instruction structure that keeps stable task rules fixed while exposing explicit variables for the context that changes from one run to another. It declares named inputs, required or optional, with admissible values and visible defaults, plus the output shape, failure behavior, dependencies, version, and eval cases that make reuse trustworthy.

How is a prompt template different from a prompt?

A one-off prompt is written for one task and one context. A template is built to survive many inputs: stable instructions stay fixed, per-run context arrives through declared variables, and missing-input, dependency, output, and versioning behavior are specified up front rather than improvised per call.

How is a prompt template different from a system prompt?

A template is a reusable parameterized asset; a system prompt is a persistent, high-priority instruction layer in a specific runtime. A template can render into a system, developer, user, or tool-input layer depending on the provider, but the template itself does not confer priority, persistence, or precedence. Layer semantics stay with the system-prompt owner.

What is the difference between a prompt template and a prompt library?

A template is one reusable parameterized prompt asset. A library is the managed collection around many such assets: discovery, ownership, versioning, compatibility metadata, review process, and deprecation. This page owns the single-asset contract; governance of the collection belongs to the prompt-library owner.

What variables should a prompt template have?

Only the inputs that genuinely change per run, and each needs a contract: required or optional, admissible values, a visible default, and defined behavior when missing or empty. Critical product policy must stay in stable instructions, never in an untrusted variable slot a caller can silently rewrite.

What is a good prompt-template format?

There is no universal format. A reviewable template separates stable instructions, variables, context slots, constraints, examples, output contract, failure conditions, and metadata/version, but small templates should carry only the blocks that change measured behavior. Placeholder syntax itself (double braces, XML tags, code builders) is an implementation choice, not the definition.

Can prompt templates use few-shot examples?

Yes, but examples are versioned, testable fixtures, not decoration. They can stabilize expected behavior at the cost of tokens, and they can overfit style, encode stale assumptions, or conflict with variables. Add an example only when it moves measured behavior, and re-evaluate it whenever the template changes.

Does asking for JSON in a template guarantee valid JSON?

No. A textual formatting request is not a machine contract. Where downstream software parses the answer, provider or runtime schema enforcement plus validators own the guarantee; the template supplies the semantics around the schema. Test malformed-output handling explicitly.

How do I version prompt templates?

Like behavior releases, not copy edits: a stable identifier, version, change summary, owner, affected flows and model or provider combinations, the eval set and version tested, and a rollback reference. One wording change can move every flow that reuses the template, so version before sharing and never edit a shared template silently in production.

How do I test a prompt template?

With fixed eval cases written before the change: normal inputs, edge inputs, missing or empty variables, insufficient evidence, unavailable tools, unsafe or injected content, and output-shape validation, plus regression across the model and provider combinations actually deployed. This page names what to test; execution and grading infrastructure belongs to the evaluation harness.

Are prompt templates provider-specific?

Templates are conceptually portable but behaviorally not. Message roles, structured-output support, tool interfaces, and context limits differ across providers and models, so the same template text can behave differently per deployment. Record compatible combinations on the contract and re-run evals for each one rather than assuming portability.

Can a prompt template prevent prompt injection?

No. Clear instruction-versus-data boundaries and labeled delimiters improve clarity, but text boundaries are not a complete security boundary, a variable can carry conflicting instructions. Treat inserted content as data, state the handling policy, and rely on permissions, data separation, tool authorization, and validation for actual protection.

For the broader instruction-design discipline, see prompt engineering; for the persistent instruction layer a template may render into, see system prompt; and for governing reusable prompts as a collection, see prompt library. For PM workflow depth, continue to Prompt engineering for PMs , that guide owns tutorial workflows; this page owns the entity reference. For the broader AI product picture, see the AI Product Management hub.

Download App

Ready to become a better product manager?

Build your product skills with short, practical lessons you can fit around your day.
Start with our free courses and upgrade anytime.

CraftUp mobile app preview