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

greetings.md
Say hello to the user.

Run it:

promd greetings

Variables

Any unknown --flag value passed to promd becomes a template variable.

weather.md
Check the weather in {{city}}.
promd weather --city Berlin

If 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.md
Summarize this in 3 bullet points:

{{input}}
story.md
Write a story about {{topic}}
promd story summarize --topic Bananas

Structured output (frontmatter)

Add an output: section to tell the backend you want a JSON object back.

extract.md
---
output:
  title: "short title"
  priority: "low|medium|high"
---

Read the following text and return JSON.

{{input}}

In later steps, you can reference properties:

next.md
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

report.md
---
output:
  urgent: true|false
  summary: "brief summary"
---

Analyse this support ticket and classify it.

{{input}}
respond.md
{{#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.

plan.md
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 team

Partials

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.md

This is useful for shared context blocks you want to reuse across prompts without repeating yourself.

shared/persona.md
You are a concise technical writer. Always use plain language and short sentences.
summarize.md
{{> shared/persona }}

Summarize the following in 3 bullet points:

{{input}}
translate.md
{{> shared/persona }}

Translate the following to French:

{{input}}

If a partial file cannot be found, promptmd leaves the block empty and logs a warning.

On this page