Prompts & Templates
Write prompt files and use variables
Promptmd runs Markdown files as prompts. A prompt file is just text, with optional YAML frontmatter.
Templates use Mustache syntax, so all standard Mustache features — sections, inverted sections, iteration, and partials — work out of the box.
Basic prompt
Say hello to the user.Run it:
promd greetingsVariables
Any unknown --flag value passed to promd becomes a template variable.
Check the weather in {{city}}.promd weather --city BerlinIf a variable is missing, promptmd keeps the placeholder (and warns in verbose logs).
Using {{input}}
When you chain prompts, the next step receives the previous step output in {{input}}.
Summarize this in 3 bullet points:
{{input}}Write a story about {{topic}}promd story summarize --topic BananasStructured output (frontmatter)
Add an output: section to tell the backend you want a JSON object back.
---
output:
title: "short title"
priority: "low|medium|high"
---
Read the following text and return JSON.
{{input}}In later steps, you can reference properties:
Make a plan for: {{input.title}} (priority: {{input.priority}})Sections
Use a section block to conditionally include content when a variable is truthy, or to iterate over a list.
Conditional blocks
---
output:
urgent: true|false
summary: "brief summary"
---
Analyse this support ticket and classify it.
{{input}}{{#urgent}}
This is urgent — respond within 1 hour.
{{/urgent}}
{{^urgent}}
Add to the backlog and respond within 3 business days.
{{/urgent}}
Ticket summary: {{summary}}{{#urgent}}...{{/urgent}} renders its content when urgent is truthy.
{{^urgent}}...{{/urgent}} renders its content when urgent is falsy or absent — the inverted (else) form.
Iterating over a list
When the variable is an array, a section repeats once per item. Use {{.}} to reference the current item, or named keys for objects.
Here are the tasks to complete:
{{#tasks}}
- {{.}}
{{/tasks}}If tasks is ["Write tests", "Deploy", "Notify team"], this expands to:
Here are the tasks to complete:
- Write tests
- Deploy
- Notify teamPartials
Use {{> name }} to include another prompt file inline. Promptmd loads <name>.md relative to the current working directory.
{{> name }} → ./name.md
{{> shared/intro }} → ./shared/intro.mdThis is useful for shared context blocks you want to reuse across prompts without repeating yourself.
You are a concise technical writer. Always use plain language and short sentences.{{> shared/persona }}
Summarize the following in 3 bullet points:
{{input}}{{> shared/persona }}
Translate the following to French:
{{input}}If a partial file cannot be found, promptmd leaves the block empty and logs a warning.