This skill should be used when working with a project knowledge base that follows the Karpathy LLM Wiki pattern. It provides workflows for ingesting source documents, querying the KB, running health checks (lint), capturing design decisions and lessons learned, and initializing a new KB in a project. Trigger when the user mentions the KB, asks to ingest a source, run a query against the wiki, capture learnings, or set up a knowledge base.
A methodology for LLM-maintained knowledge bases based on Andrej Karpathy's LLM Wiki pattern. LLMs maintain the wiki; humans curate sources and ask questions.
Schema reference: Load references/schema.md for page format, link conventions, directory structure, and log format details.
New project assets: assets/schema.md is a template — copy to kb/schema.md with project name and categories substituted when initializing.
Before running Ingest, Query, Lint, Map, or Capture — check whether kb/wiki/index.md exists. If it does not, stop and tell the user:
"這個專案還沒有 KB。先執行
/kb-wiki init初始化。"
Do not attempt to proceed with the operation.
To initialize a KB when a project has none:
CLAUDE.md, README.md, package.json, or any obvious top-level files. Based on what the project is, propose a category structure that fits. For example:
concepts, api, integrations, patterns, lessonsconcepts, data-sources, transforms, infrastructure, lessonsconcepts, integrations, competitors, patterns, lessons
Present the proposed categories with a one-line rationale for each, then ask: "這樣的分類結構合適嗎?有要調整的嗎?"
Wait for confirmation. Adjust if the user requests changes; proceed with proposed categories if they say nothing.mkdir -p kb/raw/sources kb/raw/assets kb/wiki/{category1} kb/wiki/{category2} ...
Expand the confirmed category list into the command before running.assets/schema.md from this skill to kb/schema.md. Replace:
{{PROJECT_NAME}} → actual project namekb/wiki/index.md:
# {Project} Wiki — Index
> Auto-maintained. Last updated: YYYY-MM-DD
---
**Total: 0 pages**
kb/wiki/log.md:
# {Project} Wiki — Log
> Append-only chronological record. Newest entries at top.
---
CLAUDE.md, AGENTS.mdCLAUDE.md## Knowledge Base heading (idempotent):
## Knowledge Base
This project maintains a knowledge base under `kb/`. Conventions, page format, and workflows (ingest / query / lint / map / capture) are defined in `kb/schema.md`. Read it before any KB operation.
kb/raw/sources/ and run /kb-wiki ingest.To ingest a source from kb/raw/sources/:
kb/wiki/index.md to understand existing wiki content and discover what categories existstatus: seedling.kb/wiki/index.md: add new pages, update one-line summaries if changedkb/wiki/log.md:
## [YYYY-MM-DD] ingest | Processed N source(s)
- Sources: filename(s)
- Pages created: [[page1]]
- Pages updated: [[page2]]
- Key findings: (1) finding one; (2) finding two
Never modify files under kb/raw/.
To answer a question using KB content:
kb/wiki/index.md to identify relevant pages→ [[patterns/error-triage]])kb/wiki/log.md:
## [YYYY-MM-DD] query | {question summary}
- Pages consulted: [[page1]], [[page2]]
- Pages created/updated: [[page]] (if filed back)
Use the Bash tool to run the script directly (deterministic, no extra tokens):
bun ~/.claude/skills/kb-wiki/scripts/lint.ts # structural checks
bun ~/.claude/skills/kb-wiki/scripts/lint.ts --deep # + LLM content analysis
If Bun is unavailable (command not found), fall back to doing it manually:
kb/wiki/[[page]] references that don't have a corresponding filekb/wiki/log.md:
## [YYYY-MM-DD] lint | Health check: N errors, N warnings, N info
- Mode: structural
- Pages scanned: N
- Issues found: N
Use the Bash tool to run the script directly (deterministic, no extra tokens):
bun ~/.claude/skills/kb-wiki/scripts/map.ts # rebuild index + MOCs
bun ~/.claude/skills/kb-wiki/scripts/map.ts --deep # + LLM cross-link discovery
If Bun is unavailable (command not found), fall back to doing it manually:
kb/wiki/ (excluding log.md, _moc.md files, and summaries/)kb/wiki/index.md:
# {Project} Wiki — Index
> Auto-maintained by `kb:map`. Last updated: YYYY-MM-DD
---
## {Category} (N)
- [[category/page-name]] — one-line summary
...
---
**Total: N pages**
Sort pages alphabetically within each category. Write accurate one-line summaries by reading each page — do not copy old summaries blindly.kb/wiki/{category}/_moc.md:
# {Category} — Map of Content
> Auto-maintained by `kb:map`. Last updated: YYYY-MM-DD
## [[category/page|Title]]
Summary paragraph.
Tags: `tag1`, `tag2`
Links to: [[other-page]]
kb/wiki/log.md:
## [YYYY-MM-DD] map | Rebuilt index + N MOCs
- Pages indexed: N
- Total links: N
- Orphan pages: N
To capture learnings at the end of a significant implementation block:
lessons/design-decisions.md if present, otherwise the closest equivalentlessons/ if the topic is distinctpatterns/ or equivalent categorykb/wiki/index.md and append to kb/wiki/log.mdDo not capture: implementation progress, code already in the codebase, ephemeral state.
kb/raw/ — it is immutable source materialindex.md and log.md after any wiki change