Using rereel with AI agents
rereel was designed so that a coding agent can edit a video the way it edits code: read a compact state, change a few lines of JSON, check, build, and read one JSON result.
Install the skill
Section titled “Install the skill”The npm package ships an agent skill at node_modules/@mathrunet/rereel/skills/rereel/SKILL.md. It tells the agent to keep media out of Git, inspect before editing, use ripple-shift for timing changes, cut non-destructively, and validate before committing.
mkdir -p .claude/skills/rereelcp node_modules/@mathrunet/rereel/skills/rereel/SKILL.md .claude/skills/rereel/SKILL.mdThe skill’s front matter (name: rereel, description: …) lets Claude Code load it automatically for Remotion/video tasks. To make it available in every project, use ~/.claude/skills/rereel/SKILL.md instead.
Append the skill body to the project’s AGENTS.md, which Codex reads on every session:
tail -n +5 node_modules/@mathrunet/rereel/skills/rereel/SKILL.md >> AGENTS.md(tail -n +5 skips the YAML front matter.) If your Codex setup supports skill directories, copy the file there unchanged instead.
Add it as a project rule:
mkdir -p .cursor/rulescp node_modules/@mathrunet/rereel/skills/rereel/SKILL.md .cursor/rules/rereel.mdCommit the copied file so that every collaborator and agent session gets it. Re-copy it after upgrading rereel.
The agent loop
Section titled “The agent loop”-
Inspect. Get a compact view instead of reading a large
props.json:Terminal window npx @mathrunet/rereel inspect reels/ep01 --scene s03 -
Edit JSON. Make the smallest change in
props.jsonormix_plan.json. For timing changes, useTerminal window npx @mathrunet/rereel patch reels/ep01 ripple-shift --at-sec 12.0 --delta-sec -0.5Never overwrite files in
media/or splice raw audio. -
Validate. Proceed only when the JSON says
"valid": true:Terminal window npx @mathrunet/rereel validate reels/ep01 -
Build and check the result:
Terminal window npx @mathrunet/rereel build reels/ep01A local edit should report
chunksRenderedwell belowchunksTotal. If every chunk re-rendered, the edit touched a global key. Report that to the user.
Reading results
Section titled “Reading results”Every command writes exactly one JSON line to stdout. --help writes to stderr. Failures look like this:
{"status":"error","code":2,"error":"ripple-shift requires --at-sec and --delta-sec"}The process exit code matches code:
| Code | Meaning | Typical agent action |
|---|---|---|
0 |
success | continue |
1 |
failure: invalid reel (validate), SHA mismatch, missing asset, frame-count mismatch |
read errors / error, fix the JSON |
2 |
usage: bad flag, missing file, invalid JSON, unknown provider | fix the command |
3 |
dependency missing (ffmpeg, ffprobe, remotion, a builtin template) |
ask the user to install it |
4 |
an external command failed. stderr (last 1500 chars) and exitCode are included |
inspect stderr |
See Exit codes.
Prompt patterns
Section titled “Prompt patterns”Change the caption in scene s03 to “Ship it on Monday”, then rebuild ep01 and tell me how many chunks re-rendered.
Run cut-retakes on raw/take2.wav with raw/take2.json and script.md, show me what was dropped, then update work/mix_plan.json with the new segments.
The pause at 12 s is too long. Remove 0.4 s there in ep01 and rebuild.