CLI overview
The rereel binary (dist/cli.js) is a thin wrapper around the programmatic API. Every command prints exactly one JSON line to stdout and exits with a documented exit code, which makes it easy to drive from shell scripts, CI, and AI agents.
npx @mathrunet/rereel <command> [args] [options]# or, when installed as a dev dependencyrereel <command> [args] [options]Requires Node.js >= 22. Commands that render, probe, or mix media additionally need ffmpeg and ffprobe (see Environment variables).
Commands
Section titled “Commands”| Command | Synopsis | Purpose |
|---|---|---|
freeze |
rereel freeze <reel_dir> --props <props.json> [...] |
Lock every media file referenced by props.json / mix_plan.json into rereel.lock.json and write a Git-slim bundle. |
hydrate |
rereel hydrate <reel_dir> [--template-dir <dir>] [--offline] |
Restore missing or stale media/ files from storage, verifying SHA-256. |
validate |
rereel validate <reel_dir> [--check-media] |
Check schema, lockfile completeness, and portability. Exit 1 when invalid. |
inspect |
rereel inspect <reel_dir> [--scene <id>] |
Print a compact timeline summary for agents. |
build |
rereel build <reel_dir> [--out <mp4>] [--template-dir <dir>] [--offline] |
Hydrate, render only changed chunks, concatenate, and mix audio. |
cut-retakes |
rereel cut-retakes --input <media> [--asr-json <path>] [--script <path>] [...] |
Non-destructively detect silences, fillers, and retakes. |
patch |
rereel patch <reel_dir> ripple-shift|trim-segment|swap-asset [...] |
Deterministic edits that keep props.json, mix_plan.json, timing.json, and captions.srt in sync. |
Global options
Section titled “Global options”| Option | Type | Default | Description |
|---|---|---|---|
--storage-config <path> |
path | see lookup rules | Path to a rereel.storage.json. Parsed by every command (including validate and inspect) before the command runs. |
--help, -h |
flag | — | Print usage to stderr and exit 0. Recognized anywhere in the argument list. Running rereel with no arguments does the same. |
Output contract
Section titled “Output contract”- Success: one JSON object on stdout, terminated by
\n. The shape is documented on each command page. - Error: one JSON object on stdout with the shape
{"status":"error","code":<n>,"error":"<message>", ...details}and the process exits withcode. See Exit codes. - Usage/help text goes to stderr, never stdout.
- Child processes (Remotion, FFmpeg,
npm) are run with captured output, so their logs do not leak into stdout.
rereel validate ./reels/ep01 | jq '.valid'Argument parsing rules
Section titled “Argument parsing rules”The parser is intentionally minimal. Knowing its rules avoids surprises:
- Tokens that do not start with
--are positional arguments (e.g.<reel_dir>, thepatchoperation name). --key=valuesetskeytovalue.- Value options written as
--key valueconsume the next token if it does not start with--. - Negative numbers work as values (
--delta-sec -0.5,--silence-db -40) because they start with a single-. - If a flag is repeated with values, the last value wins.
- Numeric flags are parsed with
Number(); a non-finite value fails with exit code2(Flag --<key> must be a number: <value>). - Boolean flags (
--offline,--check-media,--no-keep-media) accept--flag,--flag=true, or--flag=false. They can appear before or after positional arguments.
Environment variables
Section titled “Environment variables”| Variable | Used by | Effect |
|---|---|---|
REREEL_STORAGE_CONFIG |
all commands | Storage config path, checked after --storage-config. |
REREEL_FFMPEG_BIN (fallback TSURUGI_FFMPEG_BIN) |
build, cut-retakes, audio compiler | FFmpeg binary. Default ffmpeg. |
REREEL_FFPROBE_BIN (fallback TSURUGI_FFPROBE_BIN) |
freeze, build, cut-retakes | FFprobe binary. Default ffprobe. |
REREEL_REMOTION_BIN (fallback TSURUGI_REMOTION_BIN) |
build | Remotion CLI binary. Default: <template>/node_modules/.bin/remotion, then npx remotion. |
REREEL_TEMPLATES_DIR |
build | First search root for template.source: "builtin". The second root is ~/.samurai/templates/remotion. |
A missing binary (ENOENT) produces exit code 3; a binary that exits non-zero produces exit code 4.