I wanted Claude Code to read a YouTube talk and answer questions about it.
It can't watch video, so the real job is getting the transcript into a file it can read.
I tested two ways today, 2 Dec 2026, on Andrej Karpathy's one-hour "Intro to Large Language Models" talk.
The first is free.
The second is a paid API I built, and it comes after.
The free route: yt-dlp and a cleanup step
yt-dlp downloads YouTube's captions without the video.
yt-dlp --skip-download --write-auto-subs --sub-langs en --sub-format vtt \
-o "%(id)s" "https://www.youtube.com/watch?v=zjkBMFhNj_g"
On my home connection that took 2.95 seconds and wrote a 603 KB .vtt file.
Don't hand that file to Claude as it is.
Auto-generated captions roll, so each line repeats as the next one comes in, and the file holds 53,485 words for a talk with 12,151 words of speech.
That's more than four times the tokens for the same content.
This strips the timings and tags and drops the repeats.
import re, sys
seen_last = None
words = []
for line in open(sys.argv[1], encoding="utf-8"):
line = re.sub(r"<[^>]+>", "", line).strip()
if not line or "-->" in line or line.startswith(("WEBVTT", "Kind:", "Language:")):
continue
if line != seen_last:
words.append(line)
seen_last = line
print(" ".join(words))
python3 vtt2txt.py zjkBMFhNj_g.en.vtt > talk.txt gives 12,151 words, and Claude Code reads talk.txt like any other file.
If yt-dlp is installed where your agent runs, that's all you need.
The one-call route: a transcript API
I build a YouTube transcript actor on Apify, and it also answers plain HTTP requests.
One GET returns the cleaned transcript as JSON, with the title, channel, language and a word count.
curl -G "https://heyitsgautham--youtube-transcript-scraper.apify.actor/transcript" \
--data-urlencode "video=https://www.youtube.com/watch?v=zjkBMFhNj_g" \
--data-urlencode "timestamps=false" \
-H "Authorization: Bearer $APIFY_TOKEN"
For the same talk it returned the same 12,151 words in 5.2 seconds.
Two longer Karpathy videos came back in 4.0 seconds with 21,030 words and in 10.8 seconds with 41,116 words.
A video with no captions answers 404 and costs nothing.
To let Claude Code use it without being told how, save this as .claude/skills/yt-transcript/SKILL.md in your project.
---
name: yt-transcript
description: "Fetch the transcript of a YouTube video as plain text. Use when the user gives a YouTube link and wants it summarised, quoted or searched."
---
Fetch the transcript with one request, then read the file.
```bash
curl -s -o /tmp/yt.json -w "%{http_code}\n" -G \
"https://heyitsgautham--youtube-transcript-scraper.apify.actor/transcript" \
--data-urlencode "video=$URL" --data-urlencode "timestamps=false" \
-H "Authorization: Bearer $APIFY_TOKEN"
jq -r '.title, .wordCount, .transcript' /tmp/yt.json > /tmp/yt.txt
```
- 200 means `/tmp/yt.txt` holds the title, the word count and the transcript.
- 404 means the video has no captions or was removed. Say so and stop.
- Long talks run past 10,000 words, so read the file in parts instead of printing it.
Then ask in plain words.
I ran claude -p "Summarise https://www.youtube.com/watch?v=zjkBMFhNj_g in 3 bullet points, and tell me how many words the transcript has." with APIFY_TOKEN set in the environment and curl, jq and Read allowed.
Claude Code picked up the skill, fetched the transcript, read the file and answered 28 seconds later.
The three bullets covered what an LLM is, where Karpathy thinks they're going, and LLM security, and it reported 12,151 words.
Which one to use
Use yt-dlp when it runs where your agent runs.
It's free, and it gave the same text in my test.
The API is for when you'd rather not install yt-dlp and keep the cleanup script around, or when the agent runs somewhere you can't add tools.
It costs $3 per 1,000 transcripts, less on Apify's discount tiers, and failed lookups are free.
You need an Apify API token, which is under Settings, API & Integrations in Apify Console.
The actor's page has a ready-made example for Claude Code you can run from the browser first.
This article was created with the help of AI. An AI agent (Claude) ran every command above on 2 Dec 2026 and drafted the text from those runs, and every number is copied from them.
Top comments (0)