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.

@vijay-athithyaa-GV

Copy link
Copy Markdown

I built llm-wiki-init — a Claude Code plugin to scaffold this pattern

Packaged the raw/wiki/CLAUDE.md structure from this gist as an installable
Claude Code plugin. Fully generic — no assumptions about domain.

/plugin marketplace add vijay-athithyaa-GV/llm-wiki-init
/plugin install llm-wiki-init@llm-wiki-init
/wiki-init my-wiki "any topic"

Also ships /wiki-status — read-only health check (page counts, recent log
entries, orphan pages). Refuses to overwrite an existing wiki if you re-run
/wiki-init on the same folder.

https://github.com/vijay-athithyaa-GV/llm-wiki-init

@drjoeshepherd

Copy link
Copy Markdown

Take a look at SIGN (https://github.com/sign-protocol/sign-lang). I built and open sourced this spec to help agents reason over knowledge. I basically encode your wiki idea in SIGN to improve reasoning quality and token costs.

@TABARC-Code

TABARC-Code commented Aug 7, 2026

Copy link
Copy Markdown

I am finding adding smaller nuanced skills that adds llm context help. I've been using Dewey decimal code as a way to tag files and it tends to be a useful thing. [Dewey code skill] (https://github.com/TABARC-Code/Deweygraph-file-organizer) And in my repo somewhere the odf file structure skill

@gowtham0992

Copy link
Copy Markdown

Link 2.2 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:

  • Sync, no server. "lnk sync" moves reviewed memory between machines through a git remote you control. Secrets are scanned before push, conflicts become review items instead of git conflict markers, private captures never leave the machine. "lnk team-sync" runs a shared team brain on the same rails.

  • Temporal recall. "where does local data live" returns today's answer. "where does local data live in March" returns what was true then, rebuilt from dated files and supersede lineage. No model in the path. 0.917 point-in-time accuracy from plain phrasing, same as an ISO date.

  • Retrieval observability. Link records locally when agents read memory back, and which memories. "lnk wins" reports counts, "lnk digest" names memories never retrieved once. Never your query, never synced, "LINK_USAGE=off" disables it.

linkbar-12-inbox
  • Memory reaches every agent. Only 3 of 9 supported agents have session hooks, so the first MCP tool response of a session now carries the memory brief for the rest.

  • lnk import. Bring existing memory home from CLAUDE.md, Claude Code auto-memory, Cursor rules, AGENTS.md, or a ChatGPT export. Everything lands as reviewable proposals. Nothing is auto-accepted.

linkbar-12-status
  • Two new CI-enforced benchmarks. Token economics: 1,951 to 4,835 tokens per recall by budget; a 64x larger store grows the packet 1.58x. The first MCP response of a session also carries the brief, which the benchmark now measures separately. Poisoning: 18 injection attacks including 3 MemGhost-class, 0 reach the inbox unlabeled, 0 false positives.

  • Also: "lnk digest" weekly reflection, merge suggestions for duplicate memories, "lnk setup" repairs stale agent instruction files, LinkBar 1.2 shows memory usage and sync state.

# 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

# bring your existing memory
lnk import claude-code    # or: cursor, codex, file --file chatgpt.txt

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/v2.2.1

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

@akash07k

akash07k commented Aug 7, 2026

Copy link
Copy Markdown

How is it compared to IWE?

Link 2.2 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:

* Sync, no server. "lnk sync" moves reviewed memory between machines through a git remote you control. Secrets are scanned before push, conflicts become review items instead of git conflict markers, private captures never leave the machine. "lnk team-sync" runs a shared team brain on the same rails.

* Temporal recall. "where does local data live" returns today's answer. "where does local data live in March" returns what was true then, rebuilt from dated files and supersede lineage. No model in the path. 0.917 point-in-time accuracy from plain phrasing, same as an ISO date.

* Retrieval observability. Link records locally when agents read memory back, and which memories. "lnk wins" reports counts, "lnk digest" names memories never retrieved once. Never your query, never synced, "LINK_USAGE=off" disables it.
linkbar-12-inbox
* Memory reaches every agent. Only 3 of 9 supported agents have session hooks, so the first MCP tool response of a session now carries the memory brief for the rest.

* lnk import. Bring existing memory home from CLAUDE.md, Claude Code auto-memory, Cursor rules, AGENTS.md, or a ChatGPT export. Everything lands as reviewable proposals. Nothing is auto-accepted.
linkbar-12-status
* Two new CI-enforced benchmarks. Token economics: 1,951 to 4,835 tokens per recall by budget; a 64x larger store grows the packet 1.58x. The first MCP response of a session also carries the brief, which the benchmark now measures separately. Poisoning: 18 injection attacks including 3 MemGhost-class, 0 reach the inbox unlabeled, 0 false positives.

* Also: "lnk digest" weekly reflection, merge suggestions for duplicate memories, "lnk setup" repairs stale agent instruction files, LinkBar 1.2 shows memory usage and sync state.
# 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

# bring your existing memory
lnk import claude-code    # or: cursor, codex, file --file chatgpt.txt

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/v2.2.1

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

@AnthonyL502

Copy link
Copy Markdown

I’ve been thinking about this for a while. I’ve also created a small system to help me prepare for interviews, and so far, it’s been pretty effective at helping me draw on the knowledge from my past documents. I haven’t gotten to the retrieval system yet, but thank you for your ideas and the discussion in the comments section!

@sturlese

sturlese commented Aug 7, 2026

Copy link
Copy Markdown

I've tried to take this a step further and build it for a team. Once several people write into it, a bad page becomes what the company believes, so you need a human in the loop before certain things land, and some notion of who reads what.

Captures come in from Slack or a meeting transcript, an agent drafts the page, and plain code reviews the git diff before it commits: secrets, PII, whether the entity it claims to be about exists. If it can't place something it asks the submitter one question instead of guessing, and new entities need a steward's approval. Visibility is path rules stamping audience labels at write time, enforced in one place on read.

Entity search is where embeddings alone fell short. Every page declares which entities it is about, code stamps that field rather than the model, and a question resolves against a registry of names and aliases first.

Git is the store, Postgres + pgvector the index, lexical and vector fused with RRF, one MCP server that cites or refuses:
https://github.com/sturlese/stigmergy

Like any approach it has good and bad sides, and plenty of these choices could have gone the other way. Any feedback or discussion is very welcome.

@1wgrumph

1wgrumph commented Aug 7, 2026

Copy link
Copy Markdown

I built BRAN for the Schema layer of this, using OKF.

A bit of YAML frontmatter turns ordinary markdown into a queryable knowledge graph, so there's no RAG pipeline to build: no embeddings, no vector store, no index going stale on merge.

BRAN is a Rust CLI that keeps a repository's knowledge maintainable and queryable, then hands your model a small, bounded context packet. Same input, same ranking, every time. It runs standalone with no model and no account, or connected to one for answers with citations. I've also hooked my agent harnesses, so a model reaching for an unranked rg or grep gets pushed to BRAN and comes back with a ranked result instead.

A query against one of my repos, "where is risk sizing enforced", narrowed 45.9 MB of candidate source to 40 KB with the right file at rank 1.

The savings compound in long agentic loops, and agents map a codebase and find bugs faster with fewer hallucinations, because the context window goes to the right files instead of bloat. It works just as well on code you didn't write, which matters when you're porting something or learning how an unfamiliar repo fits together.

@frankchu91

Copy link
Copy Markdown

MindBase v2 — this pattern now runs as a full app, on a free local model

Follow-up to my July comment. Big increment since then: back then you
needed an AI editor and an API key to run the pattern. Now you need neither.

Write in a real editor, watch the wiki absorb it. Notes live in your
layer; each one carries a status chip — ✨ Add to wiki while it's newer
than the last build, ✓ In wiki · 2 pages once absorbed. Seeing the raw
layer get digested into the wiki layer is what makes the pattern click.

MindBase v2 — writing a note, wiki-status chip, qwen3:14b running locally

The "discuss takeaways" step is now a first-class surface. Every ingest
shows takeaways + a checkbox plan of wiki updates — only what you approve
gets written. My v1 skipped this step and it felt like the AI rewriting
your notes behind your back; this one change fixed the trust problem.
Build, lint (contradictions / orphans / gaps as cards), and research are
in the UI too.

The approval step — takeaways and a checkbox plan, generated by qwen3:14b locally

It runs on a free local model. Setup detects your hardware, picks an
Ollama model that fits your RAM (8GB → llama3.2:3b, 32GB+ → qwen3:14b),
installs and verifies it. The unlock: I dropped multi-step tool loops —
every wiki operation is one constrained JSON completion against a
strict schema. Small models are shaky chaining tool calls but very
reliable filling one schema. Zero subscriptions, nothing leaves your
machine.

Still all markdown on disk. Repo: https://github.com/frankchu91/mindbase

(@akash07k — answers your question too: v2 is the default layout now,
/mb:migrate converts old projects. Thanks for the nudge.)

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