A persistent, compounding personal knowledge base. The wiki grows richer with every source you ingest and every question you answer. Unlike RAG, knowledge is compiled once and kept current — not re-derived on every query.
Based on Karpathy's LLM Wiki pattern: https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f
Directory Structure
All wiki files live in wiki/ inside the workspace ($WIKI_DIR, defaults to ./wiki/ if not set):
wiki/
├── index.md ← catalog of all pages (update on every ingest)
├── log.md ← append-only chronological record of operations
├── raw/ ← source documents (immutable — read only, never modify)
└── pages/ ← LLM-maintained wiki pages (you own this layer entirely)
On first use, create this structure if it doesn't exist.
$SKILL_DIR in script commands means this skill's installed directory. If your agent does not set it automatically, replace it with the path to this llm-wiki directory before running commands.
Page Conventions
Every page in wiki/pages/ should follow this format:
---
title: Page Title
tags: [tag1, tag2]
sources: 0
last-updated: YYYY-MM-DD
---
# Page Title
[body content]
## See also
- [Related Page](related-page.md)
- Filename: lowercase slug, e.g.
machine-learning-basics.md - Always include a
## See alsosection with cross-links to related pages - Update
sources:count when a new source touches this page - Update
last-updated:on every edit
Operations
List the wiki
When the user asks to list, show, or browse their wiki — e.g. "list your wikis", "list my wiki", "list wiki pages", "what's in my wiki", "show my notes":
- Run:
python3 "$SKILL_DIR/scripts/list.py"(add--tag TAGor--sort updatedif the user narrows it) - Present the returned pages as a readable table (title, tags, sources, last-updated).
- If the script returns an empty array
[], the wiki has no pages yet — say so and offer to start one (do not describe the directory layout as if it were the answer).
Do not answer this request by paraphrasing the Directory Structure section — always run list.py and report the actual pages.
Ingest a source
When the user asks you to ingest or process a source document:
- Read the source from
wiki/raw/<filename>(or from a URL/path the user provides) - Discuss key takeaways with the user if needed
- Write a summary page:
wiki/pages/<slug>-source.md - Update
wiki/index.md— add the new page entry - Identify related existing pages and update them (cross-references, new info, contradictions)
- A single source typically touches 5–15 pages
- Note explicitly when new data contradicts an existing claim
- Append to log:
python3 "$SKILL_DIR/scripts/log.py" ingest "<Source Title>" "<brief notes>"
Query the wiki
When the user asks about a topic you've been researching:
- Search for relevant pages:
python3 "$SKILL_DIR/scripts/search.py" "<query>" - Read the returned pages (highest-score first)
- If
index.mdexists and search returns nothing, readindex.mdto browse manually - Synthesize an answer with citations (page filenames)
- If the answer is non-trivial and reusable, file it back as a new page in
wiki/pages/ - Append to log:
python3 "$SKILL_DIR/scripts/log.py" query "<query summary>" "<key finding>"
Lint the wiki
When the user asks you to health-check or lint the wiki:
- Run:
python3 "$SKILL_DIR/scripts/lint.py" - For each issue reported:
- orphan: page has no inbound links — add cross-links from related pages, or mention in index
- missing: listed in index.md but file doesn't exist — remove from index or recreate
- unlisted: file exists but not in index.md — add it to index
- Read through several pages for contradictions and stale claims
- Append to log:
python3 "$SKILL_DIR/scripts/log.py" lint "Lint pass" "<summary of fixes>"
index.md Format
# Wiki Index
> Last updated: YYYY-MM-DD | Pages: N | Sources: N
## [Category Name]
| Page | Summary | Tags | Updated |
|------|---------|------|---------|
| [Page Title](pages/page-slug.md) | One-line summary | tag1, tag2 | YYYY-MM-DD |
Organize pages by category. Update on every ingest.
log.md Format
## [YYYY-MM-DD] ingest | Source Title
Notes about what was ingested and key pages updated.
## [YYYY-MM-DD] query | Query Summary
Key finding: ...
## [YYYY-MM-DD] lint | Lint pass
Fixed N issues: ...
Scripts
# List all wiki pages with metadata (title, tags, sources, last-updated)
python3 "$SKILL_DIR/scripts/list.py" [--tag TAG] [--sort title|updated]
# Search wiki pages by keyword relevance
python3 "$SKILL_DIR/scripts/search.py" "<query>" [--top N]
# Health-check the wiki (orphans, missing files, unlisted pages)
python3 "$SKILL_DIR/scripts/lint.py"
# Append a log entry
python3 "$SKILL_DIR/scripts/log.py" <ingest|query|lint> "<title>" ["<notes>"]
Environment Variables
WIKI_DIR— path to the wiki directory (default:./wiki/). Set this to your preferred persistent location.
Tips
- File answers back: A good analysis you synthesized is a new wiki page — don't let it disappear into chat history
- Contradictions matter: When new info contradicts old, update both pages and note the conflict explicitly
- Prefer wiki over web searches: For topics the user has been researching, the wiki has curated, synthesized knowledge. Use it first.
- Raw sources are immutable: Never modify files in
wiki/raw/— they are the source of truth