Codebase video
One persistent illustrated world, a camera that moves over it, a voice that tells a story, one caption chunk at a time. The style comes from a 140 s dam explainer; style.md breaks it down beat by beat. Read it before you write the script.
The code you explain can live in any repository. The video is built in the engine, effect-video, a separate checkout:
- If the working directory is the engine, use it.
- Otherwise use
$EFFECT_VIDEOwhen it is set. If it is not set, clone the engine to~/code/effect-video(when that path is missing) and runnub installthere (npm installworks too).
Every src/…, out/… and nub run … below is relative to the engine checkout. The repository you explain is only read. The engine's narration, caption and camera helpers are in engine.md. The worked example is src/compositions/backpressure/: copy that folder to start.
Steps
1. Find the one idea
Read the code the request points at until you can state the idea in one sentence of the form "X does Y because otherwise Z breaks".
Done when every claim the video will make has a file:line in your notes, and every number on screen is one you read in the code, a doc or a measurement you ran. A video carries one idea; a second idea is a second video.
2. Draw the world and the arc
The world is a diagram of the system itself, drawn as a cutaway: modules are places, data are things that move between them, load is pressure, a queue is a container that fills. It stays on screen the whole video and grows: each beat adds or changes one part of it.
Lay the story out as beats on the arc from style.md:
- the thing (what exists, built in front of the viewer)
- the forces (what flows through it and pushes on it, arrows sized by magnitude)
- how it breaks (show the failure in the world: overflow, red tint)
- the fix (the new part arrives in lime and gets its name: "That's the X.")
- the fix's cost (the fix creates a new problem)
- the better fix, then the payoff line that reframes what the viewer sees
An architecture or pattern explainer uses the same arc with "why does it look like this" as the question: each part of the shape is the fix for a failure you show first. Repeat the break-fix pair once per part; skip 5 and 6 when the code has no second fix.
Done when every beat has one sentence of narration, one change in the world and one camera shot, in a table.
3. Test an analogy
Read analogy.md. Done when you have either a mapping table that passes its test, so the video gets an analogy part after the technical part, or a one-line reason why none fits, so it gets none.
4. Write the script
src/compositions/<id>/script.ts, one line per sentence-sized beat, id per line so the scene can cue on it. Spoken English, written for the ear:
- Short sentences, mostly under 14 words. Second person ("you"), present tense, concrete verbs (pushes, piles up, waits).
- Budget 150 words per minute: a 20 s video has about 50 words, a 60 s one about 150.
- Open on the thing, with no greeting or title. Name each fix in its own short line: "That's backpressure."
- Code identifiers are spelled as spoken ("source dot add"); the scene shows the real identifier on screen.
- Every factual claim traces to a
file:linefrom step 1.
Done when you read it aloud and nothing sounds written.
5. Narrate
nub run narrate -- <id> speaks each line with the open Kokoro-82M voice (voice: "kokoro:af_heart"; macOS say is the fallback for any other voice name), measures it and writes word timings (see engine.md). Done when the printed overall rate is 140–180 wpm and every line id exists; reword or split lines that print far above 200 wpm.
6. Build the scene
src/compositions/<id>/<Name>.ts, registered in src/compositions/index.ts. Times come from the narration only: Narration.at(narration, "line", "word"), never hand-typed seconds, so re-narrating keeps the picture in sync. Apply the visual grammar and choreography in style.md.
Done when nub run check passes.
7. Render and inspect
nub run render -- <id> # muxes out/narration/<id>.wav into out/<id>.mp4
ffmpeg -v error -y -i out/<id>.mp4 -vf "fps=1,scale=270:-1,tile=10x<seconds/10, rounded up>" -frames:v 1 sheet.png
ffmpeg -v error -y -ss <seconds> -i out/<id>.mp4 -frames:v 1 -vf scale=540:-1 frame.png
Read the contact sheet, then full frames at each beat's key word. Check every beat against its row in the table:
- the world change happens on its cue word, and the camera frames it;
- the caption sits on a calm part of the world and collides with no label;
- labels and callouts stay inside the frame at the zoom of their shot;
ffprobeshows a video and an audio stream of the same length.
Fix and re-render until a pass finds nothing. Done when that pass is clean.
8. Deliver
Report the MP4 path, its length, the one-sentence idea, the file:line evidence, and whether it has an analogy part (or why not).