155 lines
4.4 KiB
Markdown
155 lines
4.4 KiB
Markdown
---
|
|
name: llm-wiki
|
|
description: |
|
|
Karpathy-pattern LLM knowledge base. Builds and maintains a persistent wiki of structured,
|
|
interlinked markdown files using Claude Code — fundamentally different from RAG. Instead of
|
|
re-deriving answers from raw documents at query time, the LLM incrementally builds the wiki:
|
|
reading sources, extracting concepts, updating entity pages, and flagging contradictions.
|
|
Uses Obsidian as the visual frontend.
|
|
|
|
Trigger when user says:
|
|
- "set up my wiki" / "create a knowledge base" / "build a second brain"
|
|
- "set up an LLM wiki about [topic]"
|
|
- "ingest this article / URL / transcript / video"
|
|
- "add this to my wiki"
|
|
- "query my wiki" / "what does my wiki say about"
|
|
- "lint the wiki" / "health check my wiki"
|
|
- "connect my notes on [topic]"
|
|
- "Karpathy wiki" / "LLM wiki"
|
|
allowed-tools:
|
|
- Bash(firecrawl *)
|
|
- Bash(mkdir *)
|
|
- Bash(git *)
|
|
- Bash(grep *)
|
|
- Bash(find *)
|
|
- Write
|
|
- Edit
|
|
- Read
|
|
- Glob
|
|
---
|
|
|
|
# LLM Wiki — Karpathy Pattern
|
|
|
|
A persistent, compounding knowledge base maintained entirely by Claude Code.
|
|
Obsidian is the IDE. Claude is the programmer. The wiki is the codebase.
|
|
|
|
---
|
|
|
|
## Core Concept
|
|
|
|
**RAG** re-derives knowledge on every query. The LLM has to find and piece together fragments each time. Nothing accumulates.
|
|
|
|
**This wiki** pre-compiles knowledge. When a source is ingested, Claude reads it, extracts key information, and integrates it into the existing wiki — updating entity pages, noting contradictions, adding cross-references. Ask a question later and the synthesis is already there.
|
|
|
|
The wiki is a **persistent, compounding artifact**. It gets richer with every source ingested and every question asked.
|
|
|
|
---
|
|
|
|
## Three-Layer Architecture
|
|
|
|
```
|
|
raw/ ← immutable source documents (user controls, LLM reads only)
|
|
wiki/ ← LLM-generated markdown (LLM owns, user reads)
|
|
CLAUDE.md ← schema (tells Claude how to behave in this wiki)
|
|
```
|
|
|
|
---
|
|
|
|
## Operations
|
|
|
|
Read the phase files for full protocol:
|
|
|
|
| Operation | Trigger | Phase File |
|
|
|-----------|---------|------------|
|
|
| **Setup** | "set up a wiki about X" | [phases/setup.md](phases/setup.md) |
|
|
| **Ingest** | "ingest this", "add this article" | [phases/ingest.md](phases/ingest.md) |
|
|
| **Query** | "what does my wiki say about X" | [phases/query.md](phases/query.md) |
|
|
| **Lint** | "lint the wiki", "health check" | [phases/lint.md](phases/lint.md) |
|
|
|
|
---
|
|
|
|
## Setup (Quick Reference)
|
|
|
|
When asked to set up a new wiki:
|
|
|
|
```bash
|
|
# 1. Create vault structure
|
|
mkdir -p ~/wikis/<topic>/{raw/assets,wiki/{sources,concepts,entities},tools}
|
|
cd ~/wikis/<topic>
|
|
git init
|
|
printf ".obsidian/workspace.json\n.DS_Store\n.firecrawl/\n" >> .gitignore
|
|
```
|
|
|
|
Then write these files (use templates):
|
|
- `CLAUDE.md` — from [templates/CLAUDE.md.template](templates/CLAUDE.md.template)
|
|
- `wiki/index.md` — from [templates/index.md.template](templates/index.md.template)
|
|
- `wiki/log.md` — from [templates/log.md.template](templates/log.md.template)
|
|
- `wiki/overview.md` — from [templates/overview.md.template](templates/overview.md.template)
|
|
|
|
Then open the vault:
|
|
```bash
|
|
obsidian ~/wikis/<topic>
|
|
```
|
|
|
|
---
|
|
|
|
## Ingest (Quick Reference)
|
|
|
|
When asked to ingest a source:
|
|
|
|
```bash
|
|
# If URL: scrape it first
|
|
firecrawl scrape "<url>" -o raw/<slug>.md
|
|
|
|
# If file already in raw/: proceed directly
|
|
```
|
|
|
|
Then:
|
|
1. Read `wiki/index.md` to find related existing pages
|
|
2. Write `wiki/sources/<slug>.md` — structured summary
|
|
3. Update up to 15 related concept/entity pages
|
|
4. Update `wiki/index.md` — add new entry
|
|
5. Append to `wiki/log.md`
|
|
|
|
---
|
|
|
|
## Query (Quick Reference)
|
|
|
|
When asked a question about wiki content:
|
|
|
|
1. Read `wiki/index.md` — identify relevant pages by scanning summaries
|
|
2. Read 3-7 most relevant pages (parallel `Read` calls)
|
|
3. Synthesize answer with `[[WikiLink]]` citations
|
|
4. Offer to file answer as `wiki/queries/<slug>.md`
|
|
|
|
---
|
|
|
|
## Log Format
|
|
|
|
Always use this prefix for log entries (enables `grep` parsing):
|
|
|
|
```
|
|
## [YYYY-MM-DD] ingest | Source Title
|
|
## [YYYY-MM-DD] query | Question asked
|
|
## [YYYY-MM-DD] lint | Health check pass N
|
|
```
|
|
|
|
Quick log inspection:
|
|
```bash
|
|
grep "^## \[" wiki/log.md | tail -10
|
|
grep "ingest" wiki/log.md | wc -l
|
|
```
|
|
|
|
---
|
|
|
|
## Search (when wiki grows large)
|
|
|
|
```bash
|
|
# Simple grep-based search
|
|
bash tools/search.sh "transformer architecture"
|
|
|
|
# Or use qmd for semantic search (install if needed)
|
|
# npm install -g qmd
|
|
# qmd search "transformer architecture" wiki/
|
|
```
|