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.

@chipsageSupport
Copy link
Copy Markdown

Too many expert here. can i get some advice here? my PC: Intel Core Ultra 7 155H with 32G RAM.
If i want to build such wiki for semiconductor industry locally (first start with my manually written knowledge base doc), what llm i should download locally? Qwen2.5-7B instruct?

@denniscarpio30-jpg
Copy link
Copy Markdown

Been running this pattern in production for months, but from a non-engineering context - enterprise service delivery management (client stakeholder coordination, ticket tracking, document generation across multiple clients). Claude Code + Obsidian.

Three things that made the biggest difference:

Entity pages for people, not just concepts. I maintain wiki pages for ~15 key stakeholders with communication preferences and decision patterns. The LLM checks these before drafting any email or meeting prep. Immediate quality jump in client communications.

The schema file is the real flywheel. Every correction I give the LLM gets filed back into CLAUDE.md so it never repeats the same mistake. Over months this compounds into something surprisingly sophisticated - tone rules per client, anticipation protocols, agent dispatch logic.

Automate the maintenance or it dies. Scheduled agents run nightly - meeting prep generation, stale ticket scanning, dashboard updates - all writing directly into the wiki. The knowledge base stays current not because I remember to update it, but because the system does it on a schedule. This is what makes the pattern sustainable long-term.

You don't need to be a developer to build this. The LLM builds and maintains the whole thing. You just need to be disciplined about feeding corrections back into the schema.

@bashiraziz
Copy link
Copy Markdown

Based on this idea, I have created a repo https://github.com/bashiraziz/llm-wiki-template. I used Claude for it and am now working create Claude skill as well for others to use it, if they so desire.

@marvec
Copy link
Copy Markdown

marvec commented Apr 6, 2026

Thanks Andrej for this awesome work!

I tried to build a less opninionated skills with Andrej's input. I took llm-wiki.md, saved it and run the following prompt in my research repo/vault. That was enough to get me up and running smoothly without any fancy dependencies:

In this repository, I would like to create skills to implement the LLM Wiki concept according to @LLMWiki.md. I need a skills to: init the wiki, to ingest new inputs (not previously processed), to optimize the wiki (i.e. compact, reorganize...), to search in the wiki (for that I have qmd MCP server), and to check the wiki health. The inputs will be in 'raw' folder, attachments will go into 'raw/attachments'. You should also process everything in 'docs' and 'notes'. Add appropriate section to CLAUDE.md then to use the skills. The skills should be prefixed with "/llmwiki:". All outputs go to "/wiki". Define the folder structure there, create log.md and index.md.

@pssah4
Copy link
Copy Markdown

pssah4 commented Apr 6, 2026

Summaries don't replace thinking.

Great pattern, and I appreciate the clarity of the writeup. I've spent time with similar ideas, trying to give LLMs a knowledge graph as a navigation layer. The results weren't better than good retrieval. And this pattern arrives at the same place: once the wiki grows, you fall back on vector search, BM25, and CLI tools. The wiki becomes a pre-compiled intermediate layer on top of what is still a retrieval problem.

But my actual issue is somewhere else.

"You never (or rarely) write the wiki yourself — the LLM writes and maintains all of it."

This frames the human role as curating sources, asking questions, thinking about what it all means. Sounds reasonable on the surface. But I think it quietly removes the part where understanding actually forms.

I've used the Zettelkasten method for about three years. It changed how I read. I read with a pen. I write my own thoughts while working through someone else's ideas. Their thinking are triggers for me to think in my own context, develop my own positions, find my own connections. The cognitive work happens in the writing itself. The note is a byproduct. The thinking is the product.

When an LLM writes my summaries and cross-references, I get a well-organized information store. What I don't get is the understanding that comes from doing that work. I don't develop my own structure of thinking, sorting information, connecting insights. And you feel that later. In discussions, in decisions, in the ability to actually defend a position. If all I have are LLM distillates, I can report what the model produced. I can't argue from something I built myself, because I never did.

This isn't an anti-AI take. I build AI agents for a living. I've integrated LLMs deeply into how I work. But I think the human still needs to do the intellectual work of evaluating information, placing it in context, forming a view. The LLM can support that. It shouldn't do it for you.

One thing where I fully agree: Obsidian is the right foundation. Markdown, local, no lock-in. Your knowledge stays yours, and you can leave whenever you want. I've always had a problem with platforms that put your own thinking behind their paywall.

This pattern is a good impulse for thinking about knowledge organization. But organizing information and building understanding are different things. The grunt work you want to automate is, in a lot of cases, exactly where the learning happens.

@isingh
Copy link
Copy Markdown

isingh commented Apr 6, 2026

I wanted to contain the wiki to its own filesystem access and a limited sandbox. so i created memex

It basically wraps claude -p, but the wiki runs as a daemon. Now you can connect it to multiple apps (local or on the internet) and ingest your data properly (and serially).

@frosk1
Copy link
Copy Markdown

frosk1 commented Apr 6, 2026

Everyone is getting excited about the “LLM Wiki” idea (incrementally building a curated knowledge layer instead of raw RAG), but there are some important limitations that shouldn’t be ignored:

  1. Error accumulation & drift
    Once incorrect information is merged into the wiki, future updates build on top of it. Without strong validation, errors compound over time instead of being corrected.

  2. Partial context problem
    Updates are typically done using only a subset of documents (e.g., top-k retrieval). This means the wiki can easily miss relevant sources and converge to an incomplete or biased view.

  3. Loss of information
    Summarization is compression. Nuance, edge cases, and important details get lost—and you can’t recover them later from the wiki alone.

  4. False sense of “source of truth”
    A curated wiki feels authoritative, but it is still a derived artifact. Treating it as ground truth is risky—raw documents must remain part of the system.

  5. Hallucinated merges
    LLMs may “smooth over” contradictions or even invent connections between concepts. This can make the wiki look cleaner than reality, but less accurate.

  6. Operational complexity
    You’re introducing a full new layer:

  • ingestion pipelines
  • merge logic
  • validation & linting
  • versioning & rollback
    This is significantly more complex than standard RAG.
  1. Cost tradeoff
    You shift cost from query time to ingestion time. Depending on update frequency and corpus size, this can become expensive.

  2. Staleness & maintenance
    Without continuous reprocessing and cleanup, the wiki will drift from reality—especially in fast-moving environments.


Bottom line:
An LLM Wiki can be useful as a derived, navigational and synthesis layer, but it should not replace raw-source retrieval. The safest approach is a hybrid: use the wiki to guide and structure answers, but always ground responses in the original documents.

Curated knowledge is powerful—but only if you don’t confuse it with truth.

@arturseo-geo
Copy link
Copy Markdown

Formalised this into a versioned schema standard — AGENTS.md v1.1.0. Two additions beyond the original workflow: (1) explicit quality rules so agent behaviour stays consistent across sessions and models, and (2) a learning layer with auto-generated flashcards and FSRS spaced repetition. Also added an insights/ directory that the agent never touches — prompted by @kepano's point that a compiled summary is noise and a human insight is signal. → github.com/arturseo-geo/llm-knowledge-base

@pnakamura
Copy link
Copy Markdown

Great pattern, Andrej. This crystallized something I've been circling
for months.

I run AI agent orchestration for a $132M international development
program — 7 specialized agents (procurement, engineering, risk,
reporting) processing tasks through a Kanban with mandatory human
review. The first months were impressive. Then I noticed the agents
weren't getting smarter. Each execution started from zero. The
engineering agent didn't know what the procurement agent had learned
last week. Approved outputs disappeared into a database table.
Same compliance gaps rediscovered over and over.

Your LLM Wiki pattern named the missing layer. But in organizational
contexts, three things change:

  1. Multiple agents write to the same wiki — a "librarian" agent
    does cross-domain synthesis after each human-approved output
  2. A human validation gate sits before every wiki update — in
    enterprise, a hallucinated fact isn't a personal inconvenience,
    it's an audit finding
  3. The wiki feeds back into agent context — creating a compounding
    loop that doesn't exist in the personal use case

I wrote a companion piece connecting this to 30 years of knowledge
management theory (Nonaka's SECI spiral, Davenport, Senge) and
exploring why agent orchestration is fundamentally a knowledge flow
design problem, not a technology problem:

Knowledge Entropy: Why Organizations Forget and AI Agents Stagnate

The core thesis: organizations have failed at knowledge management
for 30 years because the maintenance falls on humans. LLM agents
change the equation — as you said, they don't get bored.

@marvec
Copy link
Copy Markdown

marvec commented Apr 6, 2026

Thanks Andrej, this is awesome. I run it on my research repo and the results are amazing. I created as little as possible opinionated version here https://github.com/marvec/rock-star-skills

@robertandrews
Copy link
Copy Markdown

Much in common with popular PKM practice. Except, I’m not getting any sense of Generation Effect, where YOU engage with what you’re capturing. Active, rather than passive, processing is reckoned to increase recognition and comprehension. See also: The Outsourcing Trap.

@walter-a-jablonowski
Copy link
Copy Markdown

walter-a-jablonowski commented Apr 6, 2026

I like to use the following structure in a file system:

/Base                      # This is an "activity tree", could also be a knowledge base
  3 - My Activity 1.md     # number = prio, file may also contain yml
  /3 - My Activity 2
    -this.md
    Some resource.md
    ...
    3 - Some LINK

By using and index file (-this.ext) I remove the difference between files and folders. Now we have a logical tree. I found that most things in the universe seem to fit in a tree, but it doesn't fit perfectly. 5-10% need to be sorted under multiple parents or are relations. This is why I add my own soft link format.

Compared to Obsidian we have much more structure here. I don't need to maintan index files. I build an index by recursively iterating over the file system and update it with a file system watcher.

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