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.

@leszekszczepkowski

Copy link
Copy Markdown

Hi Andrej, thank you for LLM Wiki. I'd like to publish a free Polish translation for Polish users, clearly marked as a translation, with credit and a link to your original. Would that be OK with you?


Generated by Claude Code

@sajidalom8550-droid

Copy link
Copy Markdown

KnowledgeWiki

@sajidalom8550-droid

Copy link
Copy Markdown

KnowledgeWiki

@hallaai

hallaai commented Nov 15, 2026

Copy link
Copy Markdown

Tried the LLM Wiki pattern against a measured document-RAG pipeline: compiled wiki loses on precise questions

Setup. 1,914 pages: 12 FinanceBench 10-K/10-Q filings, an investor deck full of charts, an earnings release, and 3 architectural drawings. 77 questions with gold answers: ratios, single chart values, table lookups, room areas. An LLM judge grades each answer correct = 1, partial = 0.5, wrong = 0.

Wiki implementation. Each document is read 8 pages at a time, along with the current index.md so existing page names get reused. The model writes topic pages (income statement, segments, debt, room schedule, …) and tags every number with its source page as (p.N). Fragments written for the same topic are then merged into one page, and index.md and an append-only log.md are written. Querying works the way you describe: read the index, pick pages, read them. There are no embeddings. Compiling turned 1,914 pages into 403 wiki pages for about $1 with gemini-3.1-flash-lite. Lint is not implemented.

Pipeline Score
Routing + fusion retrieval + LLM rerank → per-page vision transcription + page images 0.89
No retrieval: whole document in the context window 0.88
LLM Wiki + the 5 source pages its wiki pages cite most 0.79
Classic hybrid text-chunk RAG 0.72
LLM Wiki only 0.64

What I saw:

  • Compiling drops detail. 30 of the 77 wiki-only answers lost points, and 25 of those say the information isn't in the wiki. The footnote figure a FinanceBench question needs is exactly what a summary leaves out.
  • The wiki works better as a map than as the answer. Adding the source pages it cites recovers 15 points. It still trails proper retrieval, though: it lost to the best pipeline on 10 questions and won on 1.

Takeaway: a compiled wiki is a good map and a good synthesis layer, but as the only source it loses the specific facts people ask about. I'd use it alongside retrieval (as an index or one more retrieval stream), not instead of it.. Although it might give slightly better answers to broad general questions.


@podviaznikov

Copy link
Copy Markdown

If you want to build your own vault from everything that's stuck inside apps, that's why I made exporter.dev. It keeps one folder of Markdown in sync with your apps:

  • Apple Notes, Messages, Mail, Contacts, Calendar, Reminders, Voice Memos and Phone calls
  • Safari and Chrome history, Apple Books highlights, Wallet and Screen Time
  • Notion, Linear, Bear, Logseq and Claude Code sessions
  • Health, from the iPhone app

It's all written for Obsidian: properties in front matter, [[wikilinks]] from each conversation to the people in it, block ids so a reply links to the message it answers. Point your LLM at that folder as the raw layer and let it write the wiki on top.

@gimalay

gimalay commented Nov 15, 2026

Copy link
Copy Markdown

@hallaai

The wiki works better as a map than as the answer.

Same here, on a wiki I use every day (about 1,200 markdown pages, an agent does most of the writing). Two things follow from it for me.

The numbers people ask about are not compiled into pages at all. They stay in the source files (CSV, JSONL) and a page links to the file or carries the query, so the agent reads the value instead of a summary of it. Your 25 "not in the wiki" answers are that case.

And the agent doesn't read index.md to pick pages. It queries frontmatter and links (type, status, date, what links to what) and gets a short list, then goes to the source the page cites. The pages hold what no source has: the reading, the decision, what was ruled out, when it was last checked.

I'd be curious how the "wiki + cited source pages" row moves if a wiki page cites the table or cell instead of the page.

Disclosure: I work on iwe, the CLI that runs those queries over the folder: https://github.com/iwe-org/iwe

@ShalokShalom

Copy link
Copy Markdown

LLM Wikis haven proven to be suboptimal, ask your AI for alternatives. Stuff such as Vestige, Serena and codebase-memory-mcp plus some techniques can provide a modern option.

@manuongithub

Copy link
Copy Markdown

We keep running into this with meeting transcripts, so here's a note from that corner.

Transcripts are a bad fit for RAG and a great fit for a wiki. Any one call is low signal. People hedge, go off topic, say the same thing three different ways. The value only shows up in aggregate: what this customer has asked for across nine calls, which objection keeps coming back, where what someone said in March doesn't match what they said last week. Chunk and retrieve has to work that out again on every question, and usually gets it wrong. Compiling it once into pages for accounts, people, deals and open threads, then updating those as each new call lands, fits much better.

Two things from your doc land well here. log.md comes for free, because meetings are already in order and already timestamped. And Lint is the operation we care most about. "This page contradicts a newer source" is just a stale assumption about a deal, and nobody ever goes looking for those.

We're building toward this at https://icecubes.app. Transcription with no bot in the call (browser extension for Meet, Zoom and Teams, tab capture for anything else, phone on the table for in person meetings), plus an MCP server so an agent can read the raw sources directly instead of through an export. The wiki layer is next on our list. The schema as config idea is the part we hadn't put into words. Thanks for writing this up.

@ChiefStarKid

Copy link
Copy Markdown

Thank you for this. I loved the idea and set out to build it, and ran into constraints: a small token budget, not always the best model, and sources I don’t own that move without warning. Working within them led to a fork that keeps the wiki and adds a behaviour layer: https://gist.github.com/ChiefStarKid/bb10932b9dd04752deb4db632f7c6fdc

@Starsalaya

Copy link
Copy Markdown

Your llm-wiki was a big inspiration for the design of NASC. I designed it so the wikis are made after the session, and the AI never has to remember to do it. Let the AI work and go wild, but the history is documented: decisions, open work, and the why, how and where are all saved. On top of this, I thought it was important for it to be multi-tenant, so an organization can keep its company knowledge following it into whichever AI tools it chooses to use. I designed this with my co-founder while working as a full-time firefighter and paramedic. I would love to have your feedback and thoughts. Thank you for all of your educational videos. I don't think you know how much they help people.

archerionlabs.com/nasc

@gowtham0992

Copy link
Copy Markdown

Link 6.0 is out

Link is local memory for AI agents: plain Markdown files, review-gated writes, no LLM in the memory layer, one store shared by Claude Code, Codex, Cursor, Kiro, Windsurf, Zed, VS Code, Copilot, and Gemini.

5.0 moved memory from the brief to the tool call, but only on Claude Code (and Cursor's shell). Every other agent I use could still read "never force-push main", agree, and do it anyway. 6.0 is rules that hold on every agent.

What's new:

  • Rules on every agent with a pre-tool hook. lnk setup now installs rule checks for Codex (shell and apply_patch), Cursor (shell, reads, writes, deletes), Gemini CLI and Antigravity, Copilot (CLI and VS Code), Windsurf, Kiro and Devin, each answered in the shape that agent reads. Zed has no hooks, so lnk compile --global --targets zed writes your rules into its own tool permissions.

  • Held calls. Codex, Windsurf, Kiro and Cursor's file checks can only allow or block, so an ask rule had nowhere to ask. Now the call is held, the agent is told to ask you, and lnk approve <id> (or Approve once in LinkBar) lets exactly that call through, once, on the agent it was held on. A different patch to the same file does not ride along.

  • Commands read the way the shell will run them. Options reordered or bundled (git push -uf), quotes the shell removes, bash -c, shell functions, git.exe, in-place editors like sed -i. PowerShell is now read as PowerShell: under POSIX rules Get-Content C:\repo\.env lost its backslashes and named no file, so path rules never saw it. A call Link cannot read waits for you instead of running unchecked. The limit, stated plainly: the hook runs as you, so it stops mistaken or talked-into calls, not an agent determined to write its own way around them.

  • Measured. Offline: 33 of 33 forbidden calls caught in their disguises, 0 of 53 ordinary coding-agent calls stopped, about 0.2 ms per decision. Live, a new benchmark gives a real agent tempting tasks in a throwaway repo and reads the outcome from git, not from what the agent says. First run on Codex: force-push and npm publish held, migration edit denied, both ordinary tasks done. A live Claude Code run is still to come.

  • lnk stale --wiki, the lint step from this gist, made deterministic. It lists pages written before a raw file they rest on was edited, source pages whose raw file is gone, citations to pages that don't exist, pages that cite only other wiki pages, and one concept written twice. On my own 23-page wiki: 16 findings, each confirmed by opening the files. A small sample, so the precision claim stays modest.

  • Memory reaches agents with no session-start hook. lnk compile --global writes reviewed personal memory into the one file Windsurf, the Kiro IDE and Zed read at every session start, within each vendor's size limit.

  • Dogfooding found two good ones. Codex had never seen Link's instructions: they went to ~/AGENTS.md, which Codex doesn't read (Claude Code does). And on release day CI failed because the demo's memories, dated May, had aged past their own six-month trust window. Fixing that exposed a teammate's unreviewed memory whose title could appear in an agent's recall packet. Both fixed before tagging.

  • LinkBar 1.6. Held calls sit at the top of the inbox ("Waiting for your OK": the agent, the call, the memory that held it), with a notification the moment an agent is stopped.

image image
# macOS, CLI + menu bar app
brew install --cask gowtham0992/link/linkbar
lnk setup

# CLI only (or Linux)
brew install gowtham0992/link/link
lnk setup

# already running Link
brew upgrade && lnk setup        # wires rule checks into every agent it finds

# a held call
lnk approve                      # what's waiting
lnk approve <id>                 # shows the call, then lets it through once

Still: every memory a plain file you can open, nothing durable without review, no LLM in the memory layer, CI blocks network code in the runtime.

Release notes: https://github.com/gowtham0992/link/releases/tag/v6.0.0

Repo: https://github.com/gowtham0992/link
Site: https://gowtham0992.github.io/link/
PyPI: https://pypi.org/project/link-mcp/
MCP: https://registry.modelcontextprotocol.io/?q=io.github.gowtham0992%2Flink
Benchmarks: https://github.com/gowtham0992/link/blob/main/benchmarks/RESULTS.md

@HagaiHen

Copy link
Copy Markdown

@frankchu91 Nice to see this implemented! Does the near-duplicate check compare page names only, or also the content? I'm curious how it handles two pages about the same concept with very different titles.

@eigma-app

eigma-app commented Nov 30, 2026 •

Copy link
Copy Markdown

Eigma here (mentioned above in this thread). We've been building this pattern into an app for a few months, and one thing surprised us: writing the wiki is the easy part. Coming back to it is where it falls apart.

So Eigma does three things:

  1. Your AI files it. In ChatGPT or Claude, say "save this to Eigma". It writes new pages or updates existing ones in the chapter they belong to, and you approve each change before it lands.
  2. Your AI reads it back. In a later chat, it can search your wiki and answer from your own pages.
  3. You actually keep it. Every page carries a few short quizzes that come back right before you'd forget them.

Try it on the web: https://eigma.app/
ChatGPT plugin: https://chatgpt.com/plugins/plugin_asdk_app_6aa2cbe43cf481918d7e898329bf2dd6

There's also a desktop app with an AI Agent built in (Claude Code, Codex or OpenCode). Open a PDF or a web page next to your notes, ask about it, and the agent writes the wiki pages with you. Android syncs the same wiki.

desktop-globe-2026-11-30

@NDOTO-G

NDOTO-G commented Dec 3, 2026

Copy link
Copy Markdown

@crajah @a-a-k @nishchay7pixels @SEO-Warlord

I'm tagging you all in one post because you each raised the problem I've been working on: the wiki changes or gets overwritten, and nobody can tell.

I made a format for this called doc.html. It's a single HTML file. At the top is a list of every section with a hash of what's in it. A small script checks those hashes and tells you exactly which sections changed. The model doesn't have to guess.

Nothing gets overwritten. To fix something, you add a new section that says which one it replaces, so the old version and the fix both stay in the file. And it opens in any browser.

@nishchay7pixels, you asked how you'd even know if the knowledge got corrupted. The script answers that.

@a-a-k, you listed hashes, a validator and an audit trail. That's basically what this is.

@crajah and @SEO-Warlord, you wanted to see the history instead of silent rewrites. Every change sits right next to the version it replaced.

@crajah, I saw you've since built post-graph with append-only history. Same idea, just at the database level instead of inside the file.

I tested it against a markdown wiki built from this gist. I changed one fact in both. The wiki's health check said everything was fine. The doc.html check pointed to the exact sections I changed.

We've been running our own agents' memory on it since June.

Tests: https://dochtml.org/evidence.html
Repo: https://github.com/NDOTO-G/doc.html

I'd love to hear what you think, or what breaks if you try it.

@floriantriclin

Copy link
Copy Markdown

how do you guys plugin more than 1 modal to this, like use chatgpt same time with claude? i've asked chatgpt for answer, it said that put AGENTS.md beside with CLAUDE.md, then both of them have to go through layer that contain SYSTEM.md (for common instruction), WORKFLOW.md (common workflow), RULES.md, MEMORY.md (persistant project context), DECISIONS.md (architectual decisions), TASK.md (task state), along with skills folder and agents folder (architect.md, researcher.md, maintainer.md)

@tungxeodesign-ui @ShootJackal's answer is the right one: keep the memory outside the models and point each of them at it. I build an open-source server that does exactly that, so here is what it looks like in practice (disclosure: I'm the author).

mindyard (AGPL) serves the vault over MCP. Claude (web, desktop, mobile), ChatGPT, Mistral's Vibe and other MCP clients connect to the same endpoint and read and write the same Markdown pages, versioned in git.

On the AGENTS.md / CLAUDE.md question: you don't need parallel instruction files per client. The method (pick one wiki, read its schema before writing, show a plan before any batch, ingest / query / lint) travels with the server: as an MCP skill for clients that support the Skills extension, and through the server instructions and tool descriptions for the others. The rules of each vault live in the vault itself (schema.md, plus a wiki.yaml the linter enforces), so every model follows the same ones.

Two things matter once two models write to the same pages: an edit must carry the version it read, so a stale one is refused and ChatGPT can't silently overwrite what Claude just wrote; and every batch is one atomic commit, so you can see and revert who changed what.

Self-hosting is free. If you'd rather not run a server, there's a hosted version at mindyard.dev.

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