claude-video-digest
CLAUDE.md1 starsChanged 15 days agoMITView on GitHub
Notes for working on this repo with Claude Code. This file only records what is easy to get wrong — update it in the same commit as the fix, not after. A missing dependency must fail loudly, before any download or extraction happens — ffmpeg/ffprobe/python3 are checked at the very top of the script. A check placed where a dependency is first used (e.g. at the point meta.json gets written) means a missing interpreter surfaces only after a download and…
In this repository2 other files it gives its agents.
- releaseSkill
- watch-videoSkill
The file
Files
CLAUDE.md
Notes for working on this repo with Claude Code. This file only records what is easy to get wrong — update it in the same commit as the fix, not after.
The one rule
A missing dependency must fail loudly, before any download or extraction happens —
ffmpeg/ffprobe/python3 are checked at the very top of the script. A check placed where a
dependency is first used (e.g. at the point meta.json gets written) means a missing
interpreter surfaces only after a download and full extraction already ran, leaving a
half-populated directory and an error that names the symptom, not the cause.
Traps that already cost time here
- A short-circuit (
[ cond ] && cmd) as the LAST statement of the script becomes the exit code. Hit this for real writing the output-summary block:[ "$OUTPUT_IS_TEMP" -eq 1 ] && printf '...'was the final line, and on a persistent--output(the false branch) the whole script exited 1 despite every prior step succeeding — no error printed, everything correct on disk, only$?lying. Fixed with a realif, plus an explicitexit 0as a backstop. The same short-circuit is completely safe mid-script (several exist above it); it is specifically dangerous as the last line of the script, or of theEXITtrap (cleanup()has the same issue and is guarded the same way). exitinside$(...)only kills the subshell.find_dir()is captured withx="$(find_dir ...)"; if it useddie/exiton an ambiguous match, the caller would see a plain non-zero, take the "not found" branch, and the script would carry on to completion with exit 0 — silently defeating the archived-directory guard and the cache-reuse lookup.find_dirinstead returns 0/1/2 and the caller dies at the top level.- A pipe closing early inverts a capability probe into a false negative.
ffmpeg -filters | grep -q ' drawtext 'reports "missing" on a build that has it:grep -qexits at the first match,ffmpegdies of SIGPIPE, andpipefailpromotes that into the branch behaving as if nothing matched. Fixed by capturing the full output first, then matching against the string. Nothing errors when this goes wrong — it just silently takes the degraded path. ffmpegneeds-y -nostdinon every invocation. Without them, a second run against an existing output path can block onOverwrite? [y/N]— a hang, not an error, in whatever ran the tool non-interactively.mpdecimateis a silent no-op without-fps_mode vfr. ffmpeg re-duplicates the frames the filter just dropped to hold a constant output rate, so dedupe appears to run and does nothing. Verified with a negative control: a clip where every sampled frame differs must produce the same frame count with and without--no-dedupe— if it doesn't, this is why.- A URL-derived id must be slugified; a local-file-derived id must be strictly validated —
not the same rule for both. The id is the cache-directory key, globbed verbatim on lookup,
so it must never be silently rewritten after first use (that would break cache reuse for a
value already on disk). But an arbitrary URL's last path segment can contain colons, spaces,
percent-encoding — ordinary and not a sign anything is wrong (a Wikimedia
File:x.ogvpage path, for instance) — so rejecting it outright makes the tool fail on ordinary URLs. Slugifying a URL-derived id before it's ever written to disk is safe and necessary; a local file's basename is the user's to rename, so a genuinely hostile byte there is surfaced instead. drawtext(timestamp labels on the contact sheet) needslibfreetype, and not every ffmpeg build has it — including some official Debian images. The tool degrades to an unlabelled sheet rather than failing;doctorreports which case you're in. Don't assume any particular base image ships it; check.- Contact-sheet cell size is budgeted by AREA, not width. A width cap punishes landscape sources far harder than portrait ones at the same cap — equal area gives both orientations the same pixel budget to render text with.
drawtextruns before the tile filter scales the frame down, so itsfontsizemust be computed in source pixels (desired sheet-pixel size × downscale factor), not sheet pixels directly — reading it as sheet-pixel size once produced a label large enough to cover the frame it was labelling.- An
EXITtrap's return value becomes the script's own exit code.cleanup()must end with an explicitreturn 0; a trailing short-circuit there fails the whole run on a successful cache-hit path (nothing to clean up → the test is false → exit 1). VAR="${2:-}"; shift 2only guards the expansion, not the shift. If$1is the last argument (a flag typo'd at the end of the command, e.g.... --ticket),${2:-}happily expands to empty — butshift 2with a single argument left still fails, andset -ekills the script with no error message at all. Every value-taking flag now checks[ $# -ge 2 ]before consuming, with a realdie "$1 needs a value".- An argument pre-scan that matches a literal flag string anywhere in
$@misreads other flags' values. The--configpre-scan (needed before the main parse loop, since config values must load before CLI flags can override them) originally checked every token for equality with--config— so--title --config --output /xread--outputas the config path. The pre-scan has to walk the same value-taking-flag structure as the main loop and skip each flag's own argument, not just look for one literal string. - A "discarded temp dir" comment is not the same as code that discards it.
--no-framesstill extracts frames (to build the sheet) into amktemp -d, with a comment saying it's "discarded after" — nothing did. It leaked one directory of JPEGs into the OS temp dir per run. Fixed the same way as the other scratch dirs: tracked in a variable, removed incleanup(). A comment describing cleanup that hasn't been wired up reads exactly like real cleanup on a skim. - An explicit
--max-frameswas silently ignored on short clips. The auto-derived budget is clamped byMIN_INTERVAL(so it never asks for more frames than the clip has distinct seconds), and that same clamp used to apply even when the caller had explicitly overridden the budget — so--max-frames 40on a 13.7s clip still produced 14 frames, with no error and no indication the flag hadn't been honoured. Real cost, not theoretical: a triage session read a sparse sheet, missed a transient frame the clamp had quietly excluded from even the explicit request, and wrote a wrong conclusion into a report before re-extracting denser and finding the real explanation. Fixed by skipping the clamp entirely whenMAX_FRAMESis set — an explicit ask beats a heuristic. Verified in both directions: 40 with the flag (now yields up to 40), unchanged with no flag (negative control). - A relative script path in SKILL.md breaks the plugin install. SKILL.md said
./scripts/video-digest.sh; installed as a plugin, Claude resolved that against the skill's own directory and called.../0.2.0/skills/watch-video/scripts/video-digest.sh→ exit 127, "no such file or directory". The script is at the plugin root, one level up fromskills/<name>/. Found only by installing the plugin and running it for real — every native/clone test passes, because there./scripts/...from the repo root happens to be correct. Use${CLAUDE_PLUGIN_ROOT}/scripts/video-digest.sh, which Claude Code sets to the plugin's install dir. The run recovered (Claudefind-ed the script), which is worse than a hard failure: it looks like it worked. find_config_file()picks ONE file, it does not merge.--configbeats a local.video-digest.jsonbeats~/.config/video-digest/config.json— first match wins, full stop. A project-local config file fully shadows the user-wide one rather than overlaying it, so a key set only in~/.config/silently stops applying the moment a directory gets its own.video-digest.json. Documenting this as "layered, later wins" (an easy assumption — it's how most tools' config precedence works) was wrong and shipped in README once already; re-checkfind_config_file()itself before describing the precedence anywhere.--forceand re-extraction are two different things, and conflating them wastes a re-download. A prior version of this tool (the one this was extracted from) tied re-extraction to--force, which also re-downloads — so trying a higher--max-frameson an already-cached clip meant re-fetching an unchanged video just to get denser frames. Not a bug here: this script's cache-hit branch only ever setsSOURCE_MP4; frame extraction runs unconditionally afterward using whatever parameters were passed on this invocation, regardless of whether the download was fresh or reused. Verified:--max-frames 10then--max-frames 40on the same cached clip correctly produced 11 then 28 frames, no--forceneeded. Recorded here so nobody "fixes" this into the other tool's behaviour by mistake.og:videocan name a player page, not a file. YouTube's points at/embed/<id>and Vimeo's atplayer.vimeo.com/video/<id>, both HTML. The Droplr fallback "downloaded" that, and the magic-byte check died blaming an expired link, so YouTube never reached yt-dlp at all, even with yt-dlp installed. YouTube now skips the page fetch entirely, and HTML behindog:videohands the original share URL to yt-dlp.- Every
watch?v=link derived the cache idwatch(last path segment, query dropped), so a second video would have silently reused the first one'ssource.mp4.youtube_id()givesyt-<id>for every link form. No YouTube digest existed on disk before that, so nothing was orphaned. Keep the scheme now that some do. --no-playlistonly narrows a link that names both a video and a playlist. A bare playlist or channel URL would still fetch everything, and derive the shared idplaylist, so a YouTube link with no video id is refused before anything runs.- A
[height<=720]format filter assumes landscape. A vertical Short's 720p is 720x1280, so the filter skipped it and fetched 360x640, a quarter of the sheet's pixel budget. The same trap as the cell budget above.-S res:720caps yt-dlp'sres, which is the smaller side. - A Loom share page's only
.mp4is a 5-second thumbnail preview (cdn.loom.com/sessions/thumbnails/…). The scrape took it, and a 280-second video digested as 5 seconds with exit 0, while README listed Loom as working "via yt-dlp"./thumbnail(s)/URLs are skipped now, so Loom falls through to yt-dlp. Found only by running a real link. - A stale yt-dlp fails on YouTube with
HTTP Error 403: Forbiddenon every format. 2026.07.04 failed two TED talks that way while older videos still downloaded; 2026.10.26 fetched them. doctor shows the version, and a 403 gets "update yt-dlp" in the error. - The cache lookup's glob is not proof of identity.
find_dirmatches*-<id>-*, and once yt-dlp titles named directories, a YouTube digest titled "Product Demo Video" matched a localdemo.mp4and was reused as its cache, exit 0. A hit whosemeta.jsonnames another id is dropped. A video's title names only a NEW directory: on a cache hit the restored title is usually longer than a--titlelabel, and the "enrich a shorter name" rename would erase the label. --js-runtimesis new, and an older yt-dlp rejects it as a usage error, which breaks every yt-dlp path, not just YouTube's. It is passed only whenyt-dlp --helplists it.- The URL suite works only because
video-digest.shnever resetsPATH. Thecurlandyt-dlpstand-ins intest/run-tests.shgo first onPATH; "yt-dlp is missing" is a PATH of symlinks to just ffmpeg/ffprobe/python3, since Homebrew keeps them all in one bin dir. If the script ever needs a fixed PATH (hooks get a minimal one), move the stubs to an explicit override variable first, or every URL test silently starts hitting the network.
Releasing
/release (.claude/skills/release/SKILL.md) cuts a version and
asks before the push; the tag publishes to npm and creates the GitHub Release through
publish.yml. An npm version is permanent: never npm unpublish, never move a tag npm already has.
npx @anaidenko/claude-video-digestinside this repo fails withcommand not found. npx sees that the current project is that package, so it looks for the bin in the empty localnode_modules/.bininstead of the registry. Users are unaffected. Try the published installer from another directory, or with an explicit version, which always fetches.
Security notes
- The scraper is a bounded SSRF surface, not a closed one. Given a URL, it fetches the page
and then follows a second URL found in that page's own content (the embedded
.mp4) — so the page, not the user, has a say in what gets requested next, andcurl -Lmeans a redirect chain can retarget the request even from an initially-external URL. Mitigations in place:--proto '=https,http'(nofile:///gopher://etc.),--max-redirs 3, and the resolved host is printed before downloading so a pivot is visible rather than silent. None of this closes the hole — a CLI tool that fetches a URL you hand it has some irreducible version of this risk — it just bounds and surfaces it. README says so explicitly; don't let that caveat quietly disappear in a future edit. - A share link can 200 with an HTML page instead of a video — expired link, login wall,
moved content. Downloaded and handed to ffmpeg as if it were the real thing, this used to
surface as "could not read duration — is this a video file?", which blames the wrong layer.
A magic-byte check (
<html/<!doctype htmlin the first bytes) now catches the common case before ffmpeg runs, with a message that names what actually happened.
Design decisions that look arbitrary and aren't
- Frame budget scales with duration (
~1 per secondsPerFrame, floored and capped) rather than being a flat number — a fixed count is fine for a short clip and steps straight over the action on a long one. - First and last frame are always kept, regardless of the dedupe/budget math — the opening state and the outcome are usually the two frames a reader actually needs, and even spacing reliably drops the tail.
- A missing
whisper/yt-dlp/curldegrades gracefully (no transcript / no fallback extractor / URL inputs refused) rather than failing the whole run — onlyffmpeg,ffprobeandpython3are hard requirements, checked up front. The exception is a YouTube link, which has no path but yt-dlp: it fails before any directory or fetch when yt-dlp is missing. - Output defaults to the OS temp directory, not the current directory. Writing untracked
files into a stranger's project by default would be rude; a persistent location is opt-in via
--output/ config, and that's also whatkeepSource: autokeys off.
Known gap
Droplr is verified — but it needed a code change, and the reason generalises.
The original extractor only matched URLs ending in a video extension, which was enough for
Zight/CloudApp. Droplr's page embeds no such URL at all: the video lives in an og:video
meta tag pointing at cdn-std.droplr.net/files/acc_NNN/<id> — no extension, so every
extension-based pattern misses it, and yt-dlp doesn't support the host either, so the run died
with "Unsupported URL" despite the video being one meta tag away.
Fixed by falling back to og:video / og:video:secure_url / twitter:player:stream meta tags
when no extension-matched URL is found. Verified against three separate live d.pr/v/ links.
⚠️ The lesson: "same shape, should work" was wrong, and only running it showed that. Before this, both README and this file said Droplr was "expected to work — same page shape as Zight". The page shape was similar; the URL shape was not. If another host is ever added to the claimed list, run it, don't reason about it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

