/clefcut-cloudflare-video:clefcut-cloudflare-videofrom clefcut-cloudflare-video
Cuts long videos into clips for creator platforms using local scene/silence/OCR analysis and Cloudflare CLEF clip-worthiness rating with verified ffmpeg cuts.
Ships in clefcut-cloudflare-video. 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.
ClefCut Video cuts a long local video into short clips for creator platforms,
staged so that almost everything is free: local ffmpeg measurements build the
maps and the candidate segments, one contact sheet per segment goes to
Cloudflare CLEF for clip-worthiness rating, burned-in text is read with free
local OCR (or CLAIRIC), the agent applies a scoring rubric, the user confirms
the picks, and every cut is verified by its reported duration error. The
free-first philosophy follows the sibling plugin
clefcut-cloudflare-remotion-video (Remotion QA) — same layers, different job.
references/clip-selection.md); the agent
presents ranked candidates with scores and reasons; the user picks.-c copy with a 0.5 s keyframe tolerance, upgrading to
a frame-accurate re-encode when the snap exceeds it; every cut reports
duration_error_ms; outputs are written atomically (verified temp first).
probe records a per-file fingerprint (size + head/tail sha256) that
cut --strict can check so a plan built from a DIFFERENT file at the same
path is refused — re-run probe after any re-render/re-export of the
source.before_s/after_s/
removed_s/cuts reported. Make the clip punchy — remove dead air.--crop-x/--crop-y anchor the window —
the agent picks the anchor from the free contact sheet; a portrait taller
than 9:16 crops vertically), 9:16 blur-pad (warns when taller-than-9:16
vertical content is cropped); +faststart; optional two-pass loudness
normalization; rotation metadata honored.check verifies an export against the shared
platform table (duration/aspect are judgement calls, codec/faststart/etc.
are hard format rows); preview gives per output clip a 6-frame contact
sheet, muted first-3s and last-3s samples, and per-boundary scene scores
over ±1.5 s windows on the source. The agent reviews the samples, scores
and check rows before anything is called done.Why staged: each layer costs roughly an order of magnitude less than the one above it. Deciding from maps and sheets instead of raw frames is what keeps a 60-minute video's model spend at pennies and the agent's token spend sane.
This skill targets YouTube, YouTube Shorts, TikTok, Instagram Reels, X
(Twitter), and other creator video platforms. That list is deliberately open:
any platform not in the specs table uses the GENERIC CREATOR PLATFORM profile
— 9:16 1080x1920, 60–90 s or less, H.264 + AAC in an MP4 with +faststart,
even (divisible-by-2) dimensions, and critical content kept out of the top
~15%, bottom ~30%, and right ~10% of the frame. H.264 + AAC + faststart with
a 9:16 safe-middle layout passes every platform named above.
Never present the platform list as exhaustive, and never guess a spec. When a
platform question matters (exact duration cap, bitrate, safe zones), load
references/platform-specs.md — every fact there carries a VERIFIED,
VERIFIED—excerpt, or UNVERIFIED (community-measured) mark — and check the
platform's own help pages for anything still marked unverified.
templates/env.example into the project's .env file (or
~/.clefcut/.env for all projects) and have the user fill it in.CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (the
token needs Workers AI permission — Workers AI - Read, plus Edit unless it
was created from the dashboard template). Optional: CLEFCUT_GATEWAY_ID
(route through an AI Gateway), CLEFCUT_FFMPEG (explicit ffmpeg path).CLEFCUT_FFMPEG); a Remotion install
works too since it bundles ffmpeg. Run
node "<skill-dir>/scripts/clipcut.mjs" doctor and fix everything it
reports before any other command.clipcut verify <video> once per machine and
after every ffmpeg upgrade — it runs the real pipeline (probe → segments
→ sheets → cut → tighten → export → check → preview) on a real file in a
temp dir and reports per-step PASS/FAIL/SKIP. Network steps stay off
unless --net is passed and credentials exist.node "<skill-dir>/scripts/clipcut.mjs" <cmd> from
the directory holding the source video. Never use npx for the tool.check FAIL rows);
2 = error — the message on stderr has the fix. preview is
informational: it exits 0 or 2 only, never 1. plan --file uses
0 = valid, 1 = warnings only, 2 = invalid. check exits 1 on any FAIL
row (judgement rows can only FAIL when --platform is given; unmeasurable
facts are WARN "could not measure", never PASS).| Command | What it does |
|---|---|
doctor | Check env vars, ffmpeg, and text-engine availability. Run it first. --ping makes one clef-flash call to verify the token. |
probe <video> | Free local maps: scene scores, silence ranges, loudness, codec/container facts, VFR flag. Writes probe.json. |
segments <probe.json> | Free candidate segments from probe evidence, bounded by --min/--max duration (defaults 15–90 s; override from the genre table in references/clip-selection.md). When no candidate fits and the video is longer than --max, exits 1 with guidance; --even-split N is the mechanical fallback (N equal segments flagged mechanical: true, honest equal-split warning). Writes segments.json. |
sheets <video> --segments segments.json | One contact sheet per candidate segment (default 6 frames in a 3×2 grid of ~480-px-wide cells). Writes sheets/seg_NNN.png plus the sheets.json manifest. |
rate --sheets sheets/ --questions questions.json | Send one sheet per segment to CLEF (--model clef-flash default; --max-images 2–4 batches, with auto-isolation of a failing batch). Writes ratings.json, rewritten after every request. |
read <video> --segments segments.json | Read burned-in on-screen text per segment with --engine local, clairic, or auto (chosen once per run). Writes text.json. |
cut <video> --plan clips.json | Cut the chosen clips: lossless with --tolerance 0.5 default, verified duration_error_ms (plus start_error_ms and av_start_skew_s for copy-mode cuts), 30 ms fades on re-encoded cuts. Re-encoded cuts record nearest_keyframes + lossless_alternative (the copy command that would have run and why it did not). When the plan carries a fingerprint (copied from probe.json), cut compares it to the actual file — a same-path re-render trips it where the path/duration checks cannot — and --strict turns a mismatch into exit 2 before anything is written. Writes clips/<slug>.mp4 and clips/cut-report.json. |
tighten <clip> | Remove silence: detect silences (--threshold -35 dBFS, --min-silence 0.6 s), keep --margin 0.15 s of silence on each side of speech, drop kept pieces under --min-keep 0.2 s, refuse over --max-cuts 400 cuts. One re-encode (crf 18, aac 192k, faststart) with 30 ms fades at each join; writes <stem>_tight.mp4 atomically and reports before_s / after_s / removed_s / cuts. No silence found → prints a suggested threshold (mean + 6 dB, capped at −5 dB) and exits 0. |
export <clip> --platform <id> | Render variants per clip (original, 9x16-crop, 9x16-blur) into exports/<slug>_<platform>_<variant>.mp4, +faststart, optional two-pass loudnorm (--loudnorm). The original variant re-encodes when the source is odd-sized, non-H.264, or non-yuv420p. For 9x16-crop, --crop-x/--crop-y (0..1, default 0.5 = the exact center crop) anchor the crop window in the leftover region — the agent picks the anchor from the FREE contact sheet (preview/sheets), says which anchor it chose and why. Rotation metadata is honored (display dimensions). |
check <file> [--platform <id>] | Compliance gate: rows for duration, aspect (rotation-aware: judged on display dimensions after rotation metadata), resolution, resolution cap (informational WARN where the platform's row marks a max — shorts 1080p verified, x/tiktok community), fps/VFR, codec, pix_fmt, audio, sample rate, faststart, loudness (measure-only; quiet masters WARN, only clipping TP>0 or over-loud I>~-2 FAIL), silent audio — each PASS/WARN/FAIL with a plain reason and the exact fix command. Judgement rows (duration/aspect/loudness) FAIL only with --platform; unmeasurable facts are WARN "could not measure". Writes check-report.json. Exits 1 on any FAIL. |
preview <clip> --source <video> --start S --end E | 6-frame contact sheet plus muted first-3s/last-3s samples and preview.json per-boundary scene scores; --probe probe.json cross-checks the source's scene changes. Informational: exit 0 or 2 only. |
verify <video> [--net] | Real-footage self-test: runs the REAL pipeline commands (probe incl. fingerprint → segments → sheets → cut a slice with duration_error_ms reported → tighten → export 9x16-crop → check → preview) on the user's own file in a temp dir that is always cleaned. Network steps SKIP with a reason unless credentials exist AND --net is given (then one clef-flash ping + one clairic image, cost gate respected). Per-step PASS/FAIL/SKIP-with-reason + a summary; exit 1 on any FAIL. Run once per machine and after ffmpeg upgrades. |
plan | Print the clips.json schema; with --file, validate a plan (duplicate slugs rejected, durations + total printed, unknown platforms mapped to the creator profile with a warning). |
The rate questions file is project-local: templates/questions.example.json
lives in the skill directory — copy it into the project first and edit the
copy; rate --sheets sheets/ --questions questions.json then points at that
copy.
| Engine | Cost | Strengths | Weaknesses |
|---|---|---|---|
local | Free, offline | tesseract.js (npm i -D tesseract.js; the first run downloads English data) or system tesseract; nothing is uploaded | Weaker on stylized fonts, low contrast, and rotated or animated text |
clairic | ~$0.10 per million input tokens, no output charge | Nothing to install; a confidence and p_null per field; handles stylized and low-contrast text | Frames are uploaded; the model is in Preview and its behavior may change |
auto | Free when a local engine is installed; CLAIRIC pricing otherwise | The engine is chosen ONCE per run — local when a local engine is installed, otherwise CLAIRIC for the whole run (never a per-segment fallback); the run report states which engine produced the results | Costs money for the whole run whenever no local engine is available |
Ask the user which engine to use when a project starts; default to auto.
These rules are load-bearing. Breaking them is how a cheap clip run becomes a surprise bill.
rate sends ONE sheet per request by default, not one image per frame. A
60-minute video with 10 candidates sends 10 default sheets — roughly
7,680 input tokens ≈ $0.0003 on clef-flash (estimate). This is the whole
reason the pipeline builds sheets.rate or read --engine clairic call, and get the OK. Example
form: "10 candidates, 10 sheets ≈ 7,680 tokens ≈ $0.0003 on clef-flash
(estimate)." (read frames are capped at 1280 px wide — roughly 768 to
1,024 tokens each from a 1080p source, estimate.)--yes (or CLEFCUT_YES=1) above 240 images. The
agent still states the estimate even under the gate.usage fields of completed runs.Worked token math and per-model details: references/clef.md and
references/clairic.md.
-c copy — fast and quality-free, but it can
only land on keyframes (I-frames), so the actual start can snap away from
the requested one.--tolerance). When the keyframe snap
would exceed it, the cut upgrades to an accurate re-encode — -ss before
-i plus re-encode is frame-accurate. When that happens, the report also
records nearest_keyframes (the keyframes bracketing the requested start)
and lossless_alternative — the copy command that WOULD have run plus
why it did not (e.g. "keyframe snap 1200ms exceeds tolerance 500ms").duration_error_ms in clips/cut-report.json
(copy-mode cuts also report start_error_ms — the requested start vs
the keyframe actually used — and av_start_skew_s, first video pts vs
first audio pts; over max(2 frames, 0.1 s) it becomes a warning field,
which never changes the exit code). A cut that ends over tolerance makes
the command exit 1. A caller never has to trust "it probably cut where
asked" on faith.afade
in/out) to prevent clicks. Lossless -c copy cuts cannot carry fades —
when fades are required, the cut runs in accurate mode.-c copy on VFR can
start on a frozen or wrong frame.cut, export and tighten write ATOMICALLY: the encode lands in a
hidden temp file next to the output, is verified (probe duration,
faststart box walk), and only then is renamed over the final name. A
failed or truncated encode removes the temp and leaves any pre-existing
output untouched — a broken file can never replace a good one.tighten after cutting removes detected silences while keeping
0.15 s of silence on each side of kept speech — margins keep speech
natural; do not tighten with margins near zero unless the user asks.Score every rated candidate 0–2 on five criteria — opens on action,
complete thought, ends clean, self-containment, visual energy — for a 0–10
total, and keep candidates at 7 or above. THE authoritative copy of the
rubric — exact CLEF question wording, thresholds, the escalate band, the
candidate archetypes, the genre-to-duration table, and the boundary rules —
lives in references/clip-selection.md. Load it before composing rate
questions or ranking candidates.
Three honesty rules travel with the score:
A CLEF answer near its threshold (inside the escalate margin), a null or
missing answer, or a choice answer below the 0.5 confidence floor escalates
to agent review: the agent opens that segment's contact sheet and judges it
personally before including or excluding it. When a model answer conflicts
with a measurement (scene map, silence map, loudness), the measurement
decides. Thresholds and the defect-direction convention:
references/clip-selection.md.
| File | Load it before... |
|---|---|
references/platform-specs.md | any export or check run, or any platform question — specs table, what check verifies, safe zones, export recipes |
references/clip-selection.md | composing rate questions, ranking candidates, or setting segment duration bounds |
references/clef.md | any rate run — models, prices, request schema, response shapes, retries, token math |
references/clairic.md | read --engine clairic — field types, response shape, Preview caveats |
references/ai-gateway-and-mcp.md | routing through an AI Gateway or calling the Cloudflare API MCP server |
references/workflow.md | running the full loop, writing clips.json, or writing the final report |
references/ai-gateway-and-mcp.md (opens in a new tab)references/clairic.md (opens in a new tab)references/clef.md (opens in a new tab)references/clip-selection.md (opens in a new tab)references/platform-specs.md (opens in a new tab)references/workflow.md (opens in a new tab)scripts/clipcut.mjs (opens in a new tab)templates/env.example (opens in a new tab)templates/questions.example.json (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub secondsky/claude-skills --plugin clefcut-cloudflare-videoOther plugins' skills for the same job