A motion design toolkit for coding agents.
JavaScript
Position the repo as a motion design toolkit for coding agents
whaley7ca9ab19503a
diff --git a/.claude/skills/motion-design/SKILL.md b/.claude/skills/motion-design/SKILL.mdindex 8a10176..7ecb09c 100644--- a/.claude/skills/motion-design/SKILL.md+++ b/.claude/skills/motion-design/SKILL.md@@ -9,7 +9,7 @@ Remotion teaches you the API. This file is the taste. Every number below comes f## 1. Time lives in `timeline.json`-- Every beat is a named timestamp in seconds in `timeline.json`, grouped by scene (`s1`, `s2`, …). Components read it through `TL` from `src/lib.ts`; `scripts/sfx.py` reads the same file. That is what keeps picture and sound locked.+- Every beat is a named timestamp in seconds in `timeline.json`, grouped by scene (`s1`, `s2`, …). Components read it through `TL` from `src/lib.ts`; the video's cue sheet in `sfx/cues/` reads the same file. That is what keeps picture and sound locked.- Never hardcode a start time inside a component. Offsets relative to a beat (`s1.exit + 0.05`) are fine.- Retiming = editing `timeline.json`, then `npm run sfx` so audio follows.- Everything is a pure function of `frame`. No CSS transitions or keyframes, no `Math.random()` (use `rand(n)`), no `Date`. Anything else flickers or drifts at render time.diff --git a/.claude/skills/sound-design/SKILL.md b/.claude/skills/sound-design/SKILL.mdindex ef83b0c..d5573b8 100644--- a/.claude/skills/sound-design/SKILL.md+++ b/.claude/skills/sound-design/SKILL.md@@ -1,65 +1,91 @@---name: sound-design-description: Procedural sound design synced to timeline.json — which sound goes with which visual event, gain hierarchy, panning, musical key, mastering to -14 LUFS, and how to verify sync. Use when adding, changing or checking audio, SFX, music beds or loudness for a video in this repo.+description: Procedural sound design with the sfx engine — writing a cue sheet against a video's timeline, which sound goes with which visual event, gain hierarchy, panning, musical key, automatic mastering to -14 LUFS, adding new generators, and verifying sync. Use when adding, changing or checking audio, SFX, music beds or loudness for any video in this repo.---# Sound design-Most AI-made motion graphics are silent. Sound is what makes this one feel produced.+Most AI-made motion graphics are silent. Sound is what makes a piece feel produced.-All audio is generated by `scripts/sfx.py` (pure Python stdlib, no samples, no licenses to worry about) from the same `timeline.json` the visuals use. Output: `public/sfx.wav`, muxed into the final MP4 by `npm run mux`.+The `sfx/` engine synthesizes every sound in pure Python stdlib: no samples, no licenses, no installs, same output on every run. It reads the same timeline JSON as the picture, so sound can't drift out of sync.-## The rule+## How it fits together-A sound is `put(time, samples, gain, pan)` where `time` comes from a timeline key. Never type a raw number for when something happens; if the picture moves, the sound moves with it.+| File | Role |+|---|---|+| `sfx/synth.py` | generators: each returns mono samples at 48 kHz |+| `sfx/mix.py` | `Mix`: place sounds in time, master to a loudness target, write WAV |+| `sfx/loudness.py` | BS.1770 integrated loudness (matches ffmpeg's ebur128) |+| `sfx/cues/<video>.py` | a cue sheet: one video's sound design |++```bash+python3 -m sfx --list # generators with what each is for+python3 -m sfx sfx/cues/<video>.py # render → mastered WAV+```++## Writing a cue sheet for a new video++Create `sfx/cues/<video>.py`:++```python+from sfx.synth import click, pop, whoosh, chime, riser, impact++TIMELINE = "timeline.json" # the same file the composition reads+OUT = "public/sfx.wav"+TARGET_LUFS = -14.0 # optional, this is the default++def score(mix, tl):+ s1 = tl["s1"]+ mix.put(s1["title"], whoosh(0.4, 500, 2400, peak=0.45), 0.12)+ for i, t in enumerate(s1["items"]):+ mix.put(t, pop(900 + i * 150, 400), 0.3, pan=-0.4 + i * 0.3)+```++- `mix.put(t, samples, gain, pan)`: `t` always comes from `tl`, never a typed number. Offsets from a beat (`s1["exit"] + 0.05`) are fine.+- `mix.typing(start, end, chars)`: one humanized keystroke per character.+- `mix.put_stereo(t, left, right, gain)`: for stereo sources like `pad()`.+- Mastering is automatic: the engine soft-clips and sets gain to hit `TARGET_LUFS`, raising drive only as far as needed to keep the true peak ≤ −2 dBFS (room for AAC overshoot, so the MP4 stays under −1 dBTP). A mix that's mostly short hits with silence between can't reach −14 without crushing; the engine then comes out quieter and says so. Fix it with sustained sound (a pad, longer tails), not by forcing it.+- Add an `"sfx"` script in `package.json` pointing at the new cue sheet, or run it directly.++`sfx/cues/effort.py` is a complete, real example: 128 sounds plus a pad bed.## Visual event → sound-| On screen | Sound | Generator |+| On screen | Generator | Notes ||---|---|---|-| Typing | one key per character, ±4–6 ms jitter, random gain 0.14–0.26 | `key()` |-| Word / line reveal | short airy whoosh + low blip on the landing | `whoosh()`, `blip()` |-| Element pops in (badge, chip, callout) | pitched pop, rising pitch across a sequence | `pop()` |-| Control snaps to a step | click + a note from the scale | `click()`, `blip()` |-| Sketch / draw-on | pencil scratch texture | `scratch()` |-| Progress / build-up | riser into the payoff (one per video) | `riser()` |-| Success / arrival | bell chime in key | `chime()` |-| Hero transition | whoosh in, low impact on the hit (one per video) | `whoosh()`, `impact()` |-| Under everything | quiet pad chord, ducked under transitions | `pad()` |+| Typing | `mix.typing()` | jitter ±4–6 ms, random gain |+| Word / line reveal | `whoosh()` + `blip()` on the landing | short, airy |+| Badge, chip, callout pops in | `pop()` | raise pitch across a sequence |+| Control snaps to a step | `click()` + `blip()` in key | |+| Sketch / draw-on | `scratch()` | |+| Build-up | `riser()` | end exactly on the hit; one big riser per video |+| Success / arrival | `chime()` | chord in key |+| Hero transition | `whoosh()` in, `impact()` on the hit | one impact per video |+| Under everything | `pad()` with an `envelope()` | duck it under the hero transition |Accent, don't narrate: not every motion needs a sound. Continuous motion (drift, grain, rotation) stays silent.-## Levels--- Hero hits (pops, impact, key moments): gain 0.25–0.35.-- Supporting (whooshes, blips, chimes): 0.08–0.2.-- Bed (pad): ~0.03, ducked by ~65% during the hero transition and lifted after.-- Only one impact per video. Only one big riser.--## Space and music+## Levels and space-- Pan roughly follows on-screen position (−1 left … +1 right); sequences sweep across the stereo field.-- Pick one key and keep every tonal sound in it. In the effort video the pad (D–A–D–F♯–C♯) and the slider notes (E5–F♯5–A5–B5) are in D major; the scene 3 pops and chime are still in C major, so fix those before copying them.-- Pitch rises with progress (steps, pops) and resolves on the payoff chord.-- Seed the RNG (`random.seed(...)`) so renders are reproducible.+- Hero hits: gain 0.25–0.35. Supporting sounds: 0.08–0.2. Pad: ~0.03, ducked ~65% under the hero transition.+- Pan follows on-screen position (−1 left … +1 right). Sequences sweep across the stereo field.+- Pick one key and keep every tonal sound in it; pitch rises with progress and resolves on the payoff. (In the effort example the pad and slider notes are D major, but the scene 3 pops and chime are still in C major. Don't copy that.)-## Mastering+## Adding a generator-- Normalize, soft-clip with `tanh`, 0.25 s fade-out (already in `sfx.py`). `DRIVE` sets loudness, `CEIL` sets headroom; tune them together and re-measure the muxed MP4, AAC overshoot isn't linear.-- Target **−14 LUFS integrated** (X, Instagram, YouTube all normalize near this).-- Keep **true peak ≤ −1 dBFS**. AAC encoding in `mux` adds overshoot, so the final MP4 peaks higher than the WAV.+Write a function in `sfx/synth.py` that returns a list of floats at `SR`. Put what it's for in the first docstring line; `--list` shows it. Use the module-level `random` for noise so renders stay reproducible. Build on `bandnoise()` for anything airy.## Verify```bash-npm run sfx # regenerate public/sfx.wav-npm run wave # out/wave.png + loudness of the WAV-npm run build # full render + mux-node scripts/wave.mjs out/effort.mp4 # loudness of what you'll actually post+npm run sfx # or python3 -m sfx sfx/cues/<video>.py+npm run wave # out/wave.png + loudness of the WAV+npm run build+node scripts/wave.mjs out/effort.mp4 # loudness of what you'll actually post```-In `out/wave.png` every coral line is a timeline beat. Each transient should sit on a line or a hair after it. A hit between lines means a hardcoded time or a stale WAV.+In `out/wave.png` every coral line is a timeline beat. Each transient should sit on a line or a hair after it. A hit between lines means a hardcoded time or a stale WAV. Pass `--timeline` for a video with its own timeline file.## Optional: generated audio-For voiceover or sounds you can't synthesize, the ElevenLabs MCP (see `.mcp.json.example`) can generate SFX/TTS into `public/`. Place them with `<Audio src={staticFile(...)} />` inside a `<Sequence from={beat * FPS}>`, or mix them into `sfx.py` so everything stays one master.+For voiceover or sounds you can't synthesize, the ElevenLabs MCP (see `.mcp.json.example`) can generate files into `public/`. Place them with `<Audio src={staticFile(...)} />` inside a `<Sequence from={beat * FPS}>`.diff --git a/AGENTS.md b/AGENTS.mdindex 8ed288e..3f3a0bd 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -1,58 +1,66 @@# Agent guide-This repo is a motion design pipeline for coding agents, built on [Remotion](https://remotion.dev) (React → video). It ships one finished piece, `EffortVideo` (22 s, 1080×1080, 60 fps), as the reference implementation.+This repo is a motion design toolkit for coding agents, built on [Remotion](https://remotion.dev) (React → video). It gives you taste rules with numbers, a loop for reviewing your own frames, and a procedural sound engine synced to the timeline. `EffortVideo` (22 s, 1080×1080, 60 fps) is a finished example to read and take apart, not a template you have to follow.## Read firstThe skills in `.claude/skills/` are the core of this repo. Claude Code and Cursor load them automatically; other agents should read them before touching a video.-- `motion-design/SKILL.md` — taste rules with numbers: easing, springs, timing, type, color, texture, transitions.-- `review-loop/SKILL.md` — how to look at your own renders and what to check. Mandatory before saying a video is done.-- `sound-design/SKILL.md` — timeline-synced procedural audio and mastering.+- `motion-design/SKILL.md`: easing, springs, timing, type, color, texture, transitions, with numbers.+- `review-loop/SKILL.md`: how to look at your own renders and what to check. Mandatory before saying a video is done.+- `sound-design/SKILL.md`: writing a cue sheet for the `sfx` engine, levels, mastering, adding generators.-## Commands+## Making a video++1. Agree on the message, a storyboard and the one hero moment with the user. Ask for format (1:1, 16:9, 9:16), length, brand colors and fonts if they matter.+2. Write every beat into a timeline JSON before any component code, one file per video (the example keeps its own at `timeline.json`).+3. Register a `<Composition>` in `src/Root.tsx` and put the scenes in their own folder under `src/`. Reuse `src/components/` (`Mask`, `Roll`, `Grain`, `Background`, `WobbleFilter`, `Spark`) and the helpers in `src/lib.ts` (easings, `prog`, `band`, `sp`).+4. Define the video's palette and fonts in one place, the way `C` and `F` are defined in `src/lib.ts`.+5. Run the review loop until a full pass is clean.+6. Write a cue sheet `sfx/cues/<name>.py` against the same timeline and render the sound.+7. Render, mux, and check loudness on the final file.+8. Add the piece to `examples/` with the prompt you were given.++## Tools| Command | What it does ||---|---|-| `npm run studio` | live preview in the browser |-| `npm run draft` | fast half-res render → `out/draft.mp4` |-| `npm run sheet` | contact sheets at every timeline beat → `out/sheets/` |-| `npm run sfx` | regenerate audio from `timeline.json` → `public/sfx.wav` |-| `npm run wave` | waveform with beat markers + loudness check |-| `npm run build` | sfx + full render + mux → `out/effort.mp4` |-| `npm run gif` | README preview → `media/preview.gif` |-| `npm run cover` | 5:2 article cover (`ArticleCover` still) → `out/article-cover.png` |+| `npm run studio` | live preview of every composition |+| `npx remotion render <Id> out/<name>-silent.mp4 --scale=0.5` | fast draft render |+| `npm run sheet -- --video <mp4> --timeline <json>` | contact sheets at every beat → `out/sheets/` |+| `python3 -m sfx --list` | sound generators and what each is for |+| `python3 -m sfx sfx/cues/<name>.py` | render a cue sheet → mastered WAV (−14 LUFS) |+| `npm run wave -- <wav or mp4> --timeline <json>` | waveform with beat markers + loudness check || `npm run typecheck` | TypeScript check |+Mux picture and sound:++```bash+ffmpeg -y -i out/<name>-silent.mp4 -i public/<name>.wav -map 0:v -map 1:a -c:v copy -c:a aac -b:a 256k -movflags +faststart -shortest out/<name>.mp4+```++The example has shortcuts: `npm run draft`, `npm run sfx`, `npm run build` (sound + render + mux → `out/effort.mp4`), `npm run cover`, `npm run gif`.+Requirements: Node 20+, Python 3, ffmpeg. If `/usr/bin/chromium` (or `$REMOTION_BROWSER`) exists it's used; otherwise Remotion downloads its own browser on first render.## Layout```-timeline.json every beat, in seconds — single source of truth for picture and sound-src/lib.ts palette (C), fonts (F), easings, prog/band/sp helpers, TL-src/Root.tsx composition registration-src/EffortVideo.tsx the piece: scene orchestration-src/ArticleCover.tsx 2000×800 still built from the same timeline and easing-src/scenes/ one file per scene-src/components/ reusable pieces (PromptBar, EffortSlider, primitives: Mask, Roll, Grain…)-scripts/sfx.py procedural sound design-scripts/sheet.mjs contact sheets for review-scripts/wave.mjs waveform + loudness+.claude/skills/ the rules: motion-design, review-loop, sound-design+sfx/ sound engine: synth.py (generators), mix.py (placement, mastering), loudness.py+sfx/cues/effort.py example cue sheet+scripts/sheet.mjs contact sheets for visual review+scripts/wave.mjs waveform + loudness check+src/lib.ts easings and animation helpers, plus the example's palette (C), fonts (F), timeline (TL)+src/components/ reusable pieces: primitives (Mask, Roll, Spark, Grain, WobbleFilter), Background, useFonts+src/EffortVideo.tsx example piece; its scenes in src/scenes/, its timeline in timeline.json+src/ArticleCover.tsx example still: a 2000×800 cover drawn from the same timelineexamples/ gallery: prompt, process and result for each piece```-## Making a new video--1. Agree on the message and a storyboard with the user first (what's on screen, in what order, what the one hero moment is).-2. Write the beats into a timeline JSON before any component code.-3. Add a `<Composition>` in `src/Root.tsx`, build scenes, reuse `src/components/` and `src/lib.ts`.-4. Loop with `review-loop` until a full pass is clean, then do sound with `sound-design`.-5. Add the piece to `examples/` with the prompt you were given.-## Conventions- Animation is a pure function of `useCurrentFrame()`. No CSS animations, `Math.random()` or `Date`.-- No hardcoded start times in components; read them from the timeline.-- Colors only from `C`, fonts only from `F`.+- No hardcoded start times, in components or in cue sheets; read them from the timeline.+- Colors and fonts only from the video's palette object.- Match the existing code style: small helpers, inline styles, comments only for non-obvious constraints.diff --git a/README.md b/README.mdindex a11fa11..c32f984 100644--- a/README.md+++ b/README.md@@ -1,27 +1,32 @@# claude-motion-**Remotion skills teach Claude the API. This repo teaches it taste.**+**A motion design toolkit for coding agents.** Remotion skills teach your agent the API. This teaches it taste, makes it check its own frames, and gives it a sound engine.++Works with Claude Code and Cursor out of the box (skills in `.claude/skills/`), and with Codex, OpenCode or anything else that reads `AGENTS.md`.<p align="center">- <img src="media/preview.gif" width="480" alt="22-second motion graphic made by Claude with this repo" />+ <img src="media/preview.gif" width="480" alt="22-second motion graphic made by Claude with this toolkit" /></p>+<p align="center"><sub>Made by Claude with this toolkit from one prompt and one revision. No After Effects, no stock sounds. <a href="examples/01-effort/">How it was made →</a></sub></p>+<!-- For the version with sound: open this README in the GitHub editor, drag out/effort.mp4 in, and GitHub will turn it into an inline player. -->-The video above was made by Claude from one prompt: *"make a dynamic 15-second motion graphics video that shows what an incredible motion designer you are"*, plus one revision. No After Effects, no timeline editor, no stock sounds. [How it was made →](examples/01-effort/)+## What your agent gets++**Motion rules with numbers.** Easing curves, spring presets, stagger, reading holds, type scale, one-accent color, texture, motivated transitions. Not "make it smooth": `bezier(0.16, 1, 0.3, 1)` for entrances, exits at half the duration, 0.09 s between words. → [`motion-design`](.claude/skills/motion-design/SKILL.md)++**A self-review loop.** Agents can't watch video, but they can look at frames. The agent renders a draft, gets a contact sheet with one timestamped frame per beat, checks it against a list (collisions, clipping, holds, safe area, phone readability) and fixes what it finds before saying it's done. → [`review-loop`](.claude/skills/review-loop/SKILL.md)-## What's inside+**A sound engine.** Pure Python stdlib, no samples, no licenses. Generators for typing, clicks, pops, whooshes, risers, chimes, impacts, textures and pads; a mixer that places sounds on the same timeline as the picture; mastering that hits −14 LUFS by itself. The agent writes one cue sheet per video and adds generators when it needs a new sound. → [`sound-design`](.claude/skills/sound-design/SKILL.md)-- **Motion design rules with numbers.** Easing curves, spring presets, stagger, reading holds, type scale, one-accent color, texture, motivated transitions. Not "make it smooth": `bezier(0.16, 1, 0.3, 1)` for entrances, exits at half the duration, 0.09 s word stagger.-- **A visual self-review loop.** Claude renders a draft, builds contact sheets at every beat, looks at them, checks a list (collisions, clipping, holds, safe area, phone readability) and fixes what it finds before telling you it's done.-- **Sound design synced to every cut.** One `timeline.json` drives both picture and audio. All sound is procedural (no samples, no licensing), mastered to −14 LUFS, with a waveform check that shows every hit landing on its beat.-- **A finished reference piece** with reusable components: masked text reveals, rolling numbers, prompt bar with typing, a spring-loaded slider, film grain, hand-drawn line boil.+**One timeline for everything.** Every beat is a named timestamp in a JSON file. Scenes, sound and review all read it, so retiming the video retimes the sound and the checks with it.-Works with Claude Code and Cursor out of the box (skills in `.claude/skills/`), and with Codex / OpenCode / anything that reads `AGENTS.md`.+**A reference piece to take apart.** The video above, with reusable components: masked text reveals, rolling numbers, film grain, hand-drawn line boil, a background with drifting grid and glow.## Quick start-**Let your agent do it.** Paste this into Claude Code, Cursor, Codex or OpenCode:+**Let your agent set it up.** Paste this into Claude Code, Cursor, Codex or OpenCode:```textClone https://github.com/YOUR_USERNAME/claude-motion and cd into it.@@ -35,47 +40,67 @@ Then read AGENTS.md and the skills in .claude/skills/, and ask me what video I w```bashgit clone https://github.com/YOUR_USERNAME/claude-motion && cd claude-motionnpm install-npm run build # → out/effort.mp4+npm run build # the example video with sound → out/effort.mp4npm run studio # live preview```-Then ask your agent for a video. It will pick up the skills on its own.+Then ask for a video:++```text+Make a 15-second 1080×1080 motion graphic announcing <your thing>.+Follow AGENTS.md: storyboard first, then the timeline, review loop, sound.+```-## The pipeline+## How the agent works```- idea ─► timeline.json ─┬─► React scenes ─► npm run draft ─► npm run sheet ─► look, fix ─┐- (every beat) │ │- │ ◄─────────────── repeat ────────────────┘- └─► scripts/sfx.py ─► npm run wave (sync + loudness)- │- npm run build ─► out/effort.mp4+ idea ─► storyboard ─► timeline.json ─┬─► scenes ─► draft ─► contact sheet ─► look, fix ─┐+ (every beat) │ │+ │ ◄──────── repeat ───────────────┘+ └─► cue sheet ─► python3 -m sfx ─► waveform + LUFS+ │+ render + mux ─► final MP4```-| Command | |+| Tool | ||---|---|-| `npm run studio` | live preview |-| `npm run draft` | fast half-res render |-| `npm run sheet` | contact sheets at every beat (`-- --from 3 --to 5 --every 0.2` to scrub a transition) |-| `npm run sfx` | regenerate sound from the timeline |-| `npm run wave` | waveform with beat markers + LUFS / true peak |-| `npm run build` | final render with sound |-| `npm run gif` | README preview |-| `npm run cover` | 5:2 cover for an X Article, drawn from the same timeline |+| `npm run studio` | live preview of every composition |+| `npm run sheet -- --video <mp4>` | contact sheets at every beat (`--from 3 --to 5 --every 0.2` to scrub a transition) |+| `python3 -m sfx --list` | sound generators and what each is for |+| `python3 -m sfx sfx/cues/<name>.py` | render a cue sheet to a mastered WAV |+| `npm run wave -- <wav or mp4>` | waveform with beat markers, LUFS and true peak |+| `npm run build` | the example, end to end: sound, render, mux |<p align="center">- <img src="media/sheet.png" width="720" alt="Contact sheet Claude reviews: one frame per timeline beat" /><br/>- <sub>What Claude looks at: one tile per beat, labelled with its timestamp.</sub>+ <img src="media/sheet.png" width="720" alt="Contact sheet the agent reviews: one frame per timeline beat" /><br/>+ <sub>What the agent looks at: one tile per beat, labelled with its timestamp.</sub></p>+## The sound engine++A cue sheet is one Python function. Every time comes from the timeline:++```python+from sfx.synth import pop, whoosh++def score(mix, tl):+ s1 = tl["s1"]+ mix.put(s1["title"], whoosh(0.4, 500, 2400, peak=0.45), 0.12)+ for i, t in enumerate(s1["items"]):+ mix.put(t, pop(900 + i * 150, 400), 0.3, pan=-0.4 + i * 0.3)+ mix.typing(s1["typeStart"], s1["typeEnd"], chars=24)+```++`python3 -m sfx sfx/cues/<name>.py` renders it, masters it to −14 LUFS with the true peak kept under −2 dBFS, and writes the WAV. [`sfx/cues/effort.py`](sfx/cues/effort.py) is the full sound design of the example: 128 sounds and a pad.+<p align="center"><img src="media/wave.png" width="720" alt="Waveform with timeline beats in coral" /><br/>- <sub>Sound check: every coral line is a beat from timeline.json.</sub>+ <sub>Sync check: every coral line is a beat from the timeline, and every hit sits on one.</sub></p>## Effort levels for motion work-What I use with Opus 5.5 (`/effort` in Claude Code):+What works with Claude Opus 5.5 (`/effort` in Claude Code):| Stage | Effort | Why ||---|---|---|@@ -95,7 +120,7 @@ Nothing here needs MCP. These add real capabilities; copy `.mcp.json.example` to| [Playwright](https://github.com/microsoft/playwright-mcp) | screenshots of a real product UI to animate || [Figma](https://help.figma.com/hc/en-us/articles/32132100833559) | pull frames and design tokens straight from your file |-Pair it with the official [Remotion agent skills](https://www.remotion.dev/docs/ai/skills) for API coverage; this repo is about the design layer on top.+Pair it with the official [Remotion agent skills](https://www.remotion.dev/docs/ai/skills) for API coverage; this toolkit is the design layer on top.## Gallery