Skip to main content
Overdeck builds four of the prompts it sends to agents from versioned Markdown templates under src/lib/cloister/prompts/: the work agent’s kickoff, the Deft work agent’s kickoff, the planning agent’s discovery prompt and the model-to-model handoff prompt. A single loader, renderPrompt at src/lib/cloister/prompts.ts, is the only way code turns one of those templates into a finished prompt string. Role definitions are a separate system. They live in roles/<role>.md, and Overdeck reads them without this loader. See Prompts outside this loader. This page is the authoritative guide to that system: what the templates are, how the loader works, the frontmatter contract, the full template catalogue, and how to add, edit, or migrate a prompt without breaking production.

Why templates at all

Before the unified loader, prompts were assembled a dozen different ways: inline template literals in TypeScript, readFileSync of raw Markdown files, ad-hoc String.replace passes, and a pair of home-grown processIfBlocks / processEnvBlocks helpers. Each specialist invented its own variable syntax and its own idea of what an “optional” section looked like. That sprawl produced three recurring failures:
  1. Silent typos. A variable like {{issueId}} referenced in the template but named issue_id at the call site rendered as the literal string {{issueId}} in the prompt sent to Claude. No error, no warning: the specialist just got a broken prompt and ran on bad context.
  2. Drift between similar templates. The merge-agent prompt used by the full-push path and the wake-time validation path were two separate string builders that were supposed to stay in sync and didn’t.
  3. No way to see what a prompt expects. Finding the variables a template depended on meant reading the TypeScript call site line by line.
The template system fixes all three. Every template declares its variables in YAML frontmatter; the loader validates them on every render; missing or unknown variables fail with a PromptError that names the template path and the list of offending keys.

Core principles

Keep these five rules in mind when you touch any prompt template.

1. Fail loud, fail early

Missing a required variable is a programming error, not a runtime condition to recover from. The loader fails with PromptError, naming the template path and the list of missing keys. There is no silent fallback, no empty-string substitution, no “render partial output and hope nobody notices”. If you see a PromptError in a log, it means a call site is wrong and needs to be fixed, not that the loader needs a guard.

2. One template, one API

Code reads a template under src/lib/cloister/prompts/ only through renderPrompt({ name, vars }). If you find another read of one of these files, migrate it to renderPrompt. Role files under roles/ are read directly by design; see Prompts outside this loader.

3. Composition happens in TypeScript

Mustache is deliberately a small, logic-less templating language. The loader disables HTML escaping globally (Mustache.escape = (text) => String(text)) because we’re generating prompts for an LLM, not HTML. Everything else is vanilla Mustache with its usual section syntax. Any non-trivial composition (choosing between two instruction variants, joining an array of file paths, formatting a table of tasks) happens in TypeScript. The TypeScript builds a string, then passes that string to the template as a single variable. This keeps templates readable and keeps business logic in a place where tsc and your tests can see it.

4. Variables are declared, not discovered

Every variable the template’s body uses should appear in the frontmatter as either requires or optional. The loader rejects any key in vars that the frontmatter doesn’t declare, and any required key that is missing or undefined/null. Both errors name the template path and the offending keys. The loader never scans the body, so a {{VAR}} that the frontmatter leaves out renders as an empty string when the call site doesn’t pass it. This means the frontmatter tells you what a template expects, as long as authors keep it in step with the body.

5. Prompts are not docstrings

A prompt template is production code that steers an LLM’s behavior. Treat it accordingly: prefer explicit instructions over implicit assumptions, prefer concrete examples over abstract rules, and when you change a template, think about what’s going to happen the first time an agent runs it against a real workspace.

The renderPrompt API

Signature

The name is the filename under src/lib/cloister/prompts/ without the .md extension. renderPrompt({ name: 'work' }) loads work.md. renderPrompt returns an Effect. Run it with Effect.runPromise (as buildWorkAgentPrompt does), with Effect.runSync (as buildHandoffPrompt does), or yield* it inside Effect.gen.

What happens on every call

  1. Load. The file is read from disk on every call. There is no template cache; only the resolved prompts directory is cached.
  2. Parse frontmatter. The leading --- YAML block is extracted via js-yaml. Missing frontmatter, invalid YAML, or a missing name / description field all fail with PromptError, and so does a requires or optional value that isn’t a list of strings.
  3. Validate requires. Every key listed in requires must be present in vars and not undefined/null. Missing keys are collected and reported in one error message.
  4. Validate unknown keys. Every key in vars must be listed in either requires or optional. Undeclared keys are collected and reported in one error message.
  5. Render. The body is passed to Mustache.render(body, vars) with HTML escaping disabled.

Error handling

Every loading and validation failure is a PromptError, exported from the module. It’s an Effect tagged error (Data.TaggedError('PromptError')) and also an Error. renderPrompt fails its Effect with it, so Effect.runPromise rejects and Effect.runSync throws. Rendering is different: a body Mustache can’t parse, such as an unclosed {{#VAR}} section, throws Mustache’s own Error, which the loader does not convert to a PromptError. Typical PromptError messages:
Do not catch these. They indicate bugs in call sites or templates that must be fixed, not runtime conditions. The fail-loud posture is deliberate: if a call site is allowed to silently skip a required variable, the resulting prompt silently loses context and the agent silently does the wrong thing.

Prompts directory resolution

resolvePromptsDir() picks the directory once per process and caches the answer:
  1. join(__dirname, 'prompts'), next to the module that holds the loader. In dev that’s src/lib/cloister/prompts. A build copies the templates next to each bundle: dist/dashboard/prompts for the dashboard server, dist/prompts and dist/cli/prompts for the CLI.
  2. If that directory doesn’t exist, the resolver finds the package root (it strips everything from /src/ onward when __dirname contains /src/, otherwise it goes up two directories) and tries src/lib/cloister/prompts under it.
  3. If neither exists, it keeps the first path, and the first render fails with “Failed to load prompt template”.
See BUILD.md for how the build pipeline copies *.md from source to dist/dashboard/prompts/.

Frontmatter contract

Every template starts with a YAML frontmatter block delimited by ---. The loader enforces this structure: a missing or malformed block fails with PromptError before the body is rendered.

Fields

requires vs optional

The rule of thumb:
  • If the template’s output would be broken or misleading without the variable, list it as requires.
  • If the variable is genuinely a “fill this in if you have it, leave the section out otherwise” case, list it as optional.
requires is stricter than you might think: passing an empty string ("") satisfies the check. Only undefined and null fail. This is intentional. buildWorkAgentPrompt passes an empty ISSUE_ID when a recovery path has no issue id, and the prompt still renders. The caller is the one who decides whether “empty” is a legitimate value.

Unknown keys are an error

If vars contains a key that isn’t listed in requires or optional, the loader refuses to render. This catches two classes of bug:
  1. You renamed a template variable and forgot to update the call site.
  2. You added a new variable to the call site and forgot to declare it in the frontmatter.
Both show up as a single clear error message with the offending keys.

Mustache syntax reference

We use Mustache.js v4. HTML escaping is disabled globally, so {{VAR}} and {{&VAR}} behave identically and you never need to worry about &lt; or &amp; showing up in prompts.

Variable substitution

Truthy sections

Render the enclosed block if the variable is truthy (non-empty string, true, a non-empty array, an object). Empty strings and false hide the block.
Note the pattern {{#VAR}}{{VAR}}{{/VAR}}: that’s Mustache context fall-through: inside a truthy section, the variable itself is still accessible in the parent scope and gets substituted normally. This is how work.md hides its Specialist Feedback heading when PENDING_FEEDBACK is empty.

Inverted sections

Render if the variable is falsy/empty.
The merge template uses inverted sections extensively to toggle between validation-only and full-push flows from a single DO_PUSH boolean.

Boolean flags

Booleans work as expected inside {{#VAR}} and {{^VAR}}. They are the cleanest way to toggle whole sections of a template based on a flow decision made in TypeScript.

No partials, no lambdas, no custom helpers

Mustache supports partials and lambdas; we don’t use them. Composing from smaller template fragments would push the contract across multiple files; lambdas would put logic back into the template. Both defeat the point of having a declared contract per file. If you find yourself reaching for a helper, the right move is almost always to do the work in TypeScript and pass the result in as a pre-built string variable.

Template catalogue

The eleven templates under src/lib/cloister/prompts/. Four have a production caller. The other seven still load and some have smoke tests, but nothing in src/ renders them today.

Templates with a caller

Templates without a caller

Prompts outside this loader

Not every prompt goes through renderPrompt:
  • Role definitions live in roles/<role>.md. When a Claude Code agent launches with a role file, Overdeck strips its frontmatter and passes the body with --append-system-prompt-file (roleSystemPromptInjection in src/lib/agents/runtime-command.ts).
  • Review convoy sub-reviewers (security, correctness, performance, requirements) get roles/review-<subRole>.md inlined into their spawn message by buildConvoyPrompt (src/lib/cloister/review-convoy.ts), so the same text drives every harness.
  • The review and test spawn messages are built in TypeScript by buildReviewRolePrompt (src/lib/cloister/review-agent.ts) and buildTestRolePrompt (src/lib/cloister/test-agent-queue.ts).
A pull request that changes a roles/*.md file needs a commit with a Prompt-Change: trailer (scripts/check-prompt-change-trailer.sh).

Deleted (replaced by the loader)

These files used to live under prompts/. They no longer exist:
  • inspect-agent.md → the inspect verb and its inspect specialist were deleted in PAN-3917
  • merge-agent.md → replaced by merge.md with DO_PUSH/DO_BUILD flags
  • review-agent.md → replaced by review.md
  • test-agent.md → replaced by test.md
  • work-agent.md → renamed to work.md
If you find references to any of those paths in comments, PRD docs, or old commits, they are stale.

Orchestration markers

One template wraps its output in HTML comments:
  • planning.md wraps its whole body in these markers, with an HTML comment that tells session summarizers to skip the block. No code in src/ parses the markers.
Don’t add these markers to new templates: no code reads them. Unmarked Markdown is the right shape.

Composition pattern

Most non-trivial templates use a pattern we call pre-built blocks: the TypeScript call site composes a multi-line Markdown string based on runtime state, and passes that string in as a single optional variable. The template then conditionally renders the block via a Mustache section.

Example: the work.md feedback block

And the call site in src/lib/cloister/work-agent-prompt.ts, which lists the workspace’s feedback files and returns an empty string when there are none:
When pendingFeedbackStr is non-empty, the section renders; when it’s empty, the section disappears entirely. The template stays readable (no nested conditionals, no formatting logic) and the TypeScript stays honest about what the block looks like.

When to use in-template conditionals vs pre-built blocks

  • In-template sections ({{#VAR}}...{{/VAR}}) are right when the block is a fixed, static chunk of instructions that’s either present or absent based on a boolean flag. The merge.md push/no-push toggles are a good example: the alternative paths are both long, both fully specified in the template, and both known at template-authoring time.
  • Pre-built blocks are right when the block’s content is dynamic: it joins a list, formats a table, runs git commands, reads feedback files, and the template’s job is just to decide whether to include it. The work.md feedback list is a good example: the TypeScript knows how to format it, the template just needs to show or hide it.
If you’re torn, default to pre-built blocks. It’s always easier to read a template that delegates dynamic content to the call site than one that tries to be clever.

Testing prompts

Prompt tests live in src/lib/cloister/__tests__/prompts.test.ts. They fall into three categories:

1. Loader contract tests

These test the loader itself against small fixture templates. Each test writes one as __test-scratch__.md in src/lib/cloister/prompts/ and deletes it afterwards. They cover missing frontmatter, invalid YAML, missing requires, unknown vars, empty strings as requires, Mustache section rendering, etc. They cover the main error paths in renderPrompt and the frontmatter parser.

2. Live-template smoke tests

These render the real templates against realistic vars fixtures and assert that key strings appear (or don’t appear) in the output. The merge.md tests are a good example: four tests covering the push+build flow, the validation-only flow, the SKIP_DONE_REPORT branch, and the polyrepo header. Smoke tests are load-bearing: they catch cases where someone edits a template in a way that looks fine to Mustache but breaks a downstream specialist’s expectations.

3. Caller-side tests

Tests that verify TypeScript call sites pass the right variables, live alongside the calling module (e.g., work-agent-prompt-tests-mode.test.ts for buildWorkAgentPrompt). These catch the “call site got out of sync with the frontmatter” class of bug.

Writing a new smoke test

When you add a template, add at least one smoke test that:
  1. Renders the template with a realistic set of vars.
  2. Asserts the presence of fixed strings that the template always produces.
  3. Asserts the presence / absence of conditional blocks for each branch the template can take.
Keep the fixture vars small and local to the test: no shared state, no global setup. The loader caches only the prompts directory, so tests can stay simple.

Authoring workflow

Adding a new template

  1. Create src/lib/cloister/prompts/<name>.md.
  2. Write the frontmatter first. List every variable you’ll reference in the body under requires (if it must be provided) or optional (if it’s fine to omit). Write a one-line description.
  3. Write the body using {{VAR}} for substitution and {{#VAR}}...{{/VAR}} for optional sections.
  4. Add a caller in TypeScript:
  5. Add at least one smoke test in prompts.test.ts.
  6. Run npx vitest run src/lib/cloister/__tests__/prompts.test.ts, npm run typecheck and npm run lint.
  7. Run npm run build. The build pipeline copies *.md from src/lib/cloister/prompts/ to dist/dashboard/prompts/, dist/prompts/ and dist/cli/prompts/. If you skip this step, the built dashboard and CLI fail with a PromptError at runtime.

Editing an existing template

  1. Decide whether the change is contract-breaking: does it add a new required variable, remove one, or change the meaning of an existing one? If yes, update every call site in the same commit.
  2. Update the frontmatter. Adding a new variable means adding it to requires or optional. The loader refuses to render until you do.
  3. Update the body.
  4. Update or add smoke tests.
  5. Run npm run typecheck, the prompts tests and npm run lint:prompts (it checks required and forbidden strings in work.md, planning.md and some roles/*.md files).

Migrating a legacy ad-hoc prompt

If you find a call site that builds a prompt via template literals, readFileSync + ad-hoc replace, or any other pre-loader pattern, the migration path is:
  1. Create the new prompts/<name>.md template with frontmatter that matches the variables the ad-hoc code was substituting.
  2. Replace the ad-hoc builder with a single renderPrompt({ name, vars }) call.
  3. If the old code had conditional logic (e.g., “if foo, include bar”), decide per case: simple toggles become Mustache sections, dynamic content becomes a pre-built block variable.
  4. Delete the ad-hoc builder, the old template file if there was one, and any helper functions that existed only to support it.
  5. Add smoke tests.
  6. Run typecheck + prompts tests.
The typical commit layout is: template + loader call + tests + deletion of the old code, all in one PR. The loader’s fail-loud validation makes it very hard to leave a half-migrated path in place: either the call site works or it fails.

Troubleshooting

”requires variables that are missing”

The call site isn’t passing a variable the template declares as required. Fix the call site. Don’t “fix” the template by moving the variable to optional, unless the template genuinely works with it absent.

”was passed unknown variables”

Either the call site is passing a variable that the template no longer uses (delete it from the call site), or the variable is new and hasn’t been declared yet (add it to the frontmatter).

“missing YAML frontmatter”

The template file doesn’t start with a --- frontmatter block. This happens when someone deletes the frontmatter by accident, or pastes a body-only template from an old pattern. Add the frontmatter.

”Failed to load prompt template”

Three likely causes:
  1. Typo in name. renderPrompt({ name: 'work-agent' }) when the file is work.md.
  2. Missing build copy. You edited or added a template but didn’t run npm run build, so dist/dashboard/prompts/ is stale. Rebuild.
  3. No prompts/ next to the bundle. The loader resolves prompts/ relative to its own module directory (__dirname), not the working directory. If a script bundles the loader somewhere else, check that a prompts/ directory sits next to that bundle.

A variable renders as an empty string

Mustache renders a variable that isn’t in vars as an empty string, with no error. The loader only rejects keys that are passed but undeclared, and required keys that are missing. It never scans the body, so a {{VAR}} that the frontmatter doesn’t list renders empty when the call site doesn’t pass it. Declare the variable in the frontmatter (requires if the content must be there, optional if it may be left out) and pass it from the call site. Passing it without declaring it fails with “was passed unknown variables”.

A Mustache section renders when it shouldn’t

Check whether the value you’re passing is actually falsy by Mustache’s rules. Empty string: falsy. 0: falsy. false: falsy. null / undefined: falsy. An empty array: falsy. An empty object: truthy, so the section will render. This trips people up when they pass { some: 'object' } expecting the section to hide. If you want a section to hide on “nothing to say”, pass an empty string, not an empty object. Still stuck? Ask on the Overdeck Discord or file a GitHub Issue.

Further reading