/motion-pack:spec-to-loopfrom Motion Pack
Writes a frame-keyed motion-and-sound spec from a one-line brief, then builds it as a deterministic generative 3D loop with three.js/WebGL, synthesized Web Audio score, GPU-rendered at 4x supersampling, and measured QA.
Ships in Motion Pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Short generative loops (a few seconds, 60 fps) whose picture is computed on the GPU and whose score is synthesized in code, held to numbers: every motion has a frame, every hit lands on an exact sample, every claim in the delivery is measured from the delivered file. The method has two halves. First write a spec where every adjective is a number. Then build it from a template whose page is a pure function of time, render it on the real GPU, score it, and correct it in measured rounds until the tables pass and the stills look right.
The suite runs story-script -> frame-design -> motion-pack (+ spec-to-loop, Blender plates) -> motion-stack -> social-video.
spec.md written from brief.md, or from a shot in shotlist.json / plan.json that calls for a computed loop.
design.json from frame-design supplies the accent hex (rim and emissive colours, calibrated by pixel probe), the display font (bake it
with scripts/ttf2typeface.py) and the look.out/<name>.mp4 (single loop), out/<name>-x2.mp4 (two loops), the master WAV, qa/ (stills, contact sheets, JSON
reports) and the project's LEARNINGS.md. motion-pack composites the MP4 as a plate, or social-video posts it as a loop.| path | what |
|---|---|
templates/liquid-chrome.html | raymarched chrome blob that breathes, pinches into droplets, and forms extruded letters (any text, any typeface JSON), studio environment, glint sweep, drain and remerge through frame 0; GPU SDF bake + TextGeometry mesh cross-fade; full score in CONFIG |
templates/lib/score-engine.js | the sound engine: voices, cosine-crest tonal buffers, grouping, peak guard, wrap-around OfflineAudioContext render, stems |
scripts/render.mjs | headless Chrome on the hardware GPU: GPU check, 4 jittered subframes per frame, raw RGBA streamed to x264; --qa (determinism + seam + console) and --stills-only |
scripts/score.mjs | runs the page's CONFIG.SCORE through the engine (no GPU needed); --rounds N = N measured correction rounds, then the master |
scripts/measure_audio.py | per-hit timing, level over the bed, limiter gain reduction; master LUFS / true peak / seam; --tune solves trims; --write masters |
scripts/mux.sh | single-loop MP4 (2 ms fades) + two-loop MP4 (seamless), AAC 256k, durations |
scripts/check_loop.py | page QA + decoded-video seam + event stills + 1-fps contact sheet + ffprobe + A/V lag |
scripts/ttf2typeface.py | pin a variable font's weight and bake chosen glyphs to a three.js typeface JSON next to the page |
references/spec-template.md | blank video + sound spec to fill from a brief, plus the correction-round and DECISIONS formats |
references/example-spec.md | a complete worked example (the maker's wordmark loop) with its corrections, decisions and measurements |
references/spec-anatomy.md | that example clause by clause: what each clause buys; the "what makes a spec good" checklist |
references/learnings.md | architecture, a decisions catalogue, 47 gotchas and the measured results of the builds behind the skill |
One-time setup: npm i puppeteer-core in this skill's scripts/ folder or in the project (the scripts also find it on NODE_PATH, in the
full puppeteer package, or in the npx cache), and pip install numpy scipy pillow (+ fonttools for brand fonts). Chrome is found via
--chrome PATH, CHROME_PATH / PUPPETEER_EXECUTABLE_PATH, or the standard install locations on macOS, Windows and Linux.
S=<this skill's folder>; P=<project folder>; mkdir -p "$P"
cp "$S/templates/liquid-chrome.html" "$P/page.html"
# 1. edit ONLY the CONFIG block first: text, font, colours, timings in frames, camera, studio, sound levels
node "$S/scripts/render.mjs" "$P/page.html" "$P/out/x.mp4" 0 60 540 --stills-only --stills 0,84,112,150,222,300,337 --stills-dir "$P/qa/dev"
# LOOK at the stills; iterate on CONFIG (and on the template code for new ideas)
node "$S/scripts/score.mjs" "$P/page.html" "$P/out" --rounds 5 # stems -> measured correction rounds -> master WAV + fade copies
node "$S/scripts/render.mjs" "$P/page.html" "$P/out/video.mp4" # the full loop at CONFIG size, 4 subframes, streamed
bash "$S/scripts/mux.sh" "$P/out/video.mp4" "$P/out"
python3 "$S/scripts/check_loop.py" "$P/page.html" "$P/out/<name>.mp4" "$P/qa" --x2 "$P/out/<name>-x2.mp4" --master "$P/out/<name>-master.wav"
python3 "$S/scripts/ttf2typeface.py" MyFont-Variable.ttf "$P/assets/myfont-800.typeface.json" LOOP --wght 800, then
CONFIG.font.url = 'assets/myfont-800.typeface.json' (relative: render.mjs serves the page's folder). Check the font's licence.timeline.launch: [..] (frames, one per glyph) plus timeline.form.stagger.render.mjs page.html out/v916.mp4 --query "w=1080&h=1920&dolly=1.75" (the dolly factor also moves the black floor back; 1.75
fitted a 2.65-unit-wide word), then bash mux.sh out/v916.mp4 out <name>-9x16.qa/contact_events.png and qa/contact_1fps.png.references/spec-anatomy.md once, then fill references/spec-template.md)A good motion spec is a list of measurable promises. In order:
window.renderAt(t) sets everything from t; seeded random only; periodic in the loop length; with ?t= never
start requestAnimationFrame; window.__ready after fonts, textures and GPU bakes; frame N equals frame 0.From a brief: decide the loop length first (it fixes every period: breathing, orbit, noise cycle; a length whose sample count is a multiple of 1024, such as 8 s, leaves no AAC padding). Lay the timeline out as a table of frames before any prose, give every motion a verb and a number, put each sound event on the frame of its visual event, and finish with the loudness line. Show the spec to the user before building: it is cheaper to change a number than a render.
Ambiguity: choose the reading a careful motion designer would mean, write it as a numbered DECISION in the project's LEARNINGS.md
(clause, reading, why) and keep going. Never stall on an ambiguity; never silently drop a number.
references/example-spec.md) changed CONFIG and rewrote only the sound part of DERIVED.window.CONFIG (fps, loopFrames, width,
height, qaFrames, SCORE, name), window.__ready, window.__error, window.__gpu, renderAt(t) (one jittered sample),
renderFrame(n, fps) (4 subframes averaged in linear light), captureFrame(n, fps) (base64 RGBA, top row first), __hashFrame(n, fps),
__hashAt(t); a <script id="config"> block that defines CONFIG and builds CONFIG.SCORE without the GPU. Query: ?t= one frame and
no rAF, ?norun, ?size=.Date, Math.random or performance.now, no state carried between calls. Things that look stateful (springs,
follow-through) are immutable tables integrated once from constants over two loops (keep the second). Wrap the frame index mod the loop
before it becomes a time (sin(2 pi t / L) at t = L is not exactly 0). Noise must travel a circle in its domain.C.SCORE from the same frames as the picture. A sound event's
frame is the VISUAL frame; the engine adds the one-frame delay. That is why a timing change can never desync the two.__state, __layout, pixel probes) and calibrate colour, contrast and framing from numbers, then look.scripts/render.mjs does all of this; know why)--use-angle=metal on macOS, d3d11 on Windows, Chrome's default on Linux; --angle
overrides) plus --ignore-gpu-blocklist --enable-gpu-rasterization, in a fresh temporary profile (never the user's). It reads
WEBGL_debug_renderer_info and refuses to render unless the renderer names a hardware GPU: a SwiftShader fallback is far slower and
does not give the same pixels.t = n/fps + k/(4 fps); the quarter-pixel jitter slot is floor(frac(t*fps)*4) (= k) on a rotated grid
(-.375,-.125) (.125,-.375) (.375,.125) (-.125,.375) px, injected identically into the raymarch and projectionMatrix[8,9]. The average is
4x SSAA plus a 360-degree shutter. Average in linear light (the template accumulates RGBA32F HDR before bloom); record the choice in DECISIONS.libx264 -profile:v high -preset slow -crf 12 -pix_fmt yuv420p, bt709 tags via setparams, exact
-frames:v, +faststart). Never a PNG sequence: QA stills only (at most 60 per call). Disk is checked first (default: stop under 6 GiB).templates/lib/score-engine.js)OfflineAudioContext(2, 3N, 48000); the middle of three loops is kept,
so tails and pre-rolls wrap across the seam (seamless by construction). Reverb is a ConvolverNode with a seeded, energy-normalised IR and
normalize = false, so the stems stay linear and bed + hits = mix exactly.(F + 1) x SR / fps (= (F + 1) x 800 at 48 kHz and 60 fps).cos(r * theta), a sin^2 attack that ends on that
crest: the absolute peak is the anchor sample (measured error 0 samples in every build). Envelopes and AM after the crest must be 1 at t = 0.
No WaveShaper (its oversampling adds latency, so peaks land milliseconds late) and no phase-0 sines (they peak a quarter cycle late).noiseLeadMs (default 2 ms) earlier so two peaks never stack on one sample; scatter voices (spark tings, a
random-phase chord bloom) follow the crest and are never timed. Tonal groups get a peak guard on their tonal + scatter parts only (later
content above 0.76 x the crest within 60 ms is pulled down by a smooth gain, never clipped; noise is never guarded).tone (pitch: a number, {drop}, {approach}, {glide}, {glideIn}, {spring}, {wobble} or a function), noise (riser or
burst, filter glide), texture, click, creak, swish, boing, sparkle, bloom, whoosh; bed: pad (per-frame level steps can
follow a light's flicker), bass, shaker; or any function(kit, ev) -> {L, R, anchor, kind}.score.mjs --rounds N = render -> measure_audio.py --tune -> render ... -> measure_audio.py --write. The table it prints, with the
house defaults (set in CONFIG.SCORE.master):
| metric | how | default pass |
|---|---|---|
| timing, tonal | isolated tonal part of each group, argmax vs (F+1) x SR/fps | 0 samples (<= 1) |
| timing, noise / texture | loudest sample / first sample above 1e-4 x max | within 1 frame / 1 ms |
| level over the bed | hits stem vs bed stem, K-weighted, 60 ms from the target (what is heard) | 3 to 6 dB |
| own level | the group alone vs the bed (context; the solver's basis) | >= -6 dB (audible on its own) |
| limiter GR per hit | min gain from target - 5 ms to + 60 ms | <= 1.5 dB |
| master | integrated LUFS; true peak (4x resample_poly); seam step and 2nd difference vs their 99.9th percentile | -14 +- 0.5; <= -1.0 dBTP; <= p99.9 |
The tuner solves instead of nudging groups one by one (nudging oscillates when hits overlap): window w's K-weighted energy is modelled as the sum of each group's own energy in that window times its trim power, rescaled each round by measured / predicted, then a bounded least-squares fit puts every window on 4.5 dB, keeps each group's own level in [-6, +6] dB, keeps adjacent dense hits equal, and remembers a ceiling for groups the limiter has squeezed. The stock template passed in 2 rounds in this edition's smoke test and in 5 rounds in earlier builds; use 5.
| failure | meaning | fix |
|---|---|---|
| tonal peak late by milliseconds | waveshaper, phase-0 sine, or sine-phase harmonics | cosine-crest buffers, every harmonic in cosine phase |
| level and limiter alternate (hint "crest-stacked") | a peak without 60 ms of energy (noise peak, sub, kick, phase-aligned partials on one sample) | voicing: lower the peaky part, raise the sustained part, random-phase bloom, 2 ms noise lead; trims cannot fix it |
| crest-limited and the stems look innocent | a hard pan: equal loudness, one channel ~2.6 dB hotter at the peak | narrow the pan (width 0.45 worked) |
| hint "dominated by a neighbour" | an earlier tail or the next onsets fill this window | shorten / lower the tail, space the hits (the worked example's correction 2) |
| solver trims a hit toward -30 dB | its window is already full (numbers pass, the design breaks) | the own-level floor exists for this: never relax it to make a table pass |
| every hit below the bed in round 0 | the bed (pad) is too loud | lower the bed first (one move lifts every hit), then solve |
| seam step > p99.9 | something not periodic (an oscillator not reset per loop, a tail not wrapped) | build the bed from buffers or per-loop oscillators; render 3 loops, keep the middle |
scripts/mux.sh)Keep the seamless master WAV (24-bit). (a) Single-loop MP4: audio = the master with a 2 ms raised-cosine fade on the first and last 96
samples ONLY: AAC works in 1024-sample frames, so a 6 s loop's audio can run 16 ms past the video and a looping player would otherwise start
and stop on a hard step. (b) Two-loop MP4: the video read twice by stream copy (-stream_loop 1) + the master tiled twice, no fades. AAC
256k via aac_at when ffmpeg lists it, else ffmpeg's aac (AAC_ENCODER forces one). Both measured A/V lag 0; aac_at left 16 ms of
padding on a 6 s loop, ffmpeg's aac trimmed it in its edit list. It reports audio vs video duration from ffprobe.
renderAt(0) == renderAt(L); renderAt(t) == renderAt(t + 3L); frame 0 == frame NCONFIG.qaFrames) + the 1-fps contact sheet, decoded from the DELIVERED MP4; look at poses, framing, colour<link rel="icon" href="data:,">)LEARNINGS.md; QA PNGs kept to what you will look atreferences/learnings.md)TextGeometry reads height, not depth (depth is silently ignored).n/60 + k/240 times 60 can land a hair under the integer; add 1e-6 before every floor.escapeT), then trace.function foo in a classic script becomes window.foo: never write window.foo = () => foo().-color_primaries / -color_trc: keep the setparams in the filter chain.bed.f32, hits.f32, own.f32 in out/audio/).references/example-spec.md (opens in a new tab)references/learnings.md (opens in a new tab)references/spec-anatomy.md (opens in a new tab)references/spec-template.md (opens in a new tab)scripts/check_loop.py (opens in a new tab)scripts/measure_audio.py (opens in a new tab)scripts/mux.sh (opens in a new tab)scripts/render.mjs (opens in a new tab)scripts/score.mjs (opens in a new tab)scripts/ttf2typeface.py (opens in a new tab)templates/lib/score-engine.js (opens in a new tab)templates/liquid-chrome.html (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
generative-loop, motion-spec, webgl, threejs, web-audio, gpu-render, seamless-loop
npx claudepluginhub anveai/motion-pack --plugin motion-pack6 skills in this plugin
/frame-designArt-direct every frame of a video before it is built - a tone cell and motion personality, a palette measured for WCAG contrast, a free OFL type pairing, grid and platform safe zones, one hero per frame, the look and grain, and the special frames (title cards, lower thirds, end cards, covers and thumbnails) in 16:9, 9:16 and 1:1. Use this skill whenever the user asks how a video, title card, thumbnail, cover, end card or lower third should look, wants a palette, font pairing, colour grade or look, needs on-screen text to read on a phone or stay inside platform safe zones, or wants real UI screenshots placed into a generated scene, even if they never say art direction. It reads shotlist.json and writes design.json, whose fields map onto real motion-pack template CONFIG keys. It bundles scripts/contrast.py, a WCAG checker and palette linter that also proposes the nearest passing colour./motion-packMake finished, platform-ready videos with an AI agent from motion-pack, an open-source kit of deterministic, seek-safe parts rendered with HyperFrames - transitions, kinetic type and captions, synthesised sound and music, overlays and film looks, camera moves, three.js objects, Blender plates and genre templates - steered by a playbook of graded rules learned from studied films. Use this skill whenever the user wants to make or edit a video of any kind - an ad, launch film, product promo, explainer, reel, short or TikTok, short film, character spot, talking-head edit, beat-synced edit, kinetic title or sonic logo - even if they never mention motion-pack. It picks a format from the brief, writes a plan that already carries the learnings (mp brief, mp plan), renders, then lints the plan and the delivered file against every enforceable rule (mp lint, mp study) until nothing fails. For outside libraries (GSAP, three.js, Lottie, Rapier, Remotion), load motion-stack alongside.Other plugins' skills for the same job