Skip to content

Instantly share code, notes, and snippets.

@karpathy
Created April 4, 2026 16:25
Show Gist options
  • Select an option

  • Save karpathy/442a6bf555914893e9891c11519de94f to your computer and use it in GitHub Desktop.

Select an option

Save karpathy/442a6bf555914893e9891c11519de94f to your computer and use it in GitHub Desktop.
llm-wiki

LLM Wiki

A pattern for building personal knowledge bases using LLMs.

This is an idea file, it is designed to be copy pasted to your own LLM Agent (e.g. OpenAI Codex, Claude Code, OpenCode / Pi, or etc.). Its goal is to communicate the high level idea, but your agent will build out the specifics in collaboration with you.

The core idea

Most people's experience with LLMs and documents looks like RAG: you upload a collection of files, the LLM retrieves relevant chunks at query time, and generates an answer. This works, but the LLM is rediscovering knowledge from scratch on every question. There's no accumulation. Ask a subtle question that requires synthesizing five documents, and the LLM has to find and piece together the relevant fragments every time. Nothing is built up. NotebookLM, ChatGPT file uploads, and most RAG systems work this way.

The idea here is different. Instead of just retrieving from raw documents at query time, the LLM incrementally builds and maintains a persistent wiki — a structured, interlinked collection of markdown files that sits between you and the raw sources. When you add a new source, the LLM doesn't just index it for later retrieval. It reads it, extracts the key information, and integrates it into the existing wiki — updating entity pages, revising topic summaries, noting where new data contradicts old claims, strengthening or challenging the evolving synthesis. The knowledge is compiled once and then kept current, not re-derived on every query.

This is the key difference: the wiki is a persistent, compounding artifact. The cross-references are already there. The contradictions have already been flagged. The synthesis already reflects everything you've read. The wiki keeps getting richer with every source you add and every question you ask.

You never (or rarely) write the wiki yourself — the LLM writes and maintains all of it. You're in charge of sourcing, exploration, and asking the right questions. The LLM does all the grunt work — the summarizing, cross-referencing, filing, and bookkeeping that makes a knowledge base actually useful over time. In practice, I have the LLM agent open on one side and Obsidian open on the other. The LLM makes edits based on our conversation, and I browse the results in real time — following links, checking the graph view, reading the updated pages. Obsidian is the IDE; the LLM is the programmer; the wiki is the codebase.

This can apply to a lot of different contexts. A few examples:

  • Personal: tracking your own goals, health, psychology, self-improvement — filing journal entries, articles, podcast notes, and building up a structured picture of yourself over time.
  • Research: going deep on a topic over weeks or months — reading papers, articles, reports, and incrementally building a comprehensive wiki with an evolving thesis.
  • Reading a book: filing each chapter as you go, building out pages for characters, themes, plot threads, and how they connect. By the end you have a rich companion wiki. Think of fan wikis like Tolkien Gateway — thousands of interlinked pages covering characters, places, events, languages, built by a community of volunteers over years. You could build something like that personally as you read, with the LLM doing all the cross-referencing and maintenance.
  • Business/team: an internal wiki maintained by LLMs, fed by Slack threads, meeting transcripts, project documents, customer calls. Possibly with humans in the loop reviewing updates. The wiki stays current because the LLM does the maintenance that no one on the team wants to do.
  • Competitive analysis, due diligence, trip planning, course notes, hobby deep-dives — anything where you're accumulating knowledge over time and want it organized rather than scattered.

Architecture

There are three layers:

Raw sources — your curated collection of source documents. Articles, papers, images, data files. These are immutable — the LLM reads from them but never modifies them. This is your source of truth.

The wiki — a directory of LLM-generated markdown files. Summaries, entity pages, concept pages, comparisons, an overview, a synthesis. The LLM owns this layer entirely. It creates pages, updates them when new sources arrive, maintains cross-references, and keeps everything consistent. You read it; the LLM writes it.

The schema — a document (e.g. CLAUDE.md for Claude Code or AGENTS.md for Codex) that tells the LLM how the wiki is structured, what the conventions are, and what workflows to follow when ingesting sources, answering questions, or maintaining the wiki. This is the key configuration file — it's what makes the LLM a disciplined wiki maintainer rather than a generic chatbot. You and the LLM co-evolve this over time as you figure out what works for your domain.

Operations

Ingest. You drop a new source into the raw collection and tell the LLM to process it. An example flow: the LLM reads the source, discusses key takeaways with you, writes a summary page in the wiki, updates the index, updates relevant entity and concept pages across the wiki, and appends an entry to the log. A single source might touch 10-15 wiki pages. Personally I prefer to ingest sources one at a time and stay involved — I read the summaries, check the updates, and guide the LLM on what to emphasize. But you could also batch-ingest many sources at once with less supervision. It's up to you to develop the workflow that fits your style and document it in the schema for future sessions.

Query. You ask questions against the wiki. The LLM searches for relevant pages, reads them, and synthesizes an answer with citations. Answers can take different forms depending on the question — a markdown page, a comparison table, a slide deck (Marp), a chart (matplotlib), a canvas. The important insight: good answers can be filed back into the wiki as new pages. A comparison you asked for, an analysis, a connection you discovered — these are valuable and shouldn't disappear into chat history. This way your explorations compound in the knowledge base just like ingested sources do.

Lint. Periodically, ask the LLM to health-check the wiki. Look for: contradictions between pages, stale claims that newer sources have superseded, orphan pages with no inbound links, important concepts mentioned but lacking their own page, missing cross-references, data gaps that could be filled with a web search. The LLM is good at suggesting new questions to investigate and new sources to look for. This keeps the wiki healthy as it grows.

Indexing and logging

Two special files help the LLM (and you) navigate the wiki as it grows. They serve different purposes:

index.md is content-oriented. It's a catalog of everything in the wiki — each page listed with a link, a one-line summary, and optionally metadata like date or source count. Organized by category (entities, concepts, sources, etc.). The LLM updates it on every ingest. When answering a query, the LLM reads the index first to find relevant pages, then drills into them. This works surprisingly well at moderate scale (~100 sources, ~hundreds of pages) and avoids the need for embedding-based RAG infrastructure.

log.md is chronological. It's an append-only record of what happened and when — ingests, queries, lint passes. A useful tip: if each entry starts with a consistent prefix (e.g. ## [2026-04-02] ingest | Article Title), the log becomes parseable with simple unix tools — grep "^## \[" log.md | tail -5 gives you the last 5 entries. The log gives you a timeline of the wiki's evolution and helps the LLM understand what's been done recently.

Optional: CLI tools

At some point you may want to build small tools that help the LLM operate on the wiki more efficiently. A search engine over the wiki pages is the most obvious one — at small scale the index file is enough, but as the wiki grows you want proper search. qmd is a good option: it's a local search engine for markdown files with hybrid BM25/vector search and LLM re-ranking, all on-device. It has both a CLI (so the LLM can shell out to it) and an MCP server (so the LLM can use it as a native tool). You could also build something simpler yourself — the LLM can help you vibe-code a naive search script as the need arises.

Tips and tricks

  • Obsidian Web Clipper is a browser extension that converts web articles to markdown. Very useful for quickly getting sources into your raw collection.
  • Download images locally. In Obsidian Settings → Files and links, set "Attachment folder path" to a fixed directory (e.g. raw/assets/). Then in Settings → Hotkeys, search for "Download" to find "Download attachments for current file" and bind it to a hotkey (e.g. Ctrl+Shift+D). After clipping an article, hit the hotkey and all images get downloaded to local disk. This is optional but useful — it lets the LLM view and reference images directly instead of relying on URLs that may break. Note that LLMs can't natively read markdown with inline images in one pass — the workaround is to have the LLM read the text first, then view some or all of the referenced images separately to gain additional context. It's a bit clunky but works well enough.
  • Obsidian's graph view is the best way to see the shape of your wiki — what's connected to what, which pages are hubs, which are orphans.
  • Marp is a markdown-based slide deck format. Obsidian has a plugin for it. Useful for generating presentations directly from wiki content.
  • Dataview is an Obsidian plugin that runs queries over page frontmatter. If your LLM adds YAML frontmatter to wiki pages (tags, dates, source counts), Dataview can generate dynamic tables and lists.
  • The wiki is just a git repo of markdown files. You get version history, branching, and collaboration for free.

Why this works

The tedious part of maintaining a knowledge base is not the reading or the thinking — it's the bookkeeping. Updating cross-references, keeping summaries current, noting when new data contradicts old claims, maintaining consistency across dozens of pages. Humans abandon wikis because the maintenance burden grows faster than the value. LLMs don't get bored, don't forget to update a cross-reference, and can touch 15 files in one pass. The wiki stays maintained because the cost of maintenance is near zero.

The human's job is to curate sources, direct the analysis, ask good questions, and think about what it all means. The LLM's job is everything else.

The idea is related in spirit to Vannevar Bush's Memex (1945) — a personal, curated knowledge store with associative trails between documents. Bush's vision was closer to this than to what the web became: private, actively curated, with the connections between documents as valuable as the documents themselves. The part he couldn't solve was who does the maintenance. The LLM handles that.

Note

This document is intentionally abstract. It describes the idea, not a specific implementation. The exact directory structure, the schema conventions, the page formats, the tooling — all of that will depend on your domain, your preferences, and your LLM of choice. Everything mentioned above is optional and modular — pick what's useful, ignore what isn't. For example: your sources might be text-only, so you don't need image handling at all. Your wiki might be small enough that the index file is all you need, no search engine required. You might not care about slide decks and just want markdown pages. You might want a completely different set of output formats. The right way to use this is to share it with your LLM agent and work together to instantiate a version that fits your needs. The document's only job is to communicate the pattern. Your LLM can figure out the rest.

@XBlueSky

XBlueSky commented Jul 7, 2026

Copy link
Copy Markdown

This idea really resonated with me.

While using Claude Code, I ran into a similar problem: conversations are valuable, but most of the content is not worth keeping forever.

Simply storing every conversation quickly becomes noisy:

  • temporary debugging attempts
  • abandoned approaches
  • outdated assumptions

I ended up building a workflow around this idea: instead of automatically turning conversations into memory, Claude and the user collaboratively distill important knowledge into a curated Markdown knowledge base.

The knowledge stays human-readable, versionable, and can be explored through Obsidian.

I called it Cortexes:
https://cortexes.pages.dev/

The interesting question for me is not "how do we store more memory?", but "how do we maintain high-quality knowledge over time?"

@TLiu2014

TLiu2014 commented Jul 7, 2026

Copy link
Copy Markdown

LLM is like CPU and docs/files are like disk. This LLM Wiki is exactly the memory!

@mas213

mas213 commented Jul 7, 2026

Copy link
Copy Markdown

Love it. a little late to the party but was headsdown to built something similar.

Applied this pattern to a different domain: behavioral verification of code changes.

The overlap is direct. Same three layers:

Raw sources = PRs, specs, test cases, production incidents (immutable, never modified)
Wiki = a behavioral knowledge graph. Not how the code is structured, how the system is supposed to behave. Concern pages, flow maps, state transitions, cross-references between what the spec promises and what the tests cover.
Schema = a concern taxonomy (auth flows, data integrity, state transitions, error propagation, integration contracts, observability) that tells the system what to look for when a PR comes in.

Same three operations:

Ingest = parse a PR with tree-sitter, extract behavioral changes, update the graph. A single PR might touch 5-10 concern pages.
Query = "what concerns does this change touch? what can break from a user's perspective?"
Lint = verify the PR against the behavioral graph before merge. Flag drift between what the system promises and what the code actually does.

The compounding effect is the same. Every PR that flows through makes the graph richer. Every production incident that gets filed teaches it a new failure mode. The graph gets better at catching the next thing because it's seen the last hundred things.

The Lint section of your gist describes exactly what's missing from QA tooling. Most test generation tools produce more scripts without understanding what the system is supposed to do. This is the other direction: build the knowledge first, then verify against it.

Open sourced as an MCP server (Claude Code, Cursor, Codex): https://github.com/OrangeproAI/orangepro-mcp

No API key, no cloud, runs locally. Curious if you've thought about this pattern applied to code specifically.

opro-karpathy-parallel

@LiyuanW21

Copy link
Copy Markdown

Thanks for sharing this — your llm-wiki idea inspired me to package the workflow into a reusable Obsidian + agent skill:

https://github.com/LiyuanW21/obsidian-wiki-system

It supports Codex/OpenCode-style agents, bilingual vault templates, and natural-language install prompts so non-technical users can try the “LLM-maintained personal wiki” pattern more easily.

I credited your gist in the README. Thanks again for the inspiration!

@phoebe22222

Copy link
Copy Markdown

This maps almost 1:1 to a system we have been running in production for ~6 months to manage infrastructure/ops knowledge. A few notes from actually living with the pattern at ~4000+ interlinked concepts:

  • The schema file is everything. Our CLAUDE.md is exactly the "disciplined maintainer vs. generic chatbot" config you describe — it encodes the ingest/query/lint workflows + naming conventions, and it co-evolved into the single most important file in the repo.
  • index.md at scale: the flat index works great to a few hundred pages. Past that we added hybrid search (SQLite FTS5 + on-device embeddings, reciprocal-rank-fused) rather than standing up embedding-RAG infra — same spirit as qmd. We expose it as both a CLI (agent shells out) and an MCP server (native tool). ~1ms keyword, ~350ms hybrid.
  • New page vs. edit (@alinawab): heuristic that works for us — new page when it is a distinct entity/concept you would link to from elsewhere; edit in place when it is an attribute/update of an existing one. The agent gets this right ~90% of the time once the schema enumerates the page types.
  • Team sharing (@geetansharora): the wiki is just a private git repo, auto-synced. Teammates browse in Obsidian or hit the same MCP server. Git history doubles as the log.md audit trail for free.
  • Biggest failure mode (@alinawab): drift — the agent under-updating cross-references on ingest, so pages silently go stale. The lint pass is not optional; we run it on a timer (orphan detection + contradiction flagging + stale-claim checks) and that is what keeps the graph healthy.

The "compounding artifact" framing is exactly right — after a few thousand concepts the wiki answers questions the raw sources never could, because the synthesis already happened. Thanks for writing it up so cleanly.

@distorx — of everyone here your setup maps closest to mine (team-scale, production, git-backed), so I'd value your take; anyone else who's hit this, welcome too.

Mine is packaged as an agent skill, not a personal wiki: the knowledge lives alongside a SKILL.md — the schema/entry file agents load — as a git repo of markdown. Same three layers you'd recognize: an immutable source-of-truth layer (~30 metadata snapshots auto-pulled from our data platform), an LLM/human-maintained wiki layer derived from it (per-dataset field specs, metric formulas, business logic, query cases; ~450 md pages + ~110 python config files), and the SKILL.md schema + lint rules on top. It's distributed to a whole team, and each person's agent (Claude Code / Cursor / etc.) both uses and edits it.

Two things I can't settle:

  1. Size vs. keeping source-of-truth local. The immutable snapshots are the heaviest, churniest part. The gist stresses keeping an immutable raw layer as the foundation, but do you keep raw sources in-repo, or split them out (submodule / LFS / on-demand fetch) to keep the skill light? And does repo size actually hurt agents at query time, or is it purely a human clone/CI cost?

  2. Concurrent team maintenance without rot. With multiple people's agents editing the same skill: do they push directly, or through a review gate (PR) before a page lands? How do you stop two agents fighting over the same page / spawning near-duplicates? Who owns the SKILL.md schema when the whole team co-evolves it? And the lint pass — human-triggered, or on a timer / CI hook? You called drift the #1 failure mode, so I'm most curious what actually enforces it at team scale.

Trying to avoid the failure mode where a shared wiki slowly rots because no single person owns the bookkeeping. Any pointers appreciated.

@bprice1000

bprice1000 commented Jul 8, 2026

Copy link
Copy Markdown

I build a CMMS with this as a primary influence.

It’s transformative. New levers to lean on, fun things happening when we do.

Ty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment