先说结论:HackerTube 的核心思路很简单:把 Hacker News 评论里贴过的 YouTube 链接全部找出来,只留下被很多不同的人、在很多个不同月份反复推荐的视频,做成一个不需要登录、没有推荐算法的视频站。这件事现在交给 Claude Code 或 Codex,一段提示词就能做出可用的缩小版。
- 据 Karpathy 11 月 2 日凌晨(北京时间)的原帖,他嫌 YouTube 推荐不好,让 Claude 把 HN 20 年里约 4300 万条评论筛到 6,454 个被反复推荐的视频,用 Claude Code 桌面版和 Opus 5.5(Medium effort)做了约两小时。他自己只做了三件事:在 Google Cloud 后台建一个查 YouTube 信息用的 API Key、开一台 VPS、买域名。截至 11 月 2 日下午,这条帖子约 330 万次浏览、3.97 万点赞、3.4 万收藏。
- 我们用本站 Key 让 Claude Code 和 Codex 各做了一个缩小版:用 HN 官方 Algolia API 抓 2026 年 9–10 月的评论,两边都在 约 9 分钟内跑完,都找到约 3,600 条带 YouTube 链接的评论、3,500 多个不同的视频,按「至少 2 个不同的人推荐」留下 193 个,排名前三完全一致。
- 缩小版和 HackerTube 差在「判断评论是不是在推荐」:只按链接次数排,热门新闻视频会冲到前面(第 3 名的 12 次提及全部来自同一个帖子)。文末给出补上这一步的提示词。
创建 API Key,在 Claude Code、Codex、Cursor 里做你自己的 HackerTube →
HackerTube 是什么,Karpathy 是怎么做的
HackerTube 的副标题是「Hacker News 一直在互相推荐的 YouTube 视频」。据它的关于页,站上目前有 6,454 个视频,读了 39,834 条提到这些视频的 HN 评论,分成 16 个大类、150 个话题,时间跨度 2007–2026 年。点赞、历史、稍后观看都只存在你自己的浏览器里,没有账号;缩略图用的是视频中段的一帧,不是作者精心优化过的封面。
据关于页「How it was built」一节,做法分五步:
| 步骤 | HackerTube 的做法 |
|---|---|
| 1. 读全部评论 | 用公开的 HN 全量存档(open-index/hacker-news 数据集)扫出所有 YouTube 链接,得到十几万个不同视频 |
| 2. 只留被反复推荐的 | 至少 3 个不同的人、在至少 3 个不同的月份贴过,并且带了真正的评论,剩下约 7,000 个 |
| 3. 让模型读每条评论 | Claude 结合帖子标题判断这条评论是在推荐、引用、开玩笑还是批评,摘一句引语和几个话题 |
| 4. 给每个视频写卡片 | 根据 YouTube 信息和 HN 的所有评论,写摘要、HN 为什么喜欢它、类型、是否过时 |
| 5. 排名 | 按「有几个不同的月份有人推荐」排,多年反复被推荐比一次爆火更重要 |
关于页还写明,整个站点、数据管道、搜索和推荐都是 Claude Opus 5.5 在 Claude Code 里做的,评论标注和视频卡片由 Opus 协调的一组 Claude Sonnet 5.5 Agent 完成。数据也放出来了:在 Data 页能下载一个约 17.8 MB 的压缩包,里面有 videos.jsonl、mentions.jsonl、话题表、向量和一份写给 Agent 看的 DATA.md,协议是 ODC-By 1.0。Karpathy 在原帖里的建议是:把这个包交给你的 Claude,让它做一个你自己的版本。
另据 X 热点汇总(一、二),帖子发出后已经有人照着做了 arXiv 论文版的 Hacker Papers,以及书和博客的推荐合集。
缩小版要做什么
完整复刻 20 年的数据要下载整个 HN 存档,不适合第一次上手。我们把范围缩小到两个月,只用 HN 官方的 Algolia 搜索 API,不需要任何 Key:
| 步骤 | 做法 | 产出 |
|---|---|---|
| 1. 抓评论 | Algolia search_by_date,tags=comment,按时间分窗口 | data/comments.jsonl |
| 2. 抽链接 | 从评论正文里抽出 11 位视频 ID,兼容 watch?v=、youtu.be/、/shorts/ 等写法 | 每条评论提到的视频 |
| 3. 去重计数 | 每个视频统计提及次数、不同推荐人数、不同月份数 | 排名 |
| 4. 补标题 | YouTube oEmbed 接口,不需要 Key | data/videos.json |
| 5. 出页面 | 一个静态 HTML,卡片网格加前端搜索框 | site/index.html |
第 1 步:创建 API Key 并接入 Claude Code 或 Codex
- 在 aicodewith.ai 注册并登录,进入「密钥管理」,创建一个 Key,复制完整字符串。
- Claude Code:设置地址和 Key,新建一个空文件夹并在里面启动:
export ANTHROPIC_BASE_URL="https://api.aicodewith.ai"
export ANTHROPIC_AUTH_TOKEN="你的 API Key"
mkdir -p ~/hackertube-mini && cd ~/hackertube-mini
claude --model claude-opus-5-5
想长期保存配置、在 Windows 上设置,看《Claude Code 如何接入第三方 API》。Karpathy 用的是 Opus 5.5 的 Medium effort,档位怎么选见《Claude Opus 5.5 effort 怎么选》,模型对比见《Claude Code 用哪个模型》。
- Codex:在
~/.codex/config.toml里写入下面的配置,Key 直接写在experimental_bearer_token:
# ~/.codex/config.toml
model = "gpt-6.1-sol"
model_reasoning_effort = "medium"
model_provider = "aicodewith"
[model_providers.aicodewith]
name = "aicodewith"
base_url = "https://api.aicodewith.ai/chatgpt/v1"
wire_api = "responses"
experimental_bearer_token = "你的 API Key"
每个字段的含义见《Codex config.toml 配置详解》,第一次用 Codex 可以先看《Codex 怎么用》和《Codex 安装教程》。
第 2 步:先自己看一眼 HN Algolia API
动手前先跑一条请求,心里有数。下面这条查的是 2026-09-01 这一天里包含 youtu 的评论(youtube.com 和 youtu.be 都能匹配到):
# comments posted on 2026-09-01 (UTC) that contain "youtu"
curl "https://hn.algolia.com/api/v1/search_by_date?query=youtu&tags=comment&hitsPerPage=1000&numericFilters=created_at_i>=1788220800,created_at_i<1788307200"
我们实测这一天 HN 一共有 10,830 条评论,包含 youtu 的有 197 条。要注意两个限制:
- 每次查询最多返回 1000 条。直接查两个月,
youtube.com一个词就有 4,000 多条结果,超出的部分拿不到,所以必须按时间切成小窗口。 - 只搜
youtube会漏掉短链接。youtu.be/xxxx里没有youtube这个词,要用youtu前缀,再在本地用正则精确匹配。
这两点我们都写进了提示词,Claude Code 和 Codex 也都在动手前自己先试了请求、确认了上限。
第 3 步:把提示词交给 Agent
把下面这段存成 prompt.txt,交给 Claude Code 或 Codex。这是我们实测用的原文:
Build a mini "HackerTube" in this folder: a static site of the YouTube videos that Hacker News commenters keep recommending to each other.
1. Fetch data only from the official HN Algolia API (https://hn.algolia.com/api/v1/search_by_date, tags=comment). Take every comment created from 2026-09-01 00:00 UTC to 2026-10-31 23:59 UTC that contains a YouTube link (youtube.com/watch, youtu.be/, /embed/, /shorts/, m.youtube.com, music.youtube.com). Note the API returns at most 1000 hits per query, so split the time range into small enough windows. Be polite: at most 2 requests per second. Save raw hits to data/comments.jsonl.
2. Extract and normalize the 11-character video ids (HTML-unescape the comment text first), and drop the commenter's own repeated links within the same comment.
3. For each video count: mentions, distinct commenters, distinct months, first and last mention, and keep up to 3 short quotes with links to the HN comment (https://news.ycombinator.com/item?id=...). Keep a video only if at least 2 different people linked it. Rank by distinct commenters, then mentions.
4. Get titles for the kept videos from YouTube oEmbed (https://www.youtube.com/oembed?url=...&format=json, no API key); if oEmbed fails keep the id and mark it unavailable. Save data/videos.json.
5. Generate site/index.html: a single static page, no login and no tracking, with a grid of cards (thumbnail from https://i.ytimg.com/vi/<id>/hqdefault.jpg, title, channel, "N people / M mentions", one quote) and a client-side text filter.
6. Write the whole pipeline as a reusable script build.py (stdlib only, with a --since/--until option) and run it. Finally reply with: total comments fetched, unique videos found, videos kept, the top 10 videos (id, title, people, mentions), and any problems you hit.
提示词里有三个要点:明确数据源只用官方 API,Agent 就不会去抓网页;提前说清 1000 条上限和请求频率,省得它跑到一半才发现数据不全;要求写成可重跑的 build.py,以后换时间段、换门槛不用再开一次对话。
想在后台跑,用非交互模式。Claude Code 用 --allowedTools 只放行这次需要的命令;Codex 默认沙盒不能联网,我们在一个专门的空文件夹里用了 --sandbox danger-full-access,这个权限很大,不要在放着重要文件的目录里用,权限怎么设见《Codex 自动化权限配置》:
# Claude Code, non-interactive: only allow the commands this job needs
cat prompt.txt | claude -p --model claude-opus-5-5 \
--permission-mode acceptEdits \
--allowedTools "Bash(python3:*)" "Bash(curl:*)" "Bash(ls:*)" "Bash(mkdir:*)" "Bash(head:*)" "Bash(wc:*)"
# Codex, non-interactive (reads the prompt from stdin)
codex exec --skip-git-repo-check --sandbox danger-full-access - < prompt.txt
实测:用本站 Key 跑 Claude Code 和 Codex
两个客户端用同一段提示词,在同一台 Linux 机器上同时跑,时间是 2026 年 11 月 2 日下午:
| Claude Code 2.1.316 + Opus 5.5 | Codex 0.166.0 + GPT-6.1 Sol | |
|---|---|---|
| 耗时 | 约 555 秒,21 轮 | 约 534 秒,执行了 30 条命令 |
| 抓取方式 | 按天分窗口查 youtu,超过 1000 条的窗口自动对半再切,共 61 次请求 | 按天分 61 个窗口查 youtu,并检查每个窗口都没到 1000 条 |
| 含 YouTube 链接的评论 | 3,624 条 | 3,619 条 |
| 不同的视频 | 3,511 个 | 3,505 个 |
| 至少 2 人推荐、保留 | 193 个 | 193 个 |
| 取不到标题 | 2 个(oEmbed 返回 403、401) | 同左 |
| 自检 | 拿一天做全量扫描对照,预筛和全量都找到 87 条带链接评论 | 写了 5 个测试,用无头 Chrome 打开页面检查卡片和搜索框 |
| 产出 | build.py 418 行,index.html 约 258 KB | build.py 258 行,index.html 约 210 KB |
两边不约而同选了同一种抓法:不扫全部评论(两个月约 60 万条),而是按天查 youtu,再在本地精确匹配。Claude Code 还专门验证了这个捷径:拿 9 月 1 日做了一次全量扫描,结果和预筛完全一致,同时指出只查 youtube 会漏掉 20 条短链接评论。
排名前 10 两边几乎一样,前三完全相同。我们额外算了每个视频「在同一个帖子里被提了几次」:
| 排名 | 视频 | 推荐人数 | 提及次数 | 月份数 | 同一帖子里最多 |
|---|---|---|---|---|---|
| 1 | 216,000,000 Spy TVs – The LG Smart TV Problem | 15 | 18 | 2 | 7 |
| 2 | Kernel Recipes 2026 - Security in the LLM age | 12 | 21 | 1 | 2 |
| 3 | The FLYING Tesla Roadster explained by the man who engineered it | 11 | 12 | 1 | 12 |
| 4 | LG Says We're Fake News | 6 | 7 | 1 | 6 |
| 5 | Reinventing Entropy – Compression is Intelligence Part 1 | 6 | 6 | 2 | 3 |
data/videos.json 里每个视频长这样,引语都带回 HN 原评论的链接:
{
"id": "6IFVTcM28KA",
"title": "216,000,000 Spy TVs | The LG Smart TV Problem",
"people": 15, "mentions": 18, "months": 2,
"first_mention": "2026-09-07T10:52:26Z",
"last_mention": "2026-10-13T16:41:11Z",
"quotes": [
{"author": "wavesplash", "date": "2026-09-07",
"url": "https://news.ycombinator.com/item?id=49597752",
"text": "... Worth a watch to see how bad this is"}
]
}
生成的 build.py 支持换时间段和门槛重跑(以 Claude Code 版为例):
python3 build.py --since 2026-09-01 --until 2026-10-31 # full run
python3 build.py --skip-fetch --min-people 3 # rebuild from saved comments with a stricter rule
python3 build.py --full-scan # scan every comment instead of the "youtu" prefilter (slow)
实测发现的三个问题
- 按链接次数排,会把「本周热点」当成「经典推荐」。第 3 名的 12 次提及全部来自同一个讨论这条视频的帖子,第 4 名也有 6 次来自同一帖。这正是 HackerTube 要求「至少 3 个不同月份」并让模型判断每条评论态度的原因。两个月的数据里,同时满足「至少 3 人、至少 2 个月」的只有 22 个视频。
- 网友贴的 URL 经常写错,两个客户端处理方式不同。Claude Code 比 Codex 多收了 5 条评论,都是下面这类写法。Claude Code 按「取开头 11 位」宽松收下,Codex 按标准 URL 解析严格丢掉。第三条其实多了两位,按 11 位截取可能会认错视频:
https://www.youtube.com/watch?v=sCr_gb8rdEI?t=11m <- "?" instead of "&"
https://youtu.be/69o-8Mtd3Kc&t=330 <- "&" instead of "?"
https://www.youtube.com/watch?v=909o_kbCdFgll <- 13 characters, not 11
- oEmbed 不是每个视频都能取到标题。保留的 193 个里有 2 个返回 403 或 401,多半是私有视频或者关了嵌入,两边都把它们标成不可用、只显示 ID。要拿时长、播放量这类信息,得像 Karpathy 那样去 Google Cloud 建一个 YouTube Data API 的 Key。
从缩小版到 HackerTube,还差这几步
第一,让模型判断评论态度。 这是效果差别最大的一步。在缩小版的文件夹里接着对 Agent 说:
For each comment in data/comments.jsonl, read the comment text and the HN story title,
and label what the commenter does with the video: strong_rec, rec, reference, joke or critical.
Write the labels to data/stance.jsonl. Then only count strong_rec and rec,
keep a video if at least 3 different people recommended it in at least 3 different months,
and rank by the number of distinct months. Rebuild site/index.html.
几千条评论逐条判断会比较慢,可以让 Agent 分批并行。Codex 同时开太多任务可能碰到 429,并发怎么控制见《Codex 429 Too Many Requests 怎么解决》。
第二,用更长的数据。 Algolia 适合按时间段增量抓;要覆盖 2007 年至今,用 HackerTube 关于页提到的 open-index/hacker-news 全量数据集更合适。最省事的办法是直接下载 HackerTube 的数据包,让 Agent 先读 DATA.md,再按你的口味改界面或排名。
第三,部署上线。 缩小版是纯静态页,放到任何静态托管上都能打开。据 Karpathy 原帖,他把 VPS 的 IP 交给 Claude,让它更新系统、加固安全、部署并优化,全程由 Claude 完成。
常见问题
Algolia 返回的条数比 nbHits 少
每次查询最多拿 1000 条,nbHits 只是总数。把时间窗口切小,直到每个窗口的结果都少于 1000 条;我们这次按天切就够了,热门日子可以再对半切。
为什么查 youtube 抓不全
短链接 youtu.be 不包含 youtube。用 youtu 查,再在本地用正则过滤 watch?v=、youtu.be/、/embed/、/shorts/ 等写法。
评论里的链接是 / 这种乱码
Algolia 返回的 comment_text 是 HTML 转义过的,/ 会变成 /,& 会变成 &。先做 HTML 反转义再抽链接,否则正则一个也匹配不上。我们在提示词第 2 条里专门写了这一点。
想换成论文、书或播客
把提示词里的 YouTube 换成 arxiv.org/abs/、amazon.com/dp/ 或播客链接,计数和出页面的逻辑都能复用。精读论文的流程可以接着看《用 Claude Code 检索和精读 arXiv 论文》。
想让 Agent 每次都按同一套规则做
把数据源、门槛和页面要求写进项目的 CLAUDE.md 或 AGENTS.md,写法见《Claude Code 的 CLAUDE.md 怎么写》。
小结
HackerTube 说明了一件事:「用别人的品味筛内容」这类小产品,现在一个人加一个编程 Agent 就能做。我们实测,用 Claude Code 或 Codex 爬 Hacker News 评论、抽 YouTube 链接、出一个能用的静态视频站,大约 9 分钟就能完成。真正决定质量的,是「什么算推荐」这条规则,以及时间跨度够不够长。



