An LLM wiki is Andrej Karpathy's pattern for a knowledge base an AI maintains: raw sources sit in one folder, an LLM agent such as Claude Code compiles them into linked markdown pages, and a schema file sets the rules. Answers come from the compiled pages instead of from re-reading every raw document on every question.
Can I use LLM wiki with Claude Code?
Yes, and Claude Code is one of the most natural fits. The pattern needs an agent that can read a folder of sources and write markdown pages, and Claude Code does both. Put the sources in raw/, the pages in wiki/, and the rules in a CLAUDE.md at the root, then ask it to ingest, query and lint.
Karpathy published the pattern as an idea file on GitHub in April 2026, written to be pasted into whatever agent you use. It has three layers: raw sources you never edit, the wiki the model writes and owns, and the schema that tells the model how the wiki works. Here is the build in Claude Code.
Step 1: Make the folder
Create a folder with two subfolders, raw and wiki. Drop your first sources into raw/ as they are: articles saved as markdown, PDFs, transcripts, exported docs. The raw layer is the evidence; nothing in it is ever rewritten, so you can always check a wiki page against where it came from.
Step 2: Put it under git
Run git init and commit. One ingest can touch a dozen pages, and git turns that into a diff you can read and undo. This is what makes it safe to let a model own the wiki.
Step 3: Write the schema as CLAUDE.md
Claude Code reads CLAUDE.md at the root of the folder at the start of every session, so that is where the schema goes. (Other agents read AGENTS.md; same content.) A starting version:
# LLM wiki: instructions for Claude Code
raw/ holds the sources. Never edit or delete anything in raw/.
wiki/ is yours to maintain: one topic per page, plain markdown.
## Every wiki page
- Opens with a one-line summary.
- Names the raw/ file behind each claim.
- Links related pages with [[wikilinks]].
## wiki/index.md
Every page, grouped by category, one line each. Update it on every ingest.
## wiki/log.md
One line per ingest, query or lint: date, operation, pages touched.
Append only; never rewrite an old line.
## Operations
- Ingest: read the new source, update every page it affects, add pages it needs.
- Query: answer from wiki/ first, cite the pages, say "not in the wiki" when it is missing.
- Lint: list contradictions, stale claims, orphan pages and missing links. Fix only what I approve.
The two special files do real work. index.md is how the model finds pages without a search engine: it reads the catalog, then opens what is relevant. log.md is the history, so the model (and you) can see what changed when.
Step 4: Ingest
Open Claude Code in the folder and ask: "Ingest raw/[file]. Update every wiki page it affects, create the pages it needs, update the index and log." The first few ingests create most of the pages. Later ones mostly revise: a new source that contradicts an old one should change the page, not sit next to it.
Step 5: Query, and file good answers back
Ask questions the way you would ask a colleague who has read everything: "What do the sources say about [topic], and where do they disagree?" When an answer is worth keeping, tell Claude Code to save it as a wiki page. That is how the wiki compounds: questions become knowledge instead of disappearing into chat history.
Step 6: Lint on a schedule
Once a week, ask for a lint pass: contradictions between pages, claims a newer source has overtaken, pages nothing links to, and topics mentioned everywhere but missing their own page. Review the list, approve the fixes, commit. Skipping lint is how a wiki drifts back into a pile of notes.
