Reusable Templates with Variables
A custom template is a prompt skeleton whose varying parts are Twig `{{ variable }}` slots, typed as string, number, or a fixed-choice select. Preview renders it before you spend a credit, every save creates an immutable version you can roll back to, and the app records which exact version produced each run.
If you keep retyping the same prompt scaffold and only changing a few words, you are doing manual work the app can do for you. A reusable template captures the structure once, exposes the parts that change as variables, and lets you fill those slots per run. Same expert framing, different inputs, consistent output.
By Andrei Bădulescu, Founder at VantagePrompt·Updated
A custom template is a prompt skeleton with named slots. You write the wrapping instructions, scoring criteria, tone rules, and output expectations once. The pieces that vary per task — a product name, a target audience, a code snippet — become variables. At run time you fill the variables and the template renders into a complete prompt that feeds the optimizer like any other input.
What syntax do template variables use?
Variables are written with double-brace placeholders, the Twig convention. Anywhere you write {{ name }} in the template body, the editor recognizes it as a variable and surfaces it as an input field. Templates also support a small set of logic tags — conditionals and loops — so a single template can branch on the values you pass in.
You are an expert {{ role }} writing for {{ audience }}.
Task: {{ task }}
{% if audience == "executives" %}
Keep it under 150 words. Lead with the bottom-line impact.
{% else %}
Explain the reasoning step by step.
{% endif %}
Return the result as a clean, scannable list.Each variable can be typed — string, number, or a select with fixed choices — and can carry a default value and a description. Typing the audience field as a select with executives, engineers, and customers means callers pick from a list instead of free-typing, which keeps reuse reliable. The editor extracts placeholders for you, so you do not maintain the variable list by hand.
Can I test a template before spending credits?
The editor includes a live preview that renders your Twig with the current variable values. Use it to confirm the placeholders resolve, the conditionals fire on the right branch, and the final text reads the way you intend — all before you spend a single credit on an optimization run. A Twig syntax error shows up inline in the editor instead of failing silently at run time.
What happens to old versions when I save?
Each save creates a new immutable version of the template; the previous one stays intact. That gives you a clean history and a rollback path — if a tweak makes outputs worse, restore an earlier version. Variables attach to the version, not the template, so renaming a variable does not corrupt past versions. The app also records which exact version produced any given run, so your history stays auditable.
Treat a template like code: small, focused edits per save. Because every save is a version, you can experiment freely and roll back the moment quality drops.
How do I reuse a template across many inputs?
Once a template exists, it appears in the optimizer's template picker. Select it, the variable inputs open, you fill them, and you run. The structure is fixed; only the variable values change. This is where reuse pays off — the same template drives ten different prompts without you rewriting the scaffold each time. When you have a batch of inputs that all share one structure, a template is the natural fit; see the batch guide for running many at once.
// Run 1
{ "role": "copywriter", "audience": "executives", "task": "summarize the Q3 launch" }
// Run 2
{ "role": "copywriter", "audience": "engineers", "task": "explain the new caching layer" }
// Run 3
{ "role": "copywriter", "audience": "customers", "task": "announce the pricing change" }Should I share a template or publish it?
A template starts private to you. You can share it directly with specific people — they get access in their own template picker without the template becoming public and without it being copyable as a fork. That keeps a team-tested template inside the team. Separately, you can make a template public so others can discover and copy it. Pick sharing when you want collaborators on your version; pick public when you want to distribute a copyable one.
| Distribution | Who gets it | Can they fork it? | Use it when |
|---|---|---|---|
| Private (default) | Only you. | n/a | The template is still being shaped. |
| Direct share | The specific people you name — it appears in their template picker. | No — it does not become public or copyable. | You want collaborators on your version, kept inside the team. |
| Public | Anyone browsing the marketplace. | Yes — others discover and copy it. | You want to distribute a copyable template. |
| Export bundle | Whoever you send the JSON to. | They recreate it under their own account. | Moving a template between accounts. Imports always land private. |
How do I move a template between accounts?
Export a template to a JSON bundle that contains the template metadata, its current version, and its variables. Import that bundle elsewhere to recreate the template under the importing account. Imported templates always land private regardless of how they were shared originally, so importing never accidentally exposes your work.
Variables are rendered inside a restricted sandbox — raw function calls are not allowed and dangerous constructs are stripped on save. Write your template to lean on plain variables, conditionals, and loops.
The payoff: define the hard part of a prompt once, expose the soft parts as typed variables, preview it, version it, and reuse it everywhere. For deciding which use case your template should target before you build it, read Choosing the Right Use Case.
Frequently asked questions
- What syntax do template variables use?
- Twig double-brace placeholders. Anywhere you write {{ name }} in the template body the editor recognises it as a variable and surfaces it as an input field. Templates also support a small set of logic tags — conditionals and loops — so one template can branch on the values you pass in.
- Can I constrain what callers put in a variable?
- Yes. Each variable can be typed as a string, a number, or a select with fixed choices, and can carry a default value and a description. Typing an audience field as a select keeps reuse reliable instead of letting callers free-type.
- What happens when I save a template twice?
- Each save creates a new immutable version and the previous one stays intact, which gives you a clean history and a rollback path. Variables attach to the version rather than the template, so renaming a variable does not corrupt past versions.
- Can I test a template without spending credits?
- Yes. The editor's live preview renders your Twig with the current variable values, so you can confirm placeholders resolve and conditionals fire on the right branch before running an optimization. Twig syntax errors surface inline rather than failing at run time.
- What is the difference between sharing a template and publishing it?
- A direct share gives named people access in their own template picker without the template becoming public or forkable — that keeps a team-tested template inside the team. Making it public lets anyone discover and copy it. Exported bundles always import as private, so moving a template never accidentally exposes it.
- Can a template execute arbitrary code?
- No. Variables render inside a restricted sandbox: raw function calls are not allowed and dangerous constructs are stripped on save. Write templates around plain variables, conditionals, and loops.
Sources
Put it into practice.
Run this technique in the optimizer.