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.

@FERRSTUDIO

Copy link
Copy Markdown

Shameless plug for my implementation, once again(再来安利一次我的实现):https://github.com/ChavesLiu/second-brain-skill
No it's not, and you delu.
The one from Karpathy is a feather.

@gowtham0992

Copy link
Copy Markdown

Link 3.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.

What's new:

  • Recall works outside English. The tokenizer split on [^a-z0-9]+, so every non-Latin script produced zero tokens: Japanese, Chinese, Korean, Russian, Arabic and Indic memories were unfindable, and nothing said so. Accented Latin was little better: "déploiement" could not be found by typing "deploiement". Scripts written without spaces are now cut into character bigrams (the Lucene CJKAnalyzer approach, no dictionary), Latin accents fold, and combining marks in Indic scripts are kept because they are vowels, not accents; stripping them turned "मंगलवार" into "गलव". Wiki full-text search had the same bug one layer down and is fixed the same way. Found while verifying it end to end: page filenames also slugged non-Latin titles to nothing, so every such memory was filed as memory.md and the second one was refused as a duplicate. A non-English user could save exactly one memory. Titles now keep their own script. ASCII text takes the exact old path, so nothing existing changes: all nine LoCoMo figures are unchanged across 1,536 third-party queries.

  • "lnk stale": notice when a memory outlived the code it describes. The most repeated complaint about agent memory is that nothing tells you when a memory stopped being true. A note says the parser lives in a/b.py, the file is renamed, the memory keeps being retrieved and believed. Hosted memory services cannot fix this because they never see the repository. Run "lnk stale" inside a repo and it lists memories naming files git no longer has, with the successor path where git recorded a rename. A path is questioned only when it is missing now and git tracked it before; without the second half, an unresolvable path is just prose and flagging it is the noise that teaches people to ignore the flag. Read-only, findings go to the review gate. Precision is measured, not asserted: 0 false flags across 108 path references in Link's own docs, every probed deletion detected, and the eval fails CI if either moves. Stale memories are also marked in the recall packet, so the agent is told rather than left to trust.

image
  • The retrieval benchmark reports precision, not only recall. Recall is the number this category publishes, and it cannot separate a system that retrieves cleanly from one that returns everything, because returning everything scores 1.0 by construction. On the same 1,536 LoCoMo queries a whole-store dump carries 0.26% signal; Link's top-1 packet reaches 0.3086 precision on the fast tier, 117x, and pays a real recall cost that is published in the same table. The track now reports the ceiling each cutoff allows (evidence sets average 1.53 turns, so nobody can exceed precision@10 of 0.152) and R-precision as the k-independent figure to compare across systems.

  • Measured and declined: usage-aware ranking. Four formulations were built and measured (additive frequency, tiebreak-only, recency decay in the Generative Agents form across the recommended 7 to 30 day half-life, MMR diversity) and none ship. Every one either made memories that had gone unread harder to find or did nothing; recency was worst, the old half losing 0.0510 while the fresh half gained 0.0204. The reason is a category difference: those policies suit episodic observation streams, and Link stores durable constraints, which do not become less true for going unread. That is when they most need surfacing. The eval stays in the repo so the next attempt has to clear the same bar.

  • "lnk ingest" for structured exports, contributed by @jakobtfaber. Plan-first: provenance manifests hashed per output, staging through a temp directory, validation before promotion, explicit --replace-unmanaged and --prune gates. Imported docs land in the wiki, never in memory, and stay out of personal-memory proposals.

  • LinkBar 1.4. Bugs first: health probes ran on the main thread and froze the popover on every Status refresh; the review inbox showed five items and hid the rest; the workspace could not be changed in the shipped app because a Finder-launched app never sees LINK_WORKSPACE. All fixed: probes run concurrently off the main thread, the inbox scrolls, the workspace is chosen in Settings, every approve/archive/accept confirms what it did, and a refused save reports the CLI's real reason. Then the 3.0 tie-in: a Status row runs "lnk stale" against the repo your last agent session was in, with a one-click filter on the Memory tab and an amber dot in the menu bar.

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

# stale check, from inside a repo
lnk stale

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/v3.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

@chimezie

Copy link
Copy Markdown

This is a very powerful paradigm and architectural style. I mainly use OpenCode and want to implement this for that harness, but I don't want to reinvent the wheel if there are existing OpenCode implementations. Are there any implementations that can easily be 'extended' to do so?

@equationalapplications

Copy link
Copy Markdown

@chimezie I built something along these lines (disclosure: I'm the author). Curated Thoughts is an open-source (MIT) desktop app for Linux, macOS and Windows. It keeps a Karpathy-style LLM wiki over a plain-markdown vault, backed by a local SQLite "brain". It also ships an MCP server, curated-thoughts-mcp, so any harness can use it. With 2.12 the server exposes 16 tools, including wiki_context, wiki_search, wiki_traverse_graph, vault_semantic_search, vault_write_note, and a review-before-merge proposal flow for curated "wisdom" entries.

For OpenCode there's now a packaged integration: opencode v0.1.0.

  1. Install Curated Thoughts from its releases page. The installers include the curated-thoughts-mcp sidecar. Run the app once to create your brain.

  2. Download opencode-0.1.0.tar.gz from the release above, unpack it, and run:

    ./scripts/install.sh                    # preview: prints exactly what it will change, writes nothing
    CT_INSTALL_EDIT=1 ./scripts/install.sh  # apply

    It adds the mcp entry to your global opencode.json without disturbing comments or formatting, installs a small plugin that puts a memory health snapshot in the system prompt, and adds three skills that teach the agent how to use the wiki.

  3. Check it with opencode mcp list (should show curated-thoughts connected), or run the bundled doctor for a full diagnosis of sidecar, brain, vault and registration.

If you'd rather wire it up by hand, the core is just an MCP entry:

{ "mcp": { "curated-thoughts": { "type": "local", "command": ["curated-thoughts-mcp", "--mcp"], "enabled": true } } }

On extending it: the integrations repo is MIT and each integration is small. There are sibling integrations for Hermes and DeepSeek Harness if you want to see how the pieces fit. Issues and PRs are welcome.

@chimezie

Copy link
Copy Markdown

Thank you and for the info and this implementation

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