Manim explainer: topic -> finished video
Arguments: $ARGUMENTS
Produce $MV/<slug>/video.mp4: narrated (unless --silent), 1080p60, soft subtitles,
audio placed per line so it cannot drift, and a classical music bed (a different CC0 /
public-domain recording for every video) levelled and ducked under the voice.
Work through every phase; stop only for a real blocker and name it exactly.
$MV is the repository that holds this skill: two folders above this SKILL.md
(resolve symlinks). Read $MV/AGENTS.md first (render rules, skill precedence).
Two optional reference skills sharpen the result; open their files only when a phase
says so (setup.sh installs them; if they are missing, follow the rules written here):
3b1b-style-animation- pedagogy and look:rules/pedagogy.md,rules/visual-quality.md,rules/layout-spacing.md,rules/seamless-transitions.md,rules/color-scheme.md. Ignore itsaudio-sync.md(edge_tts is a cloud service) and its pip/manim.cfg setup.manimce-best-practices- Manim CE API questions (rules/<topic>.md).
Paths and commands
MV="$(cd "$(dirname "$(readlink -f <this SKILL.md>)")/../.." && pwd)" # the repo
T=$MV/tools # mvkit keyframes finalize review_sheet tts-generate video_viewer music
cd $MV/<slug> # every command below runs from the video folder
uv run --project $MV <cmd> # always; never system python or pip
Phase 0 - parse and set up
- Topic plus flags:
--silent(no narration),--voice(Kokoro:af_heartdefault,am_michael,bf_emma,bm_george, ...),--length(target seconds, default 60-120),--music(a mood, a track id, ornone; default: a mood chosen from the topic, see Phase 7),--draft(stop after the reviewed draft). - If the argument names an existing folder in
$MV, this is an iteration: read itsplan.md(status section),narration.txt,script.py, and continue from the first unchecked step. Apply the user's feedback to the narrowest affected scenes. - Otherwise pick a short kebab-case slug,
mkdir $MV/<slug>, and startplan.md. - Ask the user only if the topic is ambiguous enough that the video could be about two different things. Default audience: a technical viewer new to this topic.
Phase 1 - understand the topic before designing
- Find the one idea the video exists to deliver (the aha) and the question that makes a
viewer want it (the hook). Read
rules/pedagogy.md: intuition first, concrete example with real numbers, formalism last. - Verify every factual claim you will state. Search the web or papers for anything you
are not certain of; put sources in
plan.md. Drop a figure you cannot confirm rather than state it. If the user's brief contains an error, correct it in the video and say so inplan.mdand in the hand-off. - Every number on screen or in the narration is computed by code in
script.py's data section (run it once withuv run --project $MV python -c ...to read the values). Pick example data that is typical, not the best case: when you choose a seed or an example, check how it compares to the median and say so inplan.md. - Wording must match the numbers ("78%" is "four out of five", not "almost all").
Phase 2 - plan.md
Sections: hook, aha, audience, data (with the computed numbers), sources, a scene table, layout, palette roles, music, status checklist. Scene table rows: scene class, narration line indexes, what is on screen per line, the end state handed to the next scene.
- One idea per scene and under ~60 s per scene (about 8-12 narration lines).
- Scenes join seamlessly: each scene's opening frame is the previous scene's closing
frame, built by a shared
xxx_state()function andself.add(...)-ed. - Layout zones (frame 14.2 x 8): formula/title band y ~ 3.0; content band y -2.2..1.8 in at most three columns (x = -4.6, 0, 4.6); footnote at the bottom edge. Decide where each label lives before writing code; every label gets a fixed offset from its object.
- Visual grammar: one persistent object per concept, transformed rather than replaced; color = meaning and stays fixed (e.g. blue/red signed values, teal error, yellow emphasis); at most one new idea on screen per narration line.
Phase 3 - narration.txt (skip with --silent)
subtitles:
- One spoken line per visual step.
- Next line.
- 8-20 words per line, about 2.5 words/s (Kokoro measures ~2.6). Size to the target length.
- Write for the ear: "H transpose", "int eight", "fifteen and a half". The same text is the subtitle, so avoid symbols Kokoro would misread.
- Each line describes what is on screen while it plays; no line without a visual change.
Phase 4 - TTS (local Kokoro, nothing leaves the machine)
uv run --project $MV python $T/tts-generate.py --narration narration.txt [--voice am_michael]
Confirm the clip count equals the line count. Unchanged lines are cached (.tts-cache/).
timestamps.json gives each line's duration; NarratedScene reads it, so do not inline
durations. Re-run this after any narration edit (mvkit warns when timestamps are stale).
Phase 5 - script.py
Start from template.py next to this file. Rules:
from mvkit import *; scenes subclassNarratedScene; paletteC_*constants.- Every narration line is one
with self.say(i, "first words"):block holding the animations for that line, with explicitrun_times. The block may run longer than the speech (video holds, audio waits); keep it close so pacing stays tight. Silent videos usewith self.beat(hold=...). - No
config.pixel_*/frame_ratein the script; no-p; nomanim.cfgquality. MathTexfor all math,Texfor prose; font_size >= 24 (labels 26-34, titles 36-40).- Prefer
Transform/ReplacementTransform/TransformMatchingTexbetween states; objects that will be transformed into each other share submobject structure. - Text to unrelated text:
FadeTransform(aReplacementTransformbetween different strings scrambles the glyphs mid-way). Related formulas:TransformMatchingTex. - Never move objects through things that are still fading out: clear first, then move.
- Animations freeze updaters:
Create(always_redraw(...))draws the object as it was when it was built. Build it after the trackers reach their values. - Keep a line's content on screen until its speech ends; fade it at the start of the
next line, not early (a
self.wait()before the fade holds it). - Motion that must match across a scene cut (jiggling particles, etc.) must be a deterministic function of a tracker, or end inside the scene that started it.
- Never burn subtitles in;
say()writes them.
Phase 6 - key frames (before any full render)
uv run --project $MV python $T/keyframes.py script.py Scene1 Scene2 ...
One fast -s pass; a frame at the end of every narration line plus keyframes/report.md
and keyframes/<Scene>_sheet.png. Read every sheet image. Fix all ERRORs (text overlap,
off-frame). Judge WARNs (near edge, small/dim text, text on a filled shape) and fix the
ones that hurt readability. Also look for what the checker cannot see: crowding, unclear
focus, a label pointing at the wrong thing, a line crossing a label, numbers that
disagree with the narration. Repeat until clean.
Phase 7 - music
Every video gets a different, high-quality bed. Pick a mood that fits the topic's tone
(calm, gentle, light, playful, curious, warm, wistful, reflective,
romantic, stately, serious; uv run --project $MV python $T/music.py list), then:
uv run --project $MV python $T/music.py pick --mood <mood> --min-seconds <video length> --slug <slug>
It prints a track id that no other video in the repo uses yet (falling back to other
moods, then to the least-used track). Write <slug>/music.json:
{"track": "<id>", "gain_db": -12}
Record the choice and why in plan.md. --music <track id> skips the pick;
--music none writes no music.json. finalize fetches the recording on first use and
checks its SHA-1. Never generate music, never commit audio, and only add catalog tracks
whose recording (not just the composition) is CC0 or public domain on its own page
(see $MV/music/README.md); licensed tracks go in the git-ignored music/local.json.
The voice must win: during speech finalize requires the music >= 15 LU below the voice
on average and >= 10 LU below at its loudest 3 s, and fails otherwise. If it fails,
lower gain_db by 3 (never above -10), or set start_s to skip a loud passage, or pick
another track.
Phase 8 - draft and review
uv run --project $MV manim -ql -v WARNING script.py Scene1 Scene2 ...
uv run --project $MV python $T/finalize.py . -q l
uv run --project $MV python $T/review_sheet.py video.mp4 --every 1.5
Read review_sheet.png (crop it into parts if it is too tall to read): it shows
mid-transition frames (objects passing through each other, flashes, things popping in,
content fading before its line ends). Check finalize's report: cue/line match, speech
overrun 0.00 s, speech share of runtime (60-85% is good pacing; lower means dead air),
music gaps (>= 15 LU average, >= 10 LU loudest 3 s). Fix, re-run key frames for touched scenes, re-draft. With --draft,
stop here and report.
Phase 9 - final
uv run --project $MV manim -qh -v WARNING script.py Scene1 Scene2 ... # run in background
uv run --project $MV python $T/finalize.py . -q h
Verify with ffprobe (1920x1080, 60 fps, AAC, subtitle stream) and grab 2-3 frames a few
seconds into cues from subtitles.srt to confirm the right visual is on screen.
Changing only the music needs no re-render: edit music.json and re-run finalize.
credits.txt holds the music credit line for the video description.
Phase 10 - hand-off
- Update
plan.mdstatus. Do not commit unless asked (outputs are gitignored anyway). - Offer the review viewer (localhost only; opens the browser):
uv run --project $MV python $T/video_viewer.py video.mp4 --order concat.txt --script script.py --srt subtitles.srtThe user captures timestamped notes there and pastes them back; for each note extract that frame (ffmpeg -ss <t> -i video.mp4 -frames:v 1 /tmp/f.png), look at it, then edit. - Report: video path, duration, scenes, voice, music track (with its credit line) and its gaps below the voice, the numbers shown and how they were checked, corrections to the brief, anything not verified.
Quality bar (done means all true)
- Every key frame clean of ERRORs; no unresolved readability WARNs.
- Each claim sourced or computed; example data typical, not cherry-picked.
- Every narration line has a matching visual change; no dead air over ~1.5 s except the final hold.
- Scenes join without visible cuts; nothing pops in without an animation.
- Final: 1080p60, voice at -16 LUFS, a music track no other video uses, music >= 15 LU (average) and >= 10 LU (loudest 3 s) below the voice during speech, subtitles embedded, sync verified by frames at cue starts.