OpenWiki: LangChain's Answer to the Karpathy Wiki Problem

By Prahlad Menon 2 min read

Last month, Andrej Karpathy dropped a gist describing what he calls the “LLM Wiki” — a pattern for building knowledge bases that LLMs can actually use. The core insight: instead of RAG (retrieve chunks at query time), have the LLM build and maintain a persistent wiki that compounds knowledge over time.

Two days ago, LangChain shipped something that implements this pattern for codebases: OpenWiki.

The Gap Between Docs and Agent Understanding

Most codebases have documentation. READMEs, docstrings, architecture diagrams. But when you point a coding agent at a repo, it doesn’t understand the codebase the way a human teammate would after a few weeks on the project.

The problem isn’t lack of docs — it’s that docs are written for humans to browse, not for agents to consume in context windows.

Karpathy’s LLM Wiki pattern addresses this by inverting the relationship: instead of the LLM querying static docs, the LLM writes the docs in a format optimized for its own consumption.

What OpenWiki Does

OpenWiki is a CLI that generates and maintains an openwiki/ directory in your repo. The key behaviors:

1. Agent-Native Format

The generated wiki isn’t prose for humans — it’s structured markdown optimized for LLM context. Headings, cross-references, and summaries are designed for an agent to quickly find relevant context.

2. AGENTS.md Integration

OpenWiki automatically appends instructions to your AGENTS.md (or CLAUDE.md) telling your coding agent to reference the wiki:

## OpenWiki Context
When searching for codebase context, check openwiki/ first.
Key files: openwiki/architecture.md, openwiki/patterns.md

This closes the loop that Karpathy identified — the wiki exists, but more importantly, the agent knows to use it.

3. Self-Maintenance

A GitHub Action runs daily, generating PRs with documentation updates. No human needs to remember to update docs when code changes. The wiki stays current because maintenance cost is near zero.

# .github/workflows/openwiki-update.yml
name: Update OpenWiki
on:
  schedule:
    - cron: '0 6 * * *'  # Daily at 6am

The Karpathy Pattern in Practice

Karpathy’s gist describes three layers:

  1. Raw sources — immutable source documents
  2. The wiki — LLM-generated synthesis
  3. The schema — instructions telling the LLM how to maintain the wiki

OpenWiki maps this directly:

Karpathy LayerOpenWiki Implementation
Raw sourcesYour codebase (immutable from wiki’s perspective)
The wikiopenwiki/ directory
The schemaAGENTS.md integration + CLI prompts

The key insight from Karpathy: “Humans abandon wikis because the maintenance burden grows faster than the value. LLMs don’t get bored.”

Quick Start

npm install -g openwiki
openwiki --init
# Configure model and API key interactively

openwiki "Generate documentation for this repository"

Supports OpenRouter, Fireworks, Anthropic, OpenAI out of the box.

Why This Matters

The agent tooling space has converged on a pattern: coding agents read instruction files (AGENTS.md, CLAUDE.md, CURSOR.md) at session start. OpenWiki extends this pattern to include generated context, not just human-written instructions.

This is the difference between telling your agent “here’s how we do things” and giving it a colleague who’s already mapped the entire codebase.

Frequently Asked Questions

What is OpenWiki?

OpenWiki is a CLI tool from LangChain that automatically generates and maintains documentation for your codebase, specifically designed for AI coding agents to consume. It creates an openwiki/ directory with structured markdown files and updates your AGENTS.md or CLAUDE.md to instruct agents to reference it.

How is OpenWiki different from regular documentation?

Traditional docs are written for humans to browse. OpenWiki generates documentation optimized for LLM context windows — structured headings, cross-references, and summaries that agents can quickly parse. It also auto-updates via GitHub Actions, eliminating documentation drift.

What is the Karpathy LLM Wiki pattern?

The LLM Wiki pattern, described by Andrej Karpathy, replaces RAG (retrieving chunks at query time) with a persistent wiki that the LLM builds and maintains. Instead of re-deriving knowledge on every query, the LLM incrementally synthesizes information into interlinked pages that compound over time.

Which LLM providers does OpenWiki support?

OpenWiki supports OpenRouter, Fireworks, Baseten, OpenAI, and Anthropic out of the box. You can also specify custom model IDs for each provider during configuration.

How do I keep OpenWiki documentation up to date?

Add the included GitHub Action (.github/workflows/openwiki-update.yml) to your repository. It runs daily and opens a PR with any documentation updates needed based on code changes.

Can I use OpenWiki with Claude Code or Codex?

Yes. OpenWiki automatically appends instructions to AGENTS.md (for Codex) or CLAUDE.md (for Claude Code) telling the agent to reference the generated wiki when searching for codebase context.


Links: