The LLM Wiki: compiling knowledge instead of retrieving it

Last updated: ยท Reviewed quarterly

A wiki compiled by a language model inverts the usual order of a knowledge base. Instead of searching raw documents at the moment a question arrives, an agent reads each source once, folds what it learned into a page about a concept, and keeps that page current. Retrieval still happens, but over a corpus that has already been synthesized.

Three layers

The pattern comes from a short public gist by Andrej Karpathy, and it is a folder layout rather than a product. Nothing needs to be installed. It divides the work between material you never touch, pages a model writes, and a file in which you state the rules the model has to follow. It has since produced a string of follow-up write-ups and at least one desktop implementation, but the original is a page of instructions you can paste into an agent.

LayerWhat it holdsWho writes it
raw/Immutable sources. Articles, PDFs, exports, saved pages, interview notes, one file per source.Whatever captured them. Never edited afterwards, by you or by the agent.
wiki/One page per concept. Structured, cross-linked, rewritten whenever a new source changes what is true.The agent, from raw/, under your review.
AGENTS.mdThe schema. Page conventions, naming, how contradictions are resolved, what must never be recorded.You. This file decides whether the wiki is any good.

The middle layer carries the idea. A wiki page is not a summary of a document: it is a page about a concept, assembled from every source that touched it. A page called "retrieval evaluation" might be fed by nine papers read over seven months, rewritten each time one of them changed the picture. That is the difference between a folder of summaries and a knowledge base, and no amount of searching over the source folder produces it. The unit being an idea rather than a document is the same move Niklas Luhmann's slip box makes, described in Zettelkasten and evergreen notes; the difference is who does the writing.

The schema is named AGENTS.md in Karpathy's version because that is the filename several coding agents read on startup. In a Claude Code setup the same role is played by CLAUDE.md, and in a hand-rolled script it can be any file you prepend to every prompt. The name matters only in that the agent has to load it. The contents matter enormously.

What the schema file should say

A schema that says "keep the wiki up to date" produces sprawl: near-duplicate pages, summaries masquerading as concepts, and confident sentences with nothing behind them. A useful one is closer to a style guide with enforcement rules, and most working versions cover the same eight things.

  • Scope. What belongs in the wiki and what does not. Without this the agent will happily write a page about every proper noun it encounters.
  • Granularity. One page per concept, project or entity, with a rule for when to split a page that has grown two subjects and when to merge two pages that turned out to be one.
  • A page template. Typically: a one-sentence definition, current state, how it got there, open questions, related pages, sources. A fixed shape is what makes fifty pages comparable.
  • Titles that state something. A page titled "Caching" collects everything; a page titled "Cache invalidation is done on write, not on read" states a claim that can be checked and, when it stops being true, corrected.
  • Dates on everything. Every claim carries the date of the source it came from, so a reader can tell a current fact from a fact that was true in March.
  • Contradiction handling. The default should be explicit: when a new source disagrees with a page, keep both with their dates and mark which supersedes which, rather than silently overwriting. Silent overwrites destroy the history that made the wiki worth compiling.
  • Provenance. Every claim links back to a file in raw/. More on this below; it is the single rule that separates a checkable wiki from a plausible one.
  • Prohibitions. What must never be written down: credentials, personal data, anything under a confidentiality obligation. An agent with filesystem access will otherwise copy whatever it finds.

Twenty to forty lines is enough for a first version. The schema is not something you get right in advance. You write it, run one ingest, read every page it produced, and then add the rules whose absence you can now see.

The three operations

Ingest is the compile step. A new source arrives, the agent decides which concepts it touches, and it updates those pages: adding a claim, revising one that changed, creating a page for something that appeared for the first time. A good ingest prompt is a plan-then-write split. First pass: read the schema and the new source, then output the concepts it touches, marking each as new, changed or unaffected, with the sentence from the source that justifies it. Second pass: for each affected concept, read the existing page and write the revised version in full. Asking for both at once tends to produce a rewrite that quietly drops half the page it was meant to extend.

Batching helps more than it looks. Ingesting a week of material at once lets the agent notice that the same constraint appeared in three separate sources, which a strictly one-source-at-a-time ingest cannot see.

Query runs against wiki/, not against raw/. This is the part that is easy to miss: the pattern does not remove retrieval, it improves the corpus retrieval runs over. Search a folder of fifty synthesized pages, or simply load the relevant ones whole, and the model answers from material that was written to be an answer. Keep a path back to raw/ for the cases where the page is not enough.

Lint is the operation people skip and the one that keeps the wiki from rotting. A lint pass walks the whole tree looking for duplicate or near-duplicate pages, contradictions between pages, claims with no source link, pages nothing links to, and stale material whose date has passed the point where it should have been rechecked. Monthly is usually enough. Treat the output as a report you read, not as edits you accept unseen; a lint that silently rewrites pages is a second compiler with no supervision.

Compiling ahead versus retrieving at query time

Retrieval-augmented generation embeds your documents into a vector store and, when a question arrives, fetches the most similar chunks and hands them to the model. It is well understood, cheap to stand up, and covered in detail in local RAG. A compiled wiki does the same synthesis work, but earlier, and stores the result. The two are not competitors so much as two places to spend the same effort.

RAGCompiled wiki
When the work happensAt query time, every timeAt ingest time, once per source
Corpus searchedRaw documents, with their noise and repetitionSynthesized pages, one concept each
Cost shapeCheap to build, small cost per queryExpensive per ingest, cheap per query
New materialAvailable as soon as it is embeddedAvailable only after the next ingest run
Change over timeReturns chunks; cannot tell you a position was reversedThe page holds the history and the supersession
AccretionNone. Every query starts from the same corpusEach ingest improves the corpus for the next question
InspectabilityAn embedding store you cannot read directlyMarkdown files you can open, diff and correct by hand
Characteristic errorFetches the wrong passage; visible, transient, you retryWrites a wrong claim; durable, invisible, read as fact
Strongest atLarge corpora, exact recall, questions you did not anticipateRecurring questions, synthesis across sources, tracking how a subject moved
Weakest atAnything requiring a view assembled from many documentsNeedles: the aside in one document that no page thought worth keeping

Read the last two rows together and the division of labour is clear enough. If your questions are mostly "where was that mentioned", compilation is expensive overhead over a search index. If they are mostly "what do we currently think about X, and how did we get here", retrieval over raw material will keep handing you fragments to reassemble by hand, at every asking. Most working setups end up hybrid: the wiki as the default corpus, raw search as the fallback when a page cannot answer.

Provenance, and why it is the load-bearing rule

A compiled page is an assertion by a model about material you may not remember. What makes it trustworthy is being able to get back to that material in one step. Three conventions do this well enough, and any of them beats none.

  • Inline references. Each claim ends with a link to the source file and a locator: [raw/2026-03-11-postmortem.md#rollback]. Verbose, and the most useful when you are actually checking something.
  • A sources block per page. Every page ends with the list of raw files it was built from, in date order. Cheaper to maintain, coarser to verify against.
  • Front matter. A machine-readable list of source files and the date of the last ingest, which is what a lint script reads to find pages whose sources have changed.

The rule that gives these teeth belongs in the schema: the agent may not write a sentence it cannot attribute to a file in raw/. Anything it wants to add from its own general knowledge goes in a clearly marked section, or nowhere. Without that line, a compiled wiki gradually fills with reasonable-sounding material that no source ever said, and there is no way to tell which sentences those are.

A worked example: forty documents into a small wiki

  1. Freeze the raw layer. Convert everything to text or Markdown, one file per source, and name each file with its date and subject. Put it in raw/ and never edit it again. If a source is wrong, that is a fact about the source, and the wiki page is where it gets corrected.
  2. Write twenty lines of schema. Scope, the page template, the naming rule, the date rule, the provenance rule, the prohibitions. Resist writing more than that before you have seen output.
  3. Ingest five sources, chosen to overlap. Pick sources that discuss the same two or three subjects, because overlap is what exercises the merge and contradiction rules. Run the plan pass, read the plan, then run the write pass.
  4. Read every page it produced, end to end. This is the actual work of adopting the pattern, and it is not optional. You are looking for pages that are summaries rather than concepts, claims with no source, invented connective tissue, and the shape of page you wanted but did not get.
  5. Rewrite the schema from what went wrong. Each defect becomes a rule. Then delete wiki/ and re-ingest the same five sources: cheap at this size, and it tells you whether the rule worked.
  6. Ingest the rest in batches, then lint. Five to ten sources per run. When the whole set is in, run the lint pass and read its report before accepting anything. Expect duplicates that only appear once the corpus is large enough for two names for one idea to both exist.

The honest limits

Compilation costs tokens on every ingest, and the cost grows with the wiki, since updating a page means reading it first. Embedding a corpus is a one-off expense measured in fractions of a cent per document; compiling one is a full model pass per source plus a pass per affected page, repeated every time you add material. For a personal knowledge base this is affordable, particularly against a local model, and local-first AI at work covers what running it on-device involves. For a corpus of hundreds of thousands of documents it is the reason the pattern is not simply better than RAG.

The second limit is worse, because it is silent. A retrieval error is transient and visible: you see the wrong passage and ask again. A compilation error is durable and invisible. If the agent misreads a source and writes a confident wrong sentence into a page, that sentence is what you read next month, what the next ingest builds on, and what every query returns. The format launders it, too, since it now sits in a clean reference page rather than in an ambiguous paragraph of an original document.

The lint step is the only thing standing between you and a confidently wrong knowledge base, and it is worth being clear about how weak a guarantee that is. Lint is usually run by the same model that produced the error, so a claim it found plausible on ingest it will find plausible on review. What makes lint more than theatre is checking against raw/ rather than only for internal consistency: pull the source file a claim cites and ask whether it supports the sentence. That is a real check, it is expensive, and it is why the provenance rule exists. Sample rather than sweep if the cost is prohibitive, but sample against sources.

Third, the wiki records what the agent judged worth keeping. Everything else in raw/ is still there, but out of the path of your questions unless you go looking. Keeping the raw layer complete and searchable is what makes that recoverable rather than lossy, and a large part of why the pattern insists the raw layer be immutable.

Where the pattern sits

The compiled wiki is one answer to a question other systems answer differently. The manual answer is a note-writing practice, where you do the synthesis yourself and the value is largely in having done it. The middle ground, where a model suggests links, tags and summaries inside a vault you still own, is in AI-enhanced PKM and agent memory, which also covers how this same three-layer split reappears as an architecture for agent memory: wiki/ as semantic memory, the schema as procedural memory, the raw log as episodic.

The pattern pays off most in any setting that generates source material continuously without anyone choosing to write it: research reading, support tickets, a project's documents, or the record of what was said in meetings, which is the subject of from meeting to knowledge base. The raw layer accumulates whether or not anyone maintains it, and compilation is what turns accumulation into something you can consult.

Sources