Docs for reading and listening¶
A narratty doc serves two audiences from one file: someone reading it in a browser
and someone watching the video. The goal is one source of truth: plain Markdown that
reads well, with as few <!-- narratty: … --> comments as possible. Every comment is a
"parallel world" that readers don't see and that can drift from the text around it.
This page collects the rules that keep the two in step. They come from two rounds of a usability study in which authors wrote tutorials, architecture overviews and runbooks with narratty and retrofitted existing guides to it.
The scene model in one paragraph¶
The doc is read top to bottom. The paragraph directly before a block is its lead-in and
is spoken while that block runs; by default narration and typing start together. A
paragraph after a block is spoken in the next scene, while the output is still on
screen. A run comment before a block changes the order per block, see
Choosing who goes first. Text that no block
comes with leaves the terminal on screen as it is, unless the entry sets
prose: slides: then it shows its key points. See also
How a doc becomes scenes.
Rules¶
Write for the ear first, then check the page¶
- Keep the lead-in short and end it with a colon. One or two sentences that say what the command does: "Check that it works:". The colon also tells narratty the paragraph belongs to the next block or slide, and listeners that something follows.
- Explain output after the block. A paragraph after a block is spoken while the output is on screen. That is the natural "run, then explain".
- Avoid spatial and UI words. "Above", "below", "the command below" and "click here"
make no sense when spoken;
narratty validateflags them. Reword ("next", "this command", "the output shows") rather than adding askip+saypair. - Let callouts speak for themselves. Warning, caution, danger and important
admonitions start with their type and title ("Warning: Cache keys. …"). Note and tip
are read like text. Change it per type with the entry key
admonitions. - Footnotes and task lists are fine. Markers and checkboxes are not spoken;
footnotes are skipped, or spoken after their sentence with
footnotes: inline. - Spell out what TTS gets wrong in the lexicon, not in the text. Run
narratty lexicon checkand add terms such asJWTorconfig.yamltotts.lexiconin thespeccomment. The text stays correct for readers.
Keep the reader's commands as readers type them¶
- Label every shell fence
console, with$prompts and the real output. Volatile parts become..., also within a line (Python 3...). - Never rewrite a command for the video. Use a
runcomment instead: until: "listening on"fortail -fand servers: wait for the text, then Ctrl+C;lines: 10to shorten long output on screen (checkstill compares the full output);instead: "pip install -e ."when the reader's command can't run in the demo (offline install, a clone of their fork).- Make expected failures fail for real and mark them
expect-failure.checkverifies both the exit code and the output. - Redirect the output of background jobs (
app > app.log 2>&1 &). Output that arrives after the prompt can make a build time out;validatewarns about a bare&. - Write placeholders as environment variables (
$TOKEN, not<token>). Put values insandbox.envorsandbox.env_passthrough, never in ahiddenblock. - Use
no-runfor host-only commands (sudo, editors,open). The command stays on screen without being run; say in the text that it is shown, or add anoverlay.
Keep the parallel world small¶
- Prefer a Markdown construct over a comment. A table with a
tablecomment, a diagram withfocuscomments and a heading per step read well on the page. Asaythat replaces a paragraph does not. - Show snippets that aren't project files with
narratty="show". A JSON response or a config excerpt becomes a highlighted code slide; don't invent atitlefor it. - Let slides stay for their conclusion with
hold: next-blockorhold: next-headingon theslideortablecomment. - Clear the screen with
clear_on: 2in thespeccomment instead of hiddenclearcommands. - Keep setup out of the doc. Toolchains go into
environment, variables and git identity intosandbox.env. If ahiddenblock is unavoidable, keep it to one at the top of the first section, and never let it touch$HOMEor use--global: under--runtime nativeit runs on your machine. - Pick sections, don't skip paragraphs.
sections: {exclude: [troubleshooting]}keeps the intro;<!-- narratty: skip-rest -->leaves out the rest of a section. - Remove old workarounds when you upgrade. A
say Warning!or a footnoteskip+sayfrom before 0.7 now doubles up with the new defaults.
Let the prose carry the slides¶
- Turn on
prose: slidesfor docs that explain more than they run: architecture and concept pages, release notes, hardware set-up. Text that no command or slide comes with then shows its key points instead of an unchanged terminal. A tutorial with a command every few sentences needs it less. - Make the first sentence of each paragraph its point. It becomes the key point,
cut at a comma when it is longer than 75 characters.
narratty plan --sourceslists every key point; rewrite the sentence when one says little. Readers who skim the page profit from the same sentence, so don't add a summary comment instead. - Write enumerations as lists. A list becomes a bullet slide with its items as written, one marked while it is spoken. End the paragraph before it with a colon, and the slide appears with that paragraph.
- Keep the heading in view in long videos with
slides: {frame: true}andheading_overlays: the section heading stays at the top over terminal and slides. For a look of your own, giveslides.cssa theme andterminal.themeits colours, see Themes.
Check before you build¶
- Run
narratty validate, thennarratty check, after every edit. Treat each warning as a to-do item.checkruns the commands as the video would and reports "N commands ran, M shown only"; nothing ran means nothing is wired up. - Run
narratty plan --sourcesto see what each Markdown element became and why something was left out. Runcheckfirst:planthen uses the measured command durations. - Look at the video at section changes and after slides. Extract frames with
ffmpeg -ss <t> -i out.mp4 -frames:v 1 f.png, and read the.srt.
What each element becomes¶
| Element | On the page | In the video | Recommendation |
|---|---|---|---|
| Heading | Structure | Chapter overlay (heading_overlays); the H1 card stays during the intro |
One heading per step; it also scopes sections |
| Paragraph | Text | Lead-in of the next block, or the scene after a block; with prose: slides, text no block comes with shows its key point |
Short before a block, explanations after it; the first sentence says the point |
| List | Items | Read item by item; with prose: slides, a bullet slide marking the item spoken |
Enumerations, steps without commands |
console block |
Command and output | Typed, run, output compared by check |
The default for shell examples |
bash block |
Script | Each command runs; output not compared | Scripts readers copy as a whole |
Code with title |
File listing | Written hidden, shown with cat and a file overlay |
Config files the demo needs |
Code with narratty="show" |
Listing | Highlighted code slide | Responses, excerpts, examples |
| Code without either | Listing | Left out (validate warns); with prose: slides, a code slide |
Add show or a title, or use prose: slides |
| Table | Table | Left out; slide with a table or slide comment |
Decisions and comparisons: table {say: "If {A}, {B}."} |
mermaid |
Diagram | Slide; focus comments walk flowchart nodes and sequence participants |
One short paragraph per node |
| Image on its own line | Image | Slide titled with the alt text | Write a meaningful alt text |
| Admonition | Callout | Warnings say their type and title | Nothing extra needed |
Collapsed block, <details> |
Hidden until opened | Left out | Reader-only background, FAQ |
| Content tabs | Tabs | First tab, or the one the entry names | Keep tabs equivalent |
| Footnote, task list | Rendered | Markers not spoken | Fine |
| Inline code, links | Formatted | Plain text, lexicon applies | Avoid bare URLs |
Choosing who goes first: voice or command¶
| You want | Write before the block | What happens |
|---|---|---|
| Talk while it runs | nothing | Default (say: during) |
| Explain, then run | <!-- narratty: run {say: before} --> |
Typing starts once the lead-in is spoken |
| Run, then explain in the same scene | <!-- narratty: run {say: after} --> |
The text after the block is spoken once the commands are done |
| Let the output sink in | <!-- narratty: pause 2s --> after the block |
A silent pause |
The same keys fit in the block's attributes (narratty="say=before lines=10"), and the
entry key say: before makes "explain, then run" the default for a whole tutorial.
With say: after, keep the lead-in very short: it is spoken over an idle prompt.
Retrofitting an existing guide¶
- Run
narratty validateon the guide as it is. Typical result: "no command runs" and one warning per unlabelled fence with$lines. - Label shell fences
console; replace volatile output with.... - Split blocks so that commands with different needs (run,
no-run,instead) are in separate blocks, and turn commands that only appear inline in a step ("runmake lint") into blocks. Both help readers too. - Mark host-only steps
no-run; useinsteadfor steps that need another command in the demo,untilfor commands that don't end. - Make sure every section's first block has a lead-in, or it plays silent.
- Set
clear_on: 2, pick the sections withsections: {exclude: [...]}, and addenvironment.packageswhencheckreports a missing tool (exit 127). - Add a
tablecomment to tables the video needs andfocuscomments to diagrams. - For a guide that explains more than it runs, set
prose: slidesand read the key points innarratty plan --sources; rewrite first sentences that say little. - Run
check, thenbuild, and look at the frames at each section change.
Expect to change about a sixth of the reader-visible text, and most of those changes improve the written guide as well.
Agents¶
The repository ships an agent skill that applies these rules when writing or
retrofitting a doc: skills/narratty-docs/SKILL.md. Copy it into your agent's skill
directory (for Claude Code, .claude/skills/narratty-docs/).