Concept
Karpathy LLM Wiki: Build a Source-Backed AI Knowledge Base
The Karpathy LLM Wiki pattern turns trusted sources into maintained AI knowledge-base pages that agents can load on demand.
Article packet
Concepts
People designing a maintained knowledge layer for Claude Code, Codex, Cursor, and other AI agents
12 min read
01
The Karpathy LLM Wiki pattern maintains useful answers instead of treating raw notes, retrieved chunks, or chat logs as finished knowledge.
02
The architecture separates source material, atomic memory, maintained pages, and the index that loads only relevant context.
03
A practical loop needs observable checks and repairs for stale links, contradictions, context bloat, and human edits.
01
The Karpathy LLM Wiki pattern
Andrej Karpathy described an LLM Wiki pattern for turning raw knowledge into curated, interconnected pages that an AI agent can load on demand. This article uses his public note as a maintained source for the pattern; it does not imply that Karpathy endorses Wenlan.
In practical terms, an LLM wiki is a maintained AI knowledge base. It turns source material and durable work context into topic pages with enough provenance and maintenance state for a person to inspect why the current answer exists.
It is not simply a folder of AI-written notes. A useful LLM wiki separates raw evidence from reusable facts and maintained explanations, then gives each layer a different update rule. The result should remain useful even when the reader never installs the product used to build it.
- Sources preserve documents, conversations, files, and other inspectable evidence.
- Atomic memories preserve one decision, lesson, correction, preference, or fact learned during work.
- Maintained pages compile the current answer and cite the support behind it.
- A routing index finds the relevant page without loading the entire wiki into every prompt.
02
The architecture behind a useful LLM wiki
The smallest dependable design has four planes: source storage, durable memory, maintained pages, and selective retrieval. Keeping them separate prevents a polished page from losing its evidence and prevents a raw event log from masquerading as the current answer.
Maintenance is part of the architecture, not a later cleanup job. When support changes, the system needs to mark the affected page stale, propose or perform a refresh according to ownership, and keep the revision inspectable.
- Ingest: register source material without rewriting it into a conclusion.
- Capture: keep one complete, reusable idea with scope and provenance.
- Distill: compose related support into a maintained topic page.
- Retrieve: load the smallest useful page or memory set for the current task.
- Refresh and review: expose stale reasons, contradictions, citations, and revisions.
03
The five-minute LLM-wiki protocol
Start only after Wenlan is installed and connected to the AI client. Use one harmless topic first. The protocol below exercises session startup, targeted retrieval, one durable write, a session boundary, page distillation, and human-readable output.
The commands are separate on purpose: recall should not silently write, capture should not rewrite a whole page, and distillation should not overwrite human-owned content without a review path.
Five-minute protocol
/brief <topic>
/recall <question>
/capture <decision + why>
/handoff
/distill <topic>
/pages <topic>04
A minimum LLM-wiki starter schema
Keep the always-loaded contract small. A CLAUDE.md or AGENTS.md should describe what the wiki is for, what never changes silently, and which procedures the agent should load on demand. It should not contain the whole wiki or a long copy of every maintenance instruction.
This is a vendor-neutral information and maintenance contract, not a required folder layout or product database. Adapt the names to your tools while keeping every boundary observable.
- Purpose and scope: which decisions or questions belong in this wiki, and which do not.
- Immutable source boundary: where raw evidence lives and which files automation must never rewrite.
- Page ownership: which pages are machine-maintained, human-owned, or changed only through review.
- Naming and linking rules: stable topics, aliases, page links, and the smallest routing index.
- Citation requirement: important claims point back to an inspectable source.
- Ingest, query, lint, and maintenance log: separate on-demand procedures plus an append-only record of changes.
- Stale and review behavior: what happens when a source changes, support conflicts, or a person owns the prose.
Compact client contract
# LLM Wiki
Purpose: <the repeated decisions this wiki maintains>
Sources: <immutable evidence locations>
Pages: <ownership, naming, links, citations>
Index: <small topic router; load pages on demand>
Procedures: ingest | query | lint | review
Log: <append-only maintenance record>
Stale rule: <source change -> stale or review>05
A small acceptance test before real use
A template is not proven when the files merely exist. Test one harmless topic end to end, including a source change, before importing private or business-critical material.
This test works for a folder-and-prompts setup, an Obsidian workflow, or a dedicated LLM-wiki product. The expected result is evidence you can inspect, not just a fluent answer.
- Ingest one harmless source and confirm the original remains unchanged.
- Answer one question and cite the source for the important claim.
- Run lint and confirm missing citations, broken links, or duplicates are visible.
- Change the source, then repeat the same question.
- Confirm the old answer becomes stale or reviewable instead of being silently overwritten.
06
How to verify the loop
Do not stop at a successful command. Verify the artifacts and the next retrieval. A trustworthy setup proves that the agent can recover the intended context later and that a person can inspect the maintained result outside the chat.
If any check fails, keep the test capture harmless, diagnose the connection or source boundary, and repeat the same topic before adding real project knowledge.
- The capture returns or exposes a durable record you can find again with the same topic.
- The handoff records what changed and what the next session should do.
- The page opens as readable Markdown and shows source IDs or citations for important claims.
- A later recall or brief loads the relevant page or memory without pasting the full archive.
- A changed source produces an inspectable stale reason, refresh, or reviewable revision instead of a silent overwrite.
07
Example: from source to maintained answer
Suppose a release document establishes which platforms are actually supported. The source document remains inspectable, an atomic memory preserves the release decision and why it matters, and a maintained page compiles the current install answer. When the release document changes, the page should become stale or receive a reviewable revision.
This evidence trail is more useful than a detached summary because each layer has a clear owner and failure mode.
Expected evidence trail
source document
-> atomic memory: decision + why + source_id
-> maintained page: current answer + citations
source changes
-> stale reason or reviewable revision
-> refreshed page08
Failure modes and repairs
The hard part is not generating the first page. It is keeping the wiki small enough to retrieve, current enough to trust, and explicit enough that people can repair it.
These failure modes repeat across real LLM-wiki, Obsidian, Claude Code, and agent-memory workflows:
- Context bloat or index truncation: keep the routing index short and load topic pages on demand instead of injecting the full vault.
- Stale links and contradictions: retain provenance, mark affected pages stale, and review replacements rather than stacking another answer beside the old one.
- Human-authored pages overwritten by automation: keep machine refreshes reviewable when a person owns the prose.
- Token-heavy full-vault loading: retrieve the smallest relevant pages, memories, and source excerpts for the current question.
- Cross-session blank starts: pair a compact brief with a handoff instead of depending on the previous chat window.
09
LLM wiki vs RAG, Obsidian, and agent memory
These tools can work together, but they do not own the same layer. The useful question is not which label wins; it is where evidence, current answers, human writing, and cross-session context should live.
- RAG retrieves source chunks for a question. An LLM wiki maintains a reusable answer, its support, and its refresh state.
- Obsidian is a human-owned vault and writing surface. It can host or inspect wiki pages, but vault access alone does not define agent-memory policy or page maintenance.
- Agent memory preserves reusable context from work. An LLM wiki composes selected memories and sources into a maintained explanation.
- A plain folder plus prompts can be enough for a small, stable corpus. Add a daemon or MCP layer when several agents need the same retrieval, handoff, provenance, and review rules.
10
What an LLM wiki does not replace
An LLM wiki does not replace codebase search, repository maps, current source code, test output, or the native documentation for a tool. Those surfaces remain authoritative for what the software does now.
It is also unnecessary for one-off chats or a small set of stable documents that people already maintain well. Use the wiki when repeated work needs a current, inspectable answer across sessions or tools.
11
How Wenlan maps the architecture
Wenlan implements the pattern with three durable roles: Sources preserve inspectable material, Memories preserve atomic knowledge from work, and Pages compile maintained explanations. The local daemon owns retrieval while readable Markdown keeps pages and session artifacts visible.
The page lifecycle is explicit: distill support, cite it, track dependencies, refresh when needed, and review ownership-sensitive changes. That is the difference between a generated note and a maintained LLM wiki.
Wenlan does not require a user-authored Page schema. Typed Memory fields and built-in Page rules already govern provenance, citations, refresh, ownership, and review; the starter schema above remains a portable evaluation contract for the client and workflow.
Turn memory into an LLM wiki
Wenlan distills repeated captures into source-backed wiki pages your next AI session can actually use.
FAQ