Runbook Structure
File format
Section titled “File format”A runbook lives in its own folder and must contain a file named runbook.mdx. The file is MDX (Markdown plus JSX), so it mixes standard markdown (headers, paragraphs, lists, code blocks, images, links) with blocks such as <Check>, <Command>, <Inputs>, and <Template>.
Common structure
Section titled “Common structure”You can organize runbook.mdx however you like. A common pattern:
# Runbook title
Introduction paragraph explaining what this runbook does.
## Pre-flight checks
Make sure the user has the tools the runbook needs.
<Prerequisites id="pre-flight-checks">```yamltools: - name: tool version: ">= 1.0" install: "[Install the tool](https://example.com/install)"```</Prerequisites>
## Execute actions
Run commands on behalf of the user to complete the runbook.
<Command id="do-something" env={{ PROJECT_NAME: "{{ .inputs.ProjectName }}" }} command='echo "$PROJECT_NAME"' inputsId="config" title="Execute action" successMessage="Done!"/>
## Generate code
Generate code the user needs to accomplish their task.
<Template id="infra-code" path="templates/infra"/>
## Post-flight checks
Verify everything worked.
<Check id="post-flight-checks" command="curl https://some-endpoint.com" title="Check if deployment is successful" successMessage="Deployment successful" failMessage="Something went wrong"/>
## Finish
Celebrate, and tell the user what to do next.
<Finish id="finish">
Next, share the endpoint with your team.
</Finish>Chapters
Section titled “Chapters”A long runbook that’s best worked through in phases can split its content into chapters, which Runbooks shows one at a time, with a table of contents to move between them:
# Runbook title
Introduction paragraph, shown with every chapter.
<Chapter title="Pre-flight checks">
...
</Chapter>
<Chapter title="Deploy">
...
</Chapter>Chapters only change what’s on screen: a block in one chapter can use the inputs and outputs of a block in any other.
Front matter
Section titled “Front matter”runbook.mdx can start with YAML front matter, between two --- lines. Runbooks doesn’t show it.
---title: Deploy the servicerunbooks: ">= 0.28"---
# Deploy the serviceRequiring a version of Runbooks
Section titled “Requiring a version of Runbooks”runbooks in the front matter names the versions of Runbooks the runbook needs, such as the version that added a block or prop it uses. The release notes list what each version added.
A version of Runbooks that doesn’t meet the requirement doesn’t open the runbook. Instead, it says which versions the runbook needs and which version it is, and to update Runbooks when a later version would meet the requirement. Runbook tests fail the same way.
The requirement takes the syntax of a <Prerequisites> tool’s version, such as ">= 0.28", "~> 0.28", or ">= 0.28, < 1.0". Quote it: YAML reads an unquoted 0.30 as the number 0.3. A requirement Runbooks can’t read, or front matter that isn’t valid YAML, stops the runbook from opening, with an error that says what’s wrong.
A version of Runbooks that doesn’t have a block the runbook uses doesn’t open it either, with or without a requirement: it names the block, and says to update Runbooks or check the block’s name. A requirement still helps with a prop, which a version of Runbooks that doesn’t have it may ignore, so that the block runs without it.
Versions of Runbooks before 0.28 don’t read the requirement, and refuse a runbook with a block they don’t have with an error that only says the component isn’t defined.
Folder organization
Section titled “Folder organization”Blocks reference scripts and templates by path. You can store them anywhere, but this layout is the convention:
Directorymy-runbook/
- runbook.mdx Main runbook file
Directoryassets/ Images and other assets
- diagram.png
Directorychecks/ Shell scripts for
<Check>blocks- prereq1.sh
- prereq2.sh
Directoryscripts/ Shell scripts for
<Command>blocks- deploy.sh
- cleanup.sh
Directorytemplates/ Boilerplate templates for
<Template>blocksDirectorymy-template/
- boilerplate.yml
- main.tf
- variables.tf
Folder purposes
Section titled “Folder purposes”| Folder | Purpose | Used by |
|---|---|---|
assets/ |
Images, diagrams, videos, and other static files | Markdown image syntax and <img>, <video>, <audio> tags |
checks/ |
Shell scripts that validate prerequisites | <Check> blocks |
scripts/ |
Shell scripts that execute actions | <Command> blocks |
templates/ |
Boilerplate template directories | <Template> blocks |
Relative paths
Section titled “Relative paths”Reference files relative to the runbook’s folder:
<Check id="prereq" path="checks/prereq1.sh" /><Template id="infra" path="templates/my-template" /><img src="./assets/diagram.png" width="400" /><video src="./assets/demo.mp4" poster="./assets/demo-poster.png" controls /><Iframe src="./assets/dashboard/index.html" />A script path on a <Command>, <Check> or <Finish> block must stay inside the runbook’s folder: a path with a .. segment fails.
These paths are for block props. A script itself starts in the session’s directory, not in the runbook’s folder, so it can’t use them to find files next to the runbook. See Execution context.
Asset paths must start with ./assets/. Runbooks loads them from the runbook’s assets/ folder when they appear in markdown image syntax, including in a block prop that supports inline markdown such as title or description, or in one of these tag attributes:
| Tag | Attributes |
|---|---|
<img> |
src, srcSet |
<video> |
src, poster |
<audio> |
src |
<source> |
src (inside <video> or <audio>), srcSet (inside <picture>) |
<track> |
src |
In a srcSet, each candidate’s path is rewritten and its descriptor (2x, 480w) is kept. Write the path as a plain string: src={"./assets/demo.mp4"} is left as written and won’t load.
Video and audio are read from the file as they play, and you can seek anywhere in them.
assets/ must be a real folder, not a symlink. If assets is a symlink, Runbooks serves nothing from it and every asset fails to load, even when the symlink points inside the runbook’s folder. Otherwise assets -> . would serve runbook.mdx and its scripts to any page the runbook embeds. Symlinks inside assets/ work when they point to files inside assets/.
The <Iframe> block’s src also takes a ./assets/ path.