How to write a prompt with variables that does not break
Turn a prompt you retype into a template. How to choose variable names, what to keep out of them, and how to find the missing ones before your AI does.
If you retype the same prompt and change two words, you have a template waiting to be written. A template has a fixed part and a few variables. In Prompt Verse a variable is any name in double braces, like {{customer_name}}.
Here is a way to do it that holds up.
Start from a prompt that already worked#
Do not design a template from nothing. Take a prompt you used last week and highlight the words that changed between uses. Those are your variables. Everything else is the template.
Reply to this customer in a friendly, short way. Their name is Sanne. Their order is A-1043 and it is two days late. They wrote: "Where is my order?"Reply to this customer in a friendly, short way.
Their name is {{customer_name}}.
Their order is {{order}} and it is {{days_late}} days late.
They wrote: "{{message}}"Name variables for what they hold#
{{message}} is better than {{text1}}. {{days_late}} is better than {{n}}. You, a colleague and your AI will all read these names, and the name is the only documentation a variable gets.
Use letters, digits and underscores. Keep names short and singular.
Keep rules out of variables#
A variable is for data that changes per use. A rule belongs in the prompt itself, preferably as a wrapper. If you notice a variable that is almost always the same value, it is not a variable, it is part of the template.
Put the awkward part last#
Models handle long free text best when the instruction comes first and the unknown data comes last. Variables that hold long text, like {{message}}, belong at the end of their section.
Find the missing ones before your AI does#
When you render a prompt in Prompt Verse, the result lists any variable you did not fill. That is the cheapest test there is: render with an empty set of values and read the list. It tells you exactly what the prompt expects.
Over MCP the same thing works for your assistant. It asks for the rendered prompt, sees which variables are missing and asks you for those values instead of guessing.
Check how it looks in other formats#
The same template can be rendered as Markdown, text, XML, JSON, YAML, HTML, CSV, TOML, JSONL, chat messages or Prompty. If you plan to send the prompt to an API that takes a message list, render it as messages once and read the output. Structure mistakes show up immediately.
A short checklist#
- Every variable has a name that says what it holds.
- No variable holds a rule.
- The long free-text variable comes last in its section.
- A render with no values lists exactly the variables you expect.
- The template is committed with a message.
That last line is the one people forget. Templates get edited more often than one-off prompts, so save the version that worked before you tidy it.