Skip to content
Back to search

karpathy-wiki

基于 [Andrej Karpathy]提出的 [LLM Wiki 模式]构建的 Agent Skill,通过四阶段流水线将碎片化信息转化为结构化、可检索、持续增长的个人知识库。

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/sherwinq--karpathy-wiki/badge.svg)](/listings/sherwinq--karpathy-wiki)

HTML

<a href="/listings/sherwinq--karpathy-wiki"><img src="/api/listings/sherwinq--karpathy-wiki/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

1. 安装 Skill

将 `karpathy-wiki/` 目录放入 Agent 的 skills 目录:

# 方式一:克隆到 .agents/skills/
git clone https://github.com/your-username/karpathy-wiki.git .agents/skills/karpathy-wiki

# 方式二:手动复制
cp -r karpathy-wiki/ .agents/skills/karpathy-wiki

本 Skill 遵循 [agentskills.io](https://agentskills.io) 开放规范,兼容 Claude Code、Cursor、Codex 等支持 SKILL.md 的工具。

2. 安装 Obsidian CLI(推荐)

1. 安装最新版 [Obsidian](https://obsidian.md) 2. 设置 → 通用 → 开启「Command line interface」 3. 注册 CLI(按提示将 Obsidian 加入 PATH) 4. 终端验证:`obsidian help`

3. 配置 PDF/图片解析(可选)

编辑知识库根目录下的 `.env` 文件,填入百度 PaddleOCR Layout Parsing API 的 URL 和 Token:

LAYOUT_API_URL=https://your-api-url
LAYOUT_API_TOKEN=your-token

安装 Python 依赖:

pip install requests

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

SKILL.md · Manifest · 87 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ---
  2. name: karpathy-wiki
  3. description: Use when building or maintaining a personal knowledge base with LLM assistance. Triggers on ingesting sources, compiling wiki articles, querying knowledge, running health checks, deep research, or initializing a new wiki vault. Based on Karpathy's LLM Wiki pattern with Obsidian integration.
  4. ---
  5. # Karpathy Wiki
  6. LLM-driven personal knowledge base that compounds over time. Raw sources in, structured wiki out.
  7. > You never write the wiki. The LLM writes everything. You just steer, and every answer compounds.
  8. ## When to Use
  9. - User wants to ingest documents, URLs, or text into a knowledge base
  10. - User wants to query, compile, or maintain wiki articles
  11. - User needs deep research to fill knowledge gaps
  12. - User wants to initialize a new wiki vault
  13. ## When NOT to Use
  14. - One-off Q&A without persistent knowledge storage
  15. - Note-taking without cross-referencing or structure
  16. - Non-text content management (images, videos alone)
  17. ## Core Principles
  18. 1. **raw/ is immutable** — sources are never edited; re-ingest as new version
  19. 2. **purpose.md anchors direction** — read on every operation, align output with wiki goals
  20. 3. **Classify before extract** — determine entity type during Ingest, choose chapter structure during Compile
  21. 4. **Analyze before generate** — two-step Compile: structured analysis → article generation
  22. 5. **Backlink audit is mandatory** — bidirectional links are the knowledge graph
  23. 6. **Query answers must be archived** — good answers are compounding fuel
  24. 7. **Token budget first** — always read index before full articles (L0→L1→L2→L3)
  25. 8. **Human verifies, LLM maintains** — LLM writes, user steers
  26. ## Pipeline
  27. | Stage | Input | Output |
  28. |-------|-------|--------|
  29. | **Ingest** | URLs, files, text | `raw/` (immutable) + hash cache |
  30. | **Compile** | raw/ files | `wiki/<domain>/` articles by entity type |
  31. | **Query** | Questions | Cited answers → `outputs/queries/` |
  32. | **Lint** | Full wiki | Health report → `outputs/reports/` |
  33. Each stage appends `log.md`. Lint and Query can trigger **Deep Research** to fill gaps.
  34. ## Token Budget
  35. | Level | ~Tokens | When | What |
  36. |-------|---------|------|------|
  37. | L0 | ~200 | Every session | SKILL.md frontmatter |
  38. | L1 | ~1-2K | Session start | purpose.md + Concept Index + Dashboard |
  39. | L2 | ~2-5K | Search | Result summaries |
  40. | L3 | 5-20K | Deep read | Full articles or raw sources |
  41. ## Entity Types
  42. 7 types, each with different required sections (see `references/entity-types.md`):
  43. `concept` (default) · `person` · `tool` · `event` · `comparison` · `pattern` · `overview`
  44. ## Commands
  45. | Command | Action |
  46. |---------|--------|
  47. | `init [path] [--template <t>]` | Initialize vault (templates: general/research/reading/project) |
  48. | `ingest <source>` | Collect + classify + archive (no wiki generation) |
  49. | `compile [topic]` | Two-step: analyze → generate wiki article |
  50. | `query <question>` | Answer from wiki, archive result |
  51. | `promote` | Elevate quality query answer to wiki article |
  52. | `research <topic>` | Gap → web search → ingest → compile loop |
  53. | `delete <source>` | Safe delete with cascade cleanup |
  54. | `lint` | Health check + graph analysis |
  55. ## Conventions
  56. - **Obsidian CLI first** for page operations (see `references/obsidian-cli-cheatsheet.md`)
  57. - **Structured diff** for updates: Current/Proposed/Reason/Source, user confirms each
  58. - **Sources traceability**: frontmatter `sources[]` links every wiki page to raw/ files
  59. - **Incremental cache**: SHA256 hash in `.cache/` skips unchanged sources
  60. ## References
  61. - `references/operations.md` — Full procedures for all 9 operations
  62. - `references/frontmatter-schemas.md` · `compilation-guide.md` · `entity-types.md` · `obsidian-cli-cheatsheet.md`
  63. - `assets/` — All templates (purpose, wiki article, raw, query, indexes, log)
  64. - `scripts/` — `init-wiki.sh` (with `--template`), `parse-media.py`
README.md · README · 279 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Karpathy Wiki — LLM 驱动的知识管理系统
  2. > 基于 [Andrej Karpathy](https://github.com/karpathy) 提出的 [LLM Wiki 模式](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) 构建的 Agent Skill,通过四阶段流水线将碎片化信息转化为结构化、可检索、持续增长的个人知识库。
  3. ## 核心理念
  4. Wiki 是一个**持久化、可复利增长的知识制品**,不是一次性问答工具。
  5. > You never write the wiki. The LLM writes everything. You just steer, and every answer compounds.
  6. ## 四阶段流水线
  7. ```
  8. ┌──────────────┐
  9. │ 1. INGEST │ 分类 + 采集 → raw/(不可变)
  10. └──────┬───────┘
  11. │
  12. v
  13. ┌──────────────┐
  14. │ 2. COMPILE │ 两步分析 → LLM 读 raw/,按实体类型写 wiki/<领域>/
  15. └──────┬───────┘
  16. │
  17. v
  18. ┌──────────────┐
  19. │ 3. QUERY │ 对 wiki 提问 → outputs/queries/,promote 优质回答到 wiki/
  20. └──────┬───────┘
  21. │
  22. v
  23. ┌──────────────┐
  24. │ 4. LINT │ 查缺补漏,修复错误,图分析,建议新文章
  25. └──────┬───────┘
  26. │
  27. └──────→ 回到 Phase 1 或触发 Deep Research
  28. ```
  29. 每个阶段结束后追加 `log.md`,每个阶段增强下一个阶段,循环持续运行。
  30. ## 特性
  31. ### 核心特性
  32. - **四阶段分离** — Ingest(采集)与 Compile(编译)解耦,可批量采集后统一编译
  33. - **先分类再提取** — Ingest 时 Classify 来源类型和实体类型,Compile 时按类型选择章节结构
  34. - **7 种实体类型** — concept · person · tool · event · comparison · pattern · overview,每种有不同的必需章节
  35. - **Token 预算 / 渐进加载** — L0-L3 四级上下文管理,先索引后全文
  36. - **Counter-Arguments** — 综合 3+ 来源的文章自动添加反论段落,防止偏见积累
  37. - **YAML Frontmatter 规范** — entity_type、confidence、跨领域 domains,支持 Obsidian Dataview 动态查询
  38. - **Obsidian CLI 优先** — 创建/移动/重命名通过 CLI 自动维护双链完整性
  39. - **三级索引** — Dashboard(总览)、Concept Index(文章目录)、Source Index(资料映射)
  40. - **查询回填 + Promote** — 查询结果先暂存,优质回答提升为正式 Wiki 文章
  41. - **结构化 Diff 更新** — 更新已有文章时逐条展示 Current/Proposed/Reason/Source
  42. - **反链审计** — 编译后自动扫描已有文章补充反向链接
  43. - **PDF/图片解析** — 基于百度 PaddleOCR 的 Layout Parsing API
  44. ### 新增特性
  45. - **purpose.md — 知识库灵魂** — 定义目标、核心问题、研究范围和演进论点,LLM 每次操作读取对齐
  46. - **场景模板** — 4 种初始化模板(通用 / 学术研究 / 读书笔记 / 项目文档),一键启动不同场景
  47. - **两步 Chain-of-Thought Compile** — 先结构化分析(实体、矛盾、关联),再生成文章,显著提升质量
  48. - **SHA256 增量缓存** — 源文件内容哈希去重,跳过未变化的资料,节省 token
  49. - **Deep Research** — 发现知识缺口 → 自动生成搜索策略 → 网络搜索 → Ingest → Compile 闭环
  50. - **纯文本图分析** — 桥接节点、孤立页面、知识集群发现、惊喜连接,无 GUI 依赖
  51. - **异步审阅队列** — LLM 标记需人工判断的条目,用户统一处理,不阻塞 Ingest
  52. - **来源可追溯** — sources[] 驱动删除级联清理、更新溯源、Query 引用链
  53. - **安全删除** — 3-method matching + 级联清理,删除源文件时自动清理所有引用链
  54. - **未 promote 查询提醒** — Lint 显式列出未处理的优质回答,建议处理方式
  55. ## Token 预算
  56. | 级别 | ~Token 量 | 何时加载 | 内容 |
  57. |------|----------|---------|------|
  58. | L0 | ~200 | 每次会话 | SKILL.md frontmatter |
  59. | L1 | ~1-2K | 会话开始 | purpose.md + Concept Index + Dashboard |
  60. | L2 | ~2-5K | 搜索/定位 | 搜索结果摘要 |
  61. | L3 | 5-20K | 深度读写 | 完整文章或原始资料 |
  62. ## 实体类型系统
  63. | 类型 | 适用场景 | 示例 |
  64. |------|---------|------|
  65. | `concept` | 抽象概念、理论、算法 | Transformer、反向传播 |
  66. | `person` | 人物、团队、组织 | Andrej Karpathy、OpenAI |
  67. | `tool` | 软件、框架、平台 | PyTorch、Obsidian |
  68. | `event` | 发布、突破、历史节点 | GPT-4 发布 |
  69. | `comparison` | 多方案对比分析 | PyTorch vs TensorFlow |
  70. | `pattern` | 方法论、流程、最佳实践 | RAG 模式 |
  71. | `overview` | 领域/子领域总览 | 大语言模型综述 |
  72. ## 目录结构
  73. ```
  74. wiki/
  75. ├── purpose.md # 知识库目标与方向(LLM 每次操作读取)
  76. ├── raw/ # 原始资料(不可变)
  77. │ └── YYYY-MM-DD_slug.md
  78. ├── wiki/
  79. │ ├── index/
  80. │ │ ├── Dashboard.md # 总览
  81. │ │ ├── Concept Index.md # 文章目录
  82. │ │ └── Source Index.md # 资料引用映射
  83. │ └── <领域>/ # Wiki 文章
  84. ├── outputs/
  85. │ ├── queries/ # 查询结果
  86. │ └── reports/ # Lint 报告
  87. ├── .cache/ # 增量缓存(已被 .gitignore 排除)
  88. ├── .gitignore # Git 排除规则
  89. ├── .env # API 配置
  90. └── log.md # 操作日志
  91. ```
  92. ## 安装
  93. ### 1. 安装 Skill
  94. 将 `karpathy-wiki/` 目录放入 Agent 的 skills 目录:
  95. ```bash
  96. # 方式一:克隆到 .agents/skills/
  97. git clone https://github.com/your-username/karpathy-wiki.git .agents/skills/karpathy-wiki
  98. # 方式二:手动复制
  99. cp -r karpathy-wiki/ .agents/skills/karpathy-wiki
  100. ```
  101. 本 Skill 遵循 [agentskills.io](https://agentskills.io) 开放规范,兼容 Claude Code、Cursor、Codex 等支持 SKILL.md 的工具。
  102. ### 2. 安装 Obsidian CLI(推荐)
  103. 1. 安装最新版 [Obsidian](https://obsidian.md)
  104. 2. 设置 → 通用 → 开启「Command line interface」
  105. 3. 注册 CLI(按提示将 Obsidian 加入 PATH)
  106. 4. 终端验证:`obsidian help`
  107. ### 3. 配置 PDF/图片解析(可选)
  108. 编辑知识库根目录下的 `.env` 文件,填入百度 PaddleOCR Layout Parsing API 的 URL 和 Token:
  109. ```env
  110. LAYOUT_API_URL=https://your-api-url
  111. LAYOUT_API_TOKEN=your-token
  112. ```
  113. 安装 Python 依赖:
  114. ```bash
  115. pip install requests
  116. ```
  117. ## 快速开始
  118. ### 初始化知识库
  119. ```bash
  120. cd ~/your-obsidian-vault
  121. # 通用知识库
  122. bash .agents/skills/karpathy-wiki/scripts/init-wiki.sh
  123. # 学术研究模板
  124. bash .agents/skills/karpathy-wiki/scripts/init-wiki.sh --template research
  125. # 读书笔记模板
  126. bash .agents/skills/karpathy-wiki/scripts/init-wiki.sh --template reading
  127. # 项目文档模板
  128. bash .agents/skills/karpathy-wiki/scripts/init-wiki.sh --template project
  129. # 指定目录 + 模板
  130. bash .agents/skills/karpathy-wiki/scripts/init-wiki.sh ~/my-wiki --template research
  131. ```
  132. ### 在 LLM Agent 中使用
  133. ```bash
  134. # 切换到 vault 目录
  135. cd ~/your-obsidian-vault
  136. # 录入资料(自动分类 + 归档 + 哈希去重)
  137. /karpathy-wiki ingest https://example.com/article
  138. # 编译文章(两步:分析 → 生成)
  139. /karpathy-wiki compile Transformer 架构
  140. # 查询知识库(自动回填优质回答)
  141. /karpathy-wiki query Transformer 和 RNN 的核心区别?
  142. # 提升查询结果为正式文章
  143. /karpathy-wiki promote
  144. # 深度研究(搜索 → Ingest → Compile 闭环)
  145. /karpathy-wiki research Mixture of Experts
  146. # 安全删除源文件(级联清理引用链)
  147. /karpathy-wiki delete raw/2026-04-01_old_article.md
  148. # 健康检查(含图分析 + 审阅提醒)
  149. /karpathy-wiki lint
  150. ```
  151. ### 资料类型支持
  152. | 输入类型 | 读取方法 | 说明 |
  153. |---------|---------|------|
  154. | URL(网页) | `webReader` / Exa crawling | 优先 webReader,失败自动 fallback |
  155. | PDF | `parse-media.py` | 百度 PaddleOCR Layout Parsing,转为 Markdown + 提取图片 |
  156. | 图片 | `parse-media.py` | 百度 PaddleOCR OCR + 图表理解 |
  157. | 本地 .md/.txt | Read 工具 | 直接读取 |
  158. | 粘贴文本 | 直接使用 | 无需额外处理 |
  159. ## 在 Obsidian 中使用
  160. 知识库就是一个标准 Obsidian vault,所有 Obsidian 功能都可用:
  161. | Obsidian 功能 | 对应知识库元素 |
  162. |--------------|---------------|
  163. | 图谱视图 | 看知识关联全貌,孤儿节点一目了然 |
  164. | 反链面板 | 打开任意文章,看谁引用了它 |
  165. | 全文搜索 | 快速定位内容 |
  166. | Dataview 插件 | 基于 frontmatter(entity_type、confidence、domains)做动态查询 |
  167. | 属性面板 | 查看/编辑 YAML frontmatter |
  168. ## 文件说明
  169. ```
  170. karpathy-wiki/
  171. ├── SKILL.md # 主技能定义(原则 + 命令参考)
  172. ├── README.md # 本文件
  173. ├── references/
  174. │ ├── operations.md # 完整操作规程(9 个 Procedure)
  175. │ ├── frontmatter-schemas.md # YAML frontmatter 规范
  176. │ ├── compilation-guide.md # 文章编译写作规范
  177. │ ├── entity-types.md # 实体类型分类系统(7 种类型)
  178. │ └── obsidian-cli-cheatsheet.md # Obsidian CLI 命令速查
  179. ├── assets/
  180. │ ├── purpose-template.md # purpose.md 通用模板
  181. │ ├── purpose-research-template.md # 学术研究场景模板
  182. │ ├── purpose-reading-template.md # 读书笔记场景模板
  183. │ ├── purpose-project-template.md # 项目文档场景模板
  184. │ ├── wiki-article-template.md # Wiki 文章模板
  185. │ ├── raw-article-template.md # 原始资料模板
  186. │ ├── query-output-template.md # 查询输出模板
  187. │ ├── dashboard-template.md # Dashboard 模板
  188. │ ├── concept-index-template.md # Concept Index 模板
  189. │ ├── source-index-template.md # Source Index 模板
  190. │ └── log-template.md # Log 模板
  191. └── scripts/
  192. ├── init-wiki.sh # 初始化脚本(含 --template 模板选择)
  193. └── parse-media.py # PDF/图片解析脚本(PaddleOCR)
  194. ```
  195. ## 设计原则
  196. 1. **raw/ 不可变** — 原始记录不编辑,来源更新时重新 ingest
  197. 2. **log.md 仅追加** — 完整变更历史,不修改历史条目
  198. 3. **purpose.md 锚定方向** — 每次操作读取,确保与知识库目标一致
  199. 4. **先分类再提取** — Ingest 时判断来源和实体类型,Compile 按类型选章节
  200. 5. **编译前分析** — 先结构化分析后生成,不盲目输出
  201. 6. **反链审计不可跳过** — 双向链接是知识图谱,单向链接是博客
  202. 7. **更新用结构化 Diff** — Current / Proposed / Reason / Source,逐条确认
  203. 8. **查询必须回填** — 好的回答是复利燃料
  204. 9. **Token 预算** — 先索引后全文,渐进加载
  205. 10. **人类验证** — LLM 是写手,用户是主编
  206. 11. **渐进式深入** — 先建立骨架,再逐步补充细节
  207. 12. **增量缓存** — 哈希去重,跳过未变化的资料
  208. 13. **来源可追溯** — sources[] 是删除、更新、溯源的基础
  209. 14. **缺口驱动研究** — 发现缺口 → 自动填补,知识库持续生长
  210. ## 致谢
  211. - [Andrej Karpathy](https://github.com/karpathy) — [LLM Wiki: Knowledge Base Pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f)
  212. - [pedronauck/skills](https://github.com/pedronauck/skills) — karpathy-kb 技能(四阶段分离、结构化 Diff、反链审计等设计的参考来源)
  213. - [bluewater8008](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f?permalink_comment_id=6079549#gistcomment-6079549) — Token 预算、实体类型分类、先分类再提取等最佳实践
  214. - [localwolfpackai](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f?permalink_comment_id=6079697#gistcomment-6079697) — Counter-Arguments 偏见检测机制
  215. - [nashsu/llm_wiki](https://github.com/nashsu/llm_wiki) — purpose.md、两步 Chain-of-Thought、增量缓存、知识图谱分析、Deep Research 等设计的灵感来源
  216. - [百度 PaddleOCR](https://github.com/PaddlePaddle/PaddleOCR) — PDF/图片 Layout Parsing
  217. ## License
  218. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.