LLM Wiki
Build and maintain a persistent Markdown knowledge network instead of rediscovering the same project facts from raw documents in every session. Follow the pattern described by Karpathy's LLM Wiki, while letting each repository define its own schema and privacy boundary.
Preserve the knowledge boundary
- Treat raw sources as immutable. Add a new source or correction record instead of rewriting history.
- Treat the Wiki as synthesized project knowledge, not as a dump of chats, logs, task todos, or copied documents.
- Treat the Wiki-local agent instruction file (
AGENTS.md for Codex, CLAUDE.md for Claude Code) as its schema: topology, naming, required metadata, and maintenance rules.
- Keep active task state in the task Spec. Promote only verified, reusable, repository-appropriate knowledge.
- Keep credentials, private messages, user preferences, system memory, production payloads, and personal paths out of shared project knowledge.
- Persist only repository-relative paths, sanitized logical aliases, or content hashes in Wiki pages and maintenance logs. Keep machine-local absolute paths in the uncommitted task baseline only.
- Confirm the target repository accepts Wiki writes before modifying it. A useful finding does not by itself authorize a commit.
Read wiki-contract.md whenever deciding where information belongs or how pages must be structured.
Select one operation
| Operation |
Result |
init |
Create a new Wiki schema, indexes, log, inbox, and initial sections |
inbox |
Stage material for later compilation without treating it as accepted knowledge |
ingest |
Compile one or more sources into pages, links, indexes, provenance, and log entries |
query |
Answer from the Wiki with concrete page paths and freshness caveats |
lint |
Audit health without modifying the Wiki; finish clean or completed-with-findings |
lint-fix |
Repair authorized findings, validate the result, and record the maintenance operation |
restructure |
Change topology without losing links, history, or source attribution |
Do not combine a broad restructure with unrelated content ingestion unless the user explicitly requests both.
Run the control loop
- Read the repository instructions, the Wiki-local agent instruction file, root
index.md, and the smallest relevant section indexes.
- State the requested operation, target root, source root, read or write scope, privacy boundary, and completion evidence.
- For a write operation, record the repository baseline, dirty and untracked state, expected files, and initial hashes. Stop on overlapping user changes.
- Inspect current pages before adding content. Reuse or update existing concepts instead of creating near-duplicates.
- Preserve raw material and source attribution.
- Make the smallest coherent set of edits. Re-read a shared index, map, or log immediately before writing it and stop on baseline drift.
- Validate pages, links, metadata, provenance, privacy, and the exact diff before appending a completed maintenance log entry.
- Report what changed, which sources support it, what remains uncertain, and whether any knowledge candidate was intentionally not synced.
Read the Write baseline gate in maintenance-guide.md before any operation that changes Wiki or inbox files.
Initialize
Confirm the Wiki root and immutable source root, then read init-guide.md. Create only sections justified by the current project; avoid empty taxonomies copied from examples.
Minimum initialization evidence:
- The Wiki-local agent instruction file defines the three layers and maintenance rules.
README.md, index.md, log.md, and inbox/ exist.
- Each initial section has an
index.md.
- Links resolve and content pages satisfy the metadata contract.
Stage inbox material
Add a recognizable source note to inbox/ without rewriting it into project truth. Attach the required intake fields for capture time, origin, owner, intent, target, and status. Do not update indexes or claim ingestion until the full ingest operation completes.
Read the Inbox section of maintenance-guide.md before moving or deleting staged material.
Ingest
Compile source material into the smallest set of existing or new pages that preserves meaning and provenance. Reconcile contradictions explicitly; do not silently replace an older conclusion.
An ingest is complete only when pages, section indexes, the global index, cross-links, optional provenance maps, and log.md agree. Read maintenance-guide.md for the full quality gate.
Query
Start from index.md, follow only relevant pages and their links, and cite concrete repository paths in the answer. Name the date or freshness limit for time-sensitive facts. If the Wiki does not cover the question, say so instead of filling the gap from assumption.
Propose new synthesis as an ingest candidate. Do not mutate the Wiki during a read-only query unless the request also authorizes maintenance.
Lint, repair, or restructure
Treat lint as report-only by default. Read maintenance-guide.md, run the checks that fit the repository, and finish as clean, completed-with-findings, or blocked. Do not repair files or append log.md unless the user or repository also authorizes maintenance writes.
For lint-fix or restructure, apply the write baseline gate, change only the authorized files, validate first, and append a completed log entry last. Preserve redirects or update all inbound links when moving pages. Unresolved findings may remain after a completed audit; they block a repair operation only when its Done Contract requires them to be fixed.
Stop conditions
Stop and report the exact gap when:
- the Wiki root, source root, schema, or write authority is unclear;
- source material contains secrets, private identities, production data, or content unsuitable for the target repository;
- a proposed page conflicts with verified knowledge and the contradiction cannot be resolved from available sources;
- an expected write target already contains overlapping dirty changes or changes after its baseline hash was recorded;
- moving or deleting an inbox or raw-source file could lose the only copy;
- a restructure would break inbound links that cannot be enumerated;
- validation cannot distinguish the new Wiki state from stale or unrelated content.
Reference map
- wiki-contract.md: knowledge layers, information boundaries, topology, naming, metadata, links, and provenance.
- init-guide.md: initialization sequence, minimum directory shape, and schema template.
- maintenance-guide.md: inbox, ingest, query, lint, validation commands, and common failure modes.
1---2name: llm-wiki3description: Maintain a Git-native, LLM-curated project knowledge base that compounds across tasks. Use when initializing or restructuring a project Wiki, staging source material in an inbox, ingesting verified documents into cross-linked Markdown, querying project knowledge with source paths, promoting reusable findings from engineering work, or linting indexes, metadata, provenance, links, and stale content. Keep transient task state and private memory outside the Wiki.4---56# LLM Wiki78Build and maintain a persistent Markdown knowledge network instead of rediscovering the same project facts from raw documents in every session. Follow the pattern described by [Karpathy's LLM Wiki](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f), while letting each repository define its own schema and privacy boundary.910## Preserve the knowledge boundary1112- Treat raw sources as immutable. Add a new source or correction record instead of rewriting history.13- Treat the Wiki as synthesized project knowledge, not as a dump of chats, logs, task todos, or copied documents.14- Treat the Wiki-local agent instruction file (`AGENTS.md` for Codex, `CLAUDE.md` for Claude Code) as its schema: topology, naming, required metadata, and maintenance rules.15- Keep active task state in the task Spec. Promote only verified, reusable, repository-appropriate knowledge.16- Keep credentials, private messages, user preferences, system memory, production payloads, and personal paths out of shared project knowledge.17- Persist only repository-relative paths, sanitized logical aliases, or content hashes in Wiki pages and maintenance logs. Keep machine-local absolute paths in the uncommitted task baseline only.18- Confirm the target repository accepts Wiki writes before modifying it. A useful finding does not by itself authorize a commit.1920Read [wiki-contract.md](references/wiki-contract.md) whenever deciding where information belongs or how pages must be structured.2122## Select one operation2324| Operation | Result |25|---|---|26| `init` | Create a new Wiki schema, indexes, log, inbox, and initial sections |27| `inbox` | Stage material for later compilation without treating it as accepted knowledge |28| `ingest` | Compile one or more sources into pages, links, indexes, provenance, and log entries |29| `query` | Answer from the Wiki with concrete page paths and freshness caveats |30| `lint` | Audit health without modifying the Wiki; finish clean or completed-with-findings |31| `lint-fix` | Repair authorized findings, validate the result, and record the maintenance operation |32| `restructure` | Change topology without losing links, history, or source attribution |3334Do not combine a broad restructure with unrelated content ingestion unless the user explicitly requests both.3536## Run the control loop37381. Read the repository instructions, the Wiki-local agent instruction file, root `index.md`, and the smallest relevant section indexes.392. State the requested operation, target root, source root, read or write scope, privacy boundary, and completion evidence.403. For a write operation, record the repository baseline, dirty and untracked state, expected files, and initial hashes. Stop on overlapping user changes.414. Inspect current pages before adding content. Reuse or update existing concepts instead of creating near-duplicates.425. Preserve raw material and source attribution.436. Make the smallest coherent set of edits. Re-read a shared index, map, or log immediately before writing it and stop on baseline drift.447. Validate pages, links, metadata, provenance, privacy, and the exact diff before appending a completed maintenance log entry.458. Report what changed, which sources support it, what remains uncertain, and whether any knowledge candidate was intentionally not synced.4647Read the Write baseline gate in [maintenance-guide.md](references/maintenance-guide.md) before any operation that changes Wiki or inbox files.4849## Initialize5051Confirm the Wiki root and immutable source root, then read [init-guide.md](references/init-guide.md). Create only sections justified by the current project; avoid empty taxonomies copied from examples.5253Minimum initialization evidence:5455- The Wiki-local agent instruction file defines the three layers and maintenance rules.56- `README.md`, `index.md`, `log.md`, and `inbox/` exist.57- Each initial section has an `index.md`.58- Links resolve and content pages satisfy the metadata contract.5960## Stage inbox material6162Add a recognizable source note to `inbox/` without rewriting it into project truth. Attach the required intake fields for capture time, origin, owner, intent, target, and status. Do not update indexes or claim ingestion until the full ingest operation completes.6364Read the Inbox section of [maintenance-guide.md](references/maintenance-guide.md) before moving or deleting staged material.6566## Ingest6768Compile source material into the smallest set of existing or new pages that preserves meaning and provenance. Reconcile contradictions explicitly; do not silently replace an older conclusion.6970An ingest is complete only when pages, section indexes, the global index, cross-links, optional provenance maps, and `log.md` agree. Read [maintenance-guide.md](references/maintenance-guide.md) for the full quality gate.7172## Query7374Start from `index.md`, follow only relevant pages and their links, and cite concrete repository paths in the answer. Name the date or freshness limit for time-sensitive facts. If the Wiki does not cover the question, say so instead of filling the gap from assumption.7576Propose new synthesis as an ingest candidate. Do not mutate the Wiki during a read-only query unless the request also authorizes maintenance.7778## Lint, repair, or restructure7980Treat `lint` as report-only by default. Read [maintenance-guide.md](references/maintenance-guide.md), run the checks that fit the repository, and finish as `clean`, `completed-with-findings`, or `blocked`. Do not repair files or append `log.md` unless the user or repository also authorizes maintenance writes.8182For `lint-fix` or `restructure`, apply the write baseline gate, change only the authorized files, validate first, and append a completed log entry last. Preserve redirects or update all inbound links when moving pages. Unresolved findings may remain after a completed audit; they block a repair operation only when its Done Contract requires them to be fixed.8384## Stop conditions8586Stop and report the exact gap when:8788- the Wiki root, source root, schema, or write authority is unclear;89- source material contains secrets, private identities, production data, or content unsuitable for the target repository;90- a proposed page conflicts with verified knowledge and the contradiction cannot be resolved from available sources;91- an expected write target already contains overlapping dirty changes or changes after its baseline hash was recorded;92- moving or deleting an inbox or raw-source file could lose the only copy;93- a restructure would break inbound links that cannot be enumerated;94- validation cannot distinguish the new Wiki state from stale or unrelated content.9596## Reference map9798- [wiki-contract.md](references/wiki-contract.md): knowledge layers, information boundaries, topology, naming, metadata, links, and provenance.99- [init-guide.md](references/init-guide.md): initialization sequence, minimum directory shape, and schema template.100- [maintenance-guide.md](references/maintenance-guide.md): inbox, ingest, query, lint, validation commands, and common failure modes.