Llm wiki

From seaworld008/Commonly-used-high-value-skills · View interactive version

Llm wiki is an AI agent skill from the GitHub repository seaworld008/Commonly-used-high-value-skills. Use when building, querying, ingesting sources into, or auditing an interlinked Markdown knowledge base with immutable raw sources and traceable synthesis.

How to use this skill

Skill file

Karpathy's LLM Wiki

Build and maintain a persistent, compounding knowledge base as interlinked markdown files.

Based on Andrej Karpathy's LLM Wiki pattern.

Unlike traditional RAG (which rediscovers knowledge from scratch per query), the wiki

compiles knowledge once and keeps it current. Cross-references are already there.

Contradictions have already been flagged. Synthesis reflects everything ingested.

Division of labor: The human curates sources and directs analysis. The agent

summarizes, cross-references, files, and maintains consistency.

When This Skill Activates

Use this skill when the user:

Query and lint are read-only unless persistence or repair is already authorized. Ingest and maintenance writes stay within the requested wiki scope.

Wiki Location

Location: Set via WIKI_PATH environment variable (e.g. in ${HERMES_HOME:-~/.hermes}/.env).

If unset, defaults to ~/wiki.

WIKI="${WIKI_PATH:-$HOME/wiki}"

The wiki is just a directory of markdown files — open it in Obsidian, VS Code, or

any editor. No database, no special tooling required.

Architecture: Three Layers

wiki/
├── SCHEMA.md           # Conventions, structure rules, domain config
├── index.md            # Sectioned content catalog with one-line summaries
├── log.md              # Chronological action log (append-only, rotated yearly)
├── raw/                # Layer 1: Immutable source material
│   ├── articles/       # Web articles, clippings
│   ├── papers/         # PDFs, arxiv papers
│   ├── transcripts/    # Meeting notes, interviews
│   └── assets/         # Images, diagrams referenced by sources
├── entities/           # Layer 2: Entity pages (people, orgs, products, models)
├── concepts/           # Layer 2: Concept/topic pages
├── comparisons/        # Layer 2: Side-by-side analyses
└── queries/            # Layer 2: Filed query results worth keeping

Layer 1 — Raw Sources: Immutable. The agent reads but never modifies these.

Layer 2 — The Wiki: Markdown synthesis files. Created, updated, and

cross-referenced within the authorized task scope.

Layer 3 — The Schema: SCHEMA.md defines structure, conventions, and tag taxonomy.

Resuming an Existing Wiki (CRITICAL — do this every session)

When the user has an existing wiki, always orient yourself before doing anything:

① Read SCHEMA.md — understand the domain, conventions, and tag taxonomy.

② Read index.md — learn what pages exist and their summaries.

③ Scan recent log.md — read the last 20-30 entries to understand recent activity.

WIKI="${WIKI_PATH:-$HOME/wiki}"
# Orientation reads at session start
read_file "$WIKI/SCHEMA.md"
read_file "$WIKI/index.md"
read_file "$WIKI/log.md" offset=<last 30 lines>

Only after orientation should you ingest, query, or lint. This prevents:

For large wikis (100+ pages), also run a quick search_files for the topic

at hand before creating anything new.

Initializing a New Wiki

When the user asks to create or start a wiki:

  1. Determine the wiki path (from $WIKI_PATH env var, or ask the user; default ~/wiki)
  2. Create the directory structure above
  3. Ask the user what domain the wiki covers — be specific
  4. Write SCHEMA.md customized to the domain (see template below)
  5. Write initial index.md with sectioned header
  6. Write initial log.md with creation entry
  7. Confirm the wiki is ready and suggest first sources to ingest

SCHEMA.md Template

Read the detailed procedure and examples when working on this part of the task.

index.md Template

The index is sectioned by type. Each entry is one line: wikilink + summary.

# Wiki Index

> Content catalog. Every wiki page listed under its type with a one-line summary.
> Read this first to find relevant pages for any query.
> Last updated: YYYY-MM-DD | Total pages: N

## Entities
<!-- Alphabetical within section -->

## Concepts

## Comparisons

## Queries

Scaling rule: When any section exceeds 50 entries, split it into sub-sections

by first letter or sub-domain. When the index exceeds 200 entries total, create

a _meta/topic-map.md that groups pages by theme for faster navigation.

log.md Template

# Wiki Log

> Chronological record of all wiki actions. Append-only.
> Format: `## [YYYY-MM-DD] action | subject`
> Actions: ingest, update, query, lint, create, archive, delete
> When this file exceeds 500 entries, rotate: rename to log-YYYY.md, start fresh.

## [YYYY-MM-DD] create | Wiki initialized
- Domain: [domain]
- Structure created with SCHEMA.md, index.md, log.md

Core Operations

1. Ingest

When the user provides a source (URL, file, paste), integrate it into the wiki:

① Capture the raw source:

On re-ingest of the same URL: recompute the sha256, compare to the stored value —

skip if identical; otherwise preserve the original raw file and save a new version

with its hash and capture date. Flag drift and update synthesis links within

the authorized scope; never overwrite the original raw evidence.

② Discuss takeaways with the user — what's interesting, what matters for

the domain. (Skip this in automated/cron contexts — proceed directly.)

③ Check what already exists — search index.md and use search_files to find

existing pages for mentioned entities/concepts. This is the difference between

a growing wiki and a pile of duplicates.

④ Write or update wiki pages:

in SCHEMA.md (2+ source mentions, or central to one source)

When new info contradicts existing content, follow the Update Policy.

pages via [[wikilinks]]. Check that existing pages link back.

markers to paragraphs whose claims trace to a specific source.

confidence: medium or low in frontmatter. Don't mark high unless the

claim is well-supported across multiple sources.

⑤ Update navigation:

⑥ Report what changed — list every file created or updated to the user.

A single source can trigger updates across 5-15 wiki pages. This is normal

and desired — it's the compounding effect.

2. Query

When the user asks a question about the wiki's domain:

① Read index.md to identify relevant pages.

② For wikis with 100+ pages, also search_files across all .md files

for key terms — the index alone may miss relevant content.

③ Read the relevant pages using read_file.

④ Synthesize an answer from the compiled knowledge. Cite the wiki pages

you drew from: "Based on [[page-a]] and [[page-b]]..."

⑤ File valuable answers only when persistence is authorized — a substantial

comparison, deep dive, or novel synthesis may go in queries/ or comparisons/.

Otherwise return the answer without creating pages.

⑥ Update log.md only for authorized persistence, noting whether the query was filed.

3. Lint

When the user asks to lint, health-check, or audit the wiki:

① Orphan pages: Find pages with no inbound [[wikilinks]] from other pages.

# Use execute_code for this — programmatic scan across all wiki pages
import os, re
from collections import defaultdict
wiki = "<WIKI_PATH>"
# Scan all .md files in entities/, concepts/, comparisons/, queries/
# Extract all [[wikilinks]] — build inbound link map
# Pages with zero inbound links are orphans

② Broken wikilinks: Find [[links]] that point to pages that don't exist.

③ Index completeness: Every wiki page should appear in index.md. Compare

the filesystem against index entries.

④ Frontmatter validation: Every wiki page must have all required fields

(title, created, updated, type, tags, sources). Tags must be in the taxonomy.

⑤ Stale content: Pages whose updated date is >90 days older than the most

recent source that mentions the same entities.

⑥ Contradictions: Pages on the same topic with conflicting claims. Look for

pages that share tags/entities but state different facts. Surface all pages

with contested: true or contradictions: frontmatter for user review.

⑦ Quality signals: List pages with confidence: low and any page that cites

only a single source but has no confidence field set — these are candidates

for either finding corroboration or demoting to confidence: medium.

⑧ Source drift: For each file in raw/ with a sha256: frontmatter, recompute

the hash and flag mismatches. Mismatches indicate the raw file was edited

(shouldn't happen — raw/ is immutable) or ingested from a URL that has since

changed. Not a hard error, but worth reporting.

⑨ Page size: Flag pages over 200 lines — candidates for splitting.

⑩ Tag audit: List all tags in use, flag any not in the SCHEMA.md taxonomy.

⑪ Log rotation: Report when log.md exceeds 500 entries; rotate only within authorized maintenance.

⑫ Report findings with specific file paths and suggested actions, grouped by

severity (broken links > orphans > source drift > contested pages > stale content > style issues).

⑬ Log only if authorized: Append ## [YYYY-MM-DD] lint | N issues found only when persistence is in scope; otherwise include findings in the response.

Working with the Wiki

Searching

# Find pages by content
search_files "transformer" path="$WIKI" file_glob="*.md"

# Find pages by filename
search_files "*.md" target="files" path="$WIKI"

# Find pages by tag
search_files "tags:.*alignment" path="$WIKI" file_glob="*.md"

# Recent activity
read_file "$WIKI/log.md" offset=<last 20 lines>

Bulk Ingest

When ingesting multiple sources at once, batch the updates:

  1. Read all sources first
  2. Identify all entities and concepts across all sources
  3. Check existing pages for all of them (one search pass, not N)
  4. Create/update pages in one pass (avoids redundant updates)
  5. Update index.md once at the end
  6. Write a single log entry covering the batch

Archiving

When content is fully superseded or the domain scope changes:

  1. Create _archive/ directory if it doesn't exist
  2. Move the page to _archive/ with its original path (e.g., _archive/entities/old-page.md)
  3. Remove from index.md
  4. Update any pages that linked to it — replace wikilink with plain text + "(archived)"
  5. Log the archive action

Obsidian Integration

The wiki directory works as an Obsidian vault out of the box:

For best results:

If using the Obsidian skill alongside this one, set OBSIDIAN_VAULT_PATH to the

same directory as the wiki path.

Obsidian Headless (servers and headless machines)

On machines without a display, use obsidian-headless instead of the desktop app.

It syncs vaults via Obsidian Sync without a GUI — perfect for agents running on

servers that write to the wiki while Obsidian desktop reads it on another device.

Setup:

# Requires Node.js 22+
npm install -g obsidian-headless

# Login (requires Obsidian account with Sync subscription)
ob login --email <email> --password '<password>'

# Create a remote vault for the wiki
ob sync-create-remote --name "LLM Wiki"

# Connect the wiki directory to the vault
cd ~/wiki
ob sync-setup --vault "<vault-id>"

# Initial sync
ob sync

# Continuous sync (foreground — use systemd for background)
ob sync --continuous

Continuous background sync via systemd:

# ~/.config/systemd/user/obsidian-wiki-sync.service
[Unit]
Description=Obsidian LLM Wiki Sync
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/path/to/ob sync --continuous
WorkingDirectory=%h/wiki
Restart=on-failure
RestartSec=10

[Install]
WantedBy=default.target
systemctl --user daemon-reload
systemctl --user enable --now obsidian-wiki-sync
# Enable linger so sync survives logout:
sudo loginctl enable-linger $USER

This lets the agent write to ~/wiki on a server while you browse the same

vault in Obsidian on your laptop/phone — changes appear within seconds.

Pitfalls

Skipping this causes duplicates and missed cross-references.

provenance consistent. Read-only query/lint requests do not write either file.

appearing once in a footnote doesn't warrant an entity page.

link to at least 2 other pages.

first, then use them.

200 lines. Move detailed analysis to dedicated deep-dive pages.

the scope with the user first.

rename it log-YYYY.md and start fresh. Read-only lint reports the need without rotating.

mark in frontmatter, flag for user review.

Related Tools

llm-wiki-compiler is a Node.js CLI that

compiles sources into a concept wiki with the same Karpathy inspiration. It's Obsidian-compatible,

so users who want a scheduled/CLI-driven compile pipeline can point it at the same vault this

skill maintains. Trade-offs: it owns page generation (replaces the agent's judgment on page

creation) and is tuned for small corpora. Use this skill when you want agent-in-the-loop curation;

use llmwiki when you want batch compile of a source directory.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.