reel2skill-mcp
# reel2skill
[](https://github.com/lorenzomorselli2009-sudo/reel2skill/actions/workflows/ci.yml)
[](https://www.python.org/downloads/)
[](https://modelcontextprotocol.io/)
[](#cloud-vs-local-providers-zero-vram--vram-safe-modes)
[](https://docs.astral.sh/ruff/)
[](LICENSE)
**Compile 30–90s tech Reels, TikToks, YouTube Shorts, and local MP4s into timestamped Q&A, live-verified GitHub/PyPI/npm discoveries, reproducible playbooks, and prompt-injection-scanned AI agent skills (`SKILL.md`).**
Developers constantly bookmark vertical coding demos—CLI tricks, GitHub repos, Docker setups, MCP workflows—and never open them again. Naive "video-to-markdown" scripts miss commands flashed on screen without speech and blindly trust adversarial text embedded in frames or captions.
`reel2skill` ingests a video once (`yt-dlp` + `FFmpeg` hybrid scene/gap keyframes + dHash cache), fuses spoken audio with visual frames into a unified timeline, verifies extracted packages/repos against official registries, and enforces a fail-closed security pipeline before any `SKILL.md` touches your disk. Works both as a **Rich CLI** and a native **MCP 2.x Server** for **Claude Code, Cursor, Claude Desktop, Codex, and Antigravity**.
<p align="center">
<img src="assets/demo.gif" alt="reel2skill animated CLI demo showing live registry verification and prompt-injection blocking" width="960">
</p>
---
## Architecture
```mermaid
flowchart LR
Source["Video Source (URL or MP4)"] --> Ingest["Ingestion (yt-dlp SSRF Guard + FFmpeg + dHash Cache)"]
Ingest --> Perception["Perception (Gemini / OpenAI / Ollama VLM / Whisper CPU int8)"]
Perception --> Timeline["Unified Timeline (Audio + Keyframe Fusion)"]
Timeline --> Discuss["1. discuss (Timestamped Q&A)"]
Timeline --> Discover["2. discover (GitHub / PyPI / npm Verification)"]
Timeline --> Learn["3. learn (Step-by-Step Playbook)"]
Timeline --> Distill["4. distill (SKILL.md + scripts/)"]
Distill --> Scanner["SecurityScanner (Prompt Injection + RCE + Exfil)"]
Scanner --> Gate["HumanApprovalGate (CLI Prompt / MCP Elicitation / Token)"]
Gate --> Output["Installed Skill Bundle (SKILL.md + scripts/)"]
```
---
## 3-Command Quickstart
Requires **Python 3.11+**, [**uv**](https://docs.astral.sh/uv/), and **FFmpeg** (`ffmpeg` & `ffprobe` on `PATH`).
```bash
# 1. Clone and install (include local-stt for fast CPU Whisper transcription)
git clone https://github.com/lorenzomorselli2009-sudo/reel2skill.git && cd reel2skill
uv sync --extra local-stt
# 2. Optional: configure a cloud VLM/LLM key (or use local Whisper / Ollama with zero keys)
export GEMINI_API_KEY="your-api-key"
# 3. Pass any YouTube Short / TikTok / Reel URL or local .mp4 file
uv run reel2skill discover "https://www.youtube.com/shorts/<video-id>" --verify
uv run reel2skill distill ./your_video.mp4 --preview-only
```
---
## The Four Cognitive Modes
### 1. `discuss` — Watch & Discuss with Timestamp Citations
Ask targeted questions about what was said *and* shown on screen, grounded with `[MM:SS]` citations.
```bash
uv run reel2skill discuss ./demo_reel.mp4 --question "Which ruff and uv commands were used?"
```
### 2. `discover` — Extract & Verify Repos, Packages, and Tools
Extracts GitHub repositories, PyPI/npm packages, CLI tools, and config files from speech + OCR, with live HTTP verification against `api.github.com`, `pypi.org`, and `registry.npmjs.org`.
```bash
uv run reel2skill discover "https://www.youtube.com/shorts/..." --verify
```
### 3. `learn` — Reproducible Step-by-Step Playbook
Turns fast-paced edits into an ordered checklist with prerequisites, copy-paste commands, expected outcomes, and common pitfalls.
```bash
uv run reel2skill learn ./demo_reel.mp4 --focus "CI setup" --output playbook.md
```
### 4. `distill` (alias: `distill-to-skill`) — Compile a Portable `SKILL.md` Bundle
Generates a structured `SKILL.md` (strict single-line YAML frontmatter + triggers + workflow) and optional `scripts/*.py` helpers, runs the mandatory security audit, previews a unified diff, and writes to disk **only after human approval**.
```bash
# Safe read-only preview (never writes files)
uv run reel2skill distill ./demo_reel.mp4 --preview-only
# Interactive confirmation (or pass --yes to install automatically ONLY if security scan passes)
uv run reel2skill distill ./demo_reel.mp4 --output-dir ./.agents/skills
uv run reel2skill distill ./demo_reel.mp4 --output-dir ./.agents/skills --yes
```
### Timeline & Cache Inspection
```bash
uv run reel2skill inspect ./demo_reel.mp4
uv run reel2skill cache list
uv run reel2skill cache clear
```
---
## Cloud vs. Local Providers (Zero-VRAM & VRAM-Safe Modes)
When `REEL2SKILL_PROVIDER=auto` (default), `reel2skill` resolves in order:
1. **`gemini`** if `GEMINI_API_KEY` / `GOOGLE_API_KEY` is set
2. **`openai`** if `OPENAI_API_KEY` is set
3. **`whisper`** if `faster-whisper` (`--extra local-stt`) is installed and `REEL2SKILL_LOCAL_STT_ENABLED=true`
4. **`heuristic`** deterministic offline fallback
**`reel2skill` never probes or loads local Ollama models unprompted**—protecting consumer GPUs (8–12 GB VRAM) unless you explicitly opt in via `--provider ollama` or `REEL2SKILL_PROVIDER=ollama`.
| Provider | Audio STT | Keyframe Vision / OCR | Skill / Playbook Synthesis | GPU VRAM Used | Best For |
| --- | --- | --- | --- | --- | --- |
| **`gemini`** | `gemini-3.5-transcribe` | `gemini-4-hydrogen` | Cloud LLM | `0 GB` | Highest accuracy standalone CLI & MCP |
| **`openai`** | `whisper-1` | `gpt-4o-mini` | Cloud LLM | `0 GB` | OpenAI / compatible API endpoints |
| **`whisper`** | `faster-whisper` (`cpu` `int8`) | Keyframe extraction (`keyframe_paths`) | Host MCP Agent *(or local template)* | **`0 GB`** | **MCP hosts** (Claude Code, Cursor, Antigravity) & sub-15s local `inspect`/`discover` |
| **`ollama`** | `faster-whisper` (`cpu` `int8`) | `qwen2.5vl:7b` (resized <=640px, batch `keep_alive`) | `qwen2.5:14b-instruct-q4_K_M` (`keep_alive=0`) | Sequential unload (`keep_alive=0`) | 100% offline standalone `distill` & `learn` |
| **`heuristic`** | `.srt`/`.vtt` sidecar | Pillow frame metadata | Deterministic template | `0 GB` | Airgapped CI & deterministic testing |
> [!IMPORTANT]
> **Choosing between `whisper` and `ollama` locally:**
> - Use **`whisper`** when running `reel2skill-mcp` inside **Claude Code, Cursor, or Antigravity**: `reel2skill` downloads the video, extracts deduplicated keyframes, and transcribes speech on CPU `int8` in ~5–15s using **zero GPU VRAM**, handing `full_transcript` + `keyframe_paths` directly to your Frontier agent.
> - For **standalone CLI `distill` or `learn`**, pass `--provider gemini`, `--provider openai`, or `--provider ollama` so a full VLM + LLM synthesizes the OCR and workflow steps (standalone `whisper` does not run an LLM and formats raw transcript lines).
---
## Authenticated TikTok & Instagram Reels (`cookies`)
TikTok and Instagram frequently login-wall `yt-dlp` requests without session cookies. You can pass cookies safely via CLI flags or environment variables:
```bash
# Use cookies directly from a local browser profile (firefox, chrome, edge, brave, ...)
uv run reel2skill discover "https://www.tiktok.com/@creator/video/123456" --cookies-from-browser firefox --verify
# Or pass an exported Netscape cookies.txt file
uv run reel2skill inspect "https://www.instagram.com/reel/XYZ/" --cookies-file ~/.config/reel2skill/cookies.txt
```
Or set `REEL2SKILL_COOKIES_FROM_BROWSER=firefox` or `REEL2SKILL_COOKIES_FILE=/path/to/cookies.txt` in your MCP server `env`.
**Security by design:** MCP tool schemas intentionally **never** expose cookie parameters to the LLM, preventing a prompt-injected agent from reading arbitrary files or browser profiles.
---
## MCP Integration (Claude Code, Cursor, Claude Desktop, Antigravity)
`reel2skill` ships a native **MCP 2.x** `stdio` server (`reel2skill-mcp`) exposing six tools:
- `inspect_video_timeline` — Ingest & return synchronized timeline + `keyframe_paths`
- `watch_and_discuss` — Timestamp-cited Q&A (`full_transcript` + `keyframe_paths` + `security_warnings`)
- `discover_resources` — Extract & verify repos, packages, and CLIs
- `learn_playbook` — Build a step-by-step reproducible playbook
- `distill_skill_preview` — Compile & security-scan a `SKILL.md` draft, returning `preview_id` and SHA-256 `content_digest` (**read-only, never writes to disk**)
- `save_approved_skill` — **Disabled by default** (`REEL2SKILL_ALLOW_MCP_INSTALL=false`). When explicitly enabled, requires an allowlisted `output_dir`, security pass, and **out-of-band human confirmation** (interactive MCP Elicitation or `REEL2SKILL_MCP_APPROVAL_TOKEN` bound to `preview_id` + `expected_digest`).
Add to `.cursor/mcp.json`, `claude_desktop_config.json`, or `mcp_config.json`:
```json
{
"mcpServers": {
"reel2skill": {
"command": "uv",
"args": [
"run",
"--directory",
"/absolute/path/to/reel2skill",
"--no-sync",
"reel2skill-mcp"
],
"env": {
"REEL2SKILL_PROVIDER": "auto",
"REEL2SKILL_ALLOW_MCP_INSTALL": "false"
}
}
}
}
```
---
## Security & Indirect Prompt Injection Defense
Short-form videos can hide untrusted instructions inside **on-screen text overlays (OCR)**, **spoken audio**, or **attacker-controlled video titles/descriptions**. Compiling untrusted media into an agent skill requires strict defense-in-depth:
1. **Multilingual & De-obfuscated Indirect Prompt Injection Detection (`SecurityScanner`)**
- Scans individual timeline events, video metadata (`title`, `uploader`, `description`), and **cross-frame / cross-field streams** (catching split-frame OCR and spoken+OCR split payloads).
- Normalizes NFKC, Cyrillic/Greek homoglyphs, zero-width/bidi/tag Unicode smuggling (preserving valid emoji ZWJ), shell quote/backtick splitting (`c'u'r'l`, ``i`ex``), leetspeak, HTML comments/entities, URL encoding, Hex escapes, and Base64 blobs in guaranteed linear `O(N)` time (ReDoS-safe).
- Wraps all LLM prompts with per-call cryptographic random-nonce XML boundaries (`<untrusted_video_transcript_<nonce>>`) and enforces single-line YAML frontmatter (`name`, `description` only).
2. **Shell RCE, Supply-Chain & Exfiltration Blocking**
- Blocks pipe-to-shell (`curl|sh`, `bash <(curl ...)`, `$(curl ...)`), PowerShell cradles (`IEX`, `Net.WebClient`, `-EncodedCommand`), Windows LOLBins (`certutil`, `mshta`, `bitsadmin`, `regsvr32`), reverse shells, inline interpreter RCE (`python -c`, `node -e`), unverified git/URL package installs (`pip install git+http://`, `uvx --from`, remote `npx`), and credential/env exfiltration (`~/.ssh/*`, `~/.aws/*`, `.env`, `os.environ`, DNS tunneling, webhook/ngrok/Discord sinks)—while preserving zero false positives on legitimate developer tutorials.
3. **Filesystem, Symlink/Junction, SSRF & Resource Exhaustion Hardening**
- Rejects path traversal, control characters, NTFS alternate data streams, trailing dots/spaces, and Windows reserved device names (`CON`, `NUL`, `AUX`, `COM1`–`COM9`, `LPT1`–`LPT9`).
- Prevents symlink/junction escapes (`FILE_ATTRIBUTE_REPARSE_POINT`) and TOCTOU races via exclusive creation (`O_CREAT | O_EXCL`, `allow_skill_overwrite=false`).
- Enforces public-IP DNS validation (`validate_remote_url`) across initial URLs, `yt-dlp` sub-requests and HTTP redirect hops, and `EntityVerifier` redirects (blocking `file://`, loopback, RFC1918, link-local/IMDS `169.254.169.254`, and obfuscated hex/octal/decimal IPs), plus hardened `ffmpeg -protocol_whitelist file` args and strict byte caps (`max_video_filesize_bytes`, `max_audio_bytes`, `max_frame_bytes`).
4. **Mandatory Independent Re-Scan & Unbypassable Human Gate**
- `SkillInstaller.install()` independently re-scans every draft prior to disk write and unconditionally blocks `CRITICAL` findings.
---
## Development
```bash
uv sync --dev --extra local-stt
uv run ruff check .
uv run ruff format --check .
uv run pytest -v
```
## License
[MIT](LICENSE)
TDQS
Scored across 6 tools
The tools mostly target distinct stages of a video-to-skill workflow: discussion, resource extraction, playbook generation, timeline inspection, preview distillation, and approved saving. The main potential overlap is between watch_and_discuss and learn_playbook, since both analyze a video and produce explanatory output, though their descriptions distinguish Q&A/discussion from structured step-by-step playbooks.
All names use snake_case and begin with a verb, giving a generally predictable pattern. Minor deviations exist: watch_and_discuss is verb_and_verb rather than verb_noun, and distill_skill_preview and inspect_video_timeline use longer three-part names.
Six tools is well-scoped for a video-to-skill pipeline. Each tool represents a clear stage: inspect, discuss, discover, learn, preview, and save, with no obviously redundant entries.
The surface covers the core lifecycle from raw timeline extraction through discussion, playbook creation, preview distillation, and approved saving. Minor gaps remain around retrieving or listing already saved skills and updating/removing existing skills, but agents can work around these for the stated purpose.