# LLM Wiki on IWE: Karpathy's pattern with deterministic lint, link-safe refactoring and an IDE that edits in place

> Source: <https://gist.github.com/gimalay/6415b269dd9188060c4ea60ede5eb7bb>
> Published: 2026-10-04 17:12:00+00:00

A fork of Karpathy's LLM Wiki idea file. The original describes the pattern; this is one concrete way to run it, on [IWE](https://github.com/iwe-org/iwe) (open source, Apache-2.0: a CLI, an MCP server and an LSP for markdown folders). Disclosure: I wrote IWE.

Same idea as the original: paste it into your agent (Claude Code, Codex, OpenCode, etc.) and build the specifics together.

The original sets it up as "Obsidian is the IDE; the LLM is the programmer; the wiki is the codebase." All of that stays: raw sources, an LLM-owned wiki, a schema file, ingest / query / lint.

What changes is the bookkeeping. In the original, the index, the orphan checks and the cross-references all depend on the LLM remembering to do them. That works for a while. Somewhere past a few hundred pages it starts to slip quietly: a renamed page leaves dead links, a new page never makes it into the index, a summary drops a field the others have. IWE turns those into commands the agent runs and checks the result of.

- **index.md becomes inclusion links.** A link alone on its own line is a parent → child edge. An index or section page is just a list of those, and a page can have more than one parent.`iwe tree` prints the hierarchy;`iwe find --included-by wiki/concepts` lists one section.
- **Lint becomes partly deterministic.**`iwe stats` lists orphan pages.`iwe schema validate` checks every page against a schema (required frontmatter fields, enum values, dates, which sections and in what order). The LLM still has to spot contradictions and stale claims; it no longer has to remember the structural checks.
- **Refactoring keeps links intact.**`iwe rename old-key new-key` rewrites every reference to the page.`iwe extract` lifts a section into its own page and leaves a link behind.
- **Dataview becomes a query.**`iwe find --filter '{type: entity}'` over frontmatter, plus graph relations (`--included-by` ,`--referenced-by` ). Same language from the CLI and from the MCP server.
- **Search.**`iwe find --lexical "query"` is BM25 over titles and bodies. It is not semantic search; if you need vectors, qmd from the original still fits alongside.

```
brew install iwe-org/iwe/iwe      # or: npm install -g @iwe-org/iwe, or cargo install iwe iwes iwec
mkdir my-wiki && cd my-wiki && iwe init
```

Give the agent IWE's tools. For Claude Code:

```
/plugin marketplace add iwe-org/skills
/plugin install iwe@iwe-org
```

For Codex or any other MCP client, add the `iwec` MCP server with the wiki folder as its working directory ([agent connection guide](https://iwe.md/docs/agentic/)).

Layout, same three layers as the original:

```
raw/                 immutable sources (the LLM reads, never writes)
wiki/
  index.md           inclusion links to the section pages
  log.md             append-only, "## [2026-10-04] ingest | Title"
  sources/  entities/  concepts/
AGENTS.md            the schema (CLAUDE.md for Claude Code)
.iwe/schemas/        page-type schemas, bound by glob in .iwe/config.toml
```

A page-type schema, for example for source summaries:

```
$schema: https://document-schema.org/draft/2026-06/schema
description: a summary of one raw source
frontmatter:
  type: object
  required: [type, source, ingested]
  properties:
    type: { const: source }
    source: { type: string }
    ingested: { type: string, format: date }
```

**Ingest.** Same flow as the original. Two additions for the schema file: after writing pages, run `iwe schema validate` and fix what it reports; every new page gets an inclusion link from its section page, so nothing is created as an orphan.

**Query.** Start from the index or `iwe find --lexical`, then pull a page with its children (` iwe retrieve -k <page> -d 1`). Good answers still get filed back as pages, linked from where they belong.

**Lint.** `iwe stats` for orphans, `iwe schema validate` for shape, then the LLM pass for contradictions, stale claims and missing pages.

**Log.** Unchanged. The grep trick from the original still works.

The original runs the agent in one window and Obsidian in the other. [iWe for Mac](https://github.com/iwe-org/iwe-mac/releases) puts them in one: it connects the Claude Code or Codex you already use, the agent sees the page you have open, its edits land in the document while you watch, and one ⌘Z undoes a whole run. Obsidian and your editor keep working on the same folder; there is nothing to import. The app is free, macOS 15+, and not open source (the CLI and MCP server are).

- Contradictions and stale claims are judgment calls; the LLM still makes them.
- A schema checks shape, not truth. A page can validate and still be wrong.
- The index-in-context approach still has the same ceiling as in the original; past it, lean on queries instead of reading the index.

```
Set up an LLM Wiki in this folder using IWE: install it (brew install iwe-org/iwe/iwe),
run `iwe init`, create raw/ and wiki/ with index.md and log.md, and write an AGENTS.md
that describes ingest, query and lint using `iwe find`, `iwe retrieve`, `iwe stats` and
`iwe schema validate`. Docs: https://iwe.md/docs/agentic/
```


