Use an LLM to build and maintain a personal knowledge base. You manage two directories:raw/(immutable sources) and compiled knowledge pages (wiki/ topic directory, or this project's entities/ / concepts/ / synthesis/ etc.). Sources enter raw/, then are compiled into articles; the wiki compounds and grows over time.
Karpathy's core point:
- "The LLM writes and maintains the wiki; humans read and ask questions."
- "The wiki is a persistent, compounding artifact."
For operationalized practice, see astro-han/karpathy-llm-wiki; for the philosophy, see Karpathy gist and LLM Wiki Architecture。
Standard commands
| Command | Behavior |
|---|---|
加入 wiki:… |
Ingest |
关于 X 我知道什么 |
Query (does not write files by default) |
lint wiki |
Lint (prioritize running scripts/lint-wiki.sh) |
本周回顾 / 本月回顾 |
Operational review, see references/ops-loop.md |
Jot quick notes into raw/inbox/, then ingest. For channel-based ingestion, see references/source-adapters.md。
Architecture
Three layers, all under the user's project root (or the resolved wiki root):
raw/ — immutable sources (inbox/ except movable). Type layout recommends subdirectories:inbox/ articles/ papers/ transcripts/ notes/ git/ lark/ mail/ meeting/ assets/。
Compiled knowledge layer — you have full write permissions. Two compatible layouts (follow the existing SCHEMA.md / directory, do not force migration):
- Topic layout(consistent with the reference repository):
wiki/<topic>/<article>.md, only one level of topic subdirectories. - Type layout(this repository PersonalWiki):
entities/concepts/comparisons/queries/synthesis/, plus_archive/。
special files (in the wiki root, i.e. under topic layout within wiki/ ):
index.md— global index: one line per article, grouped by topic/type, with link + summary + Updated.log.md— append-only operation log (## [YYYY-MM-DD] <action> | <主题>)。
SCHEMA.md / this SKILL.md — conventions layer: structure and workflow rules. This project's durable wiki is in PersonalWiki/; documentation defaults to Chinese.
Templates are in the path relative to this file: references/. Deterministic scripts:scripts/init-wiki.sh、lint-wiki.sh、new-raw.sh、rehash-raw.sh。
Initialization
Triggered by default on the first Ingest. Check whetherFirst Ingest triggers. Check whether raw/ and the compiled knowledge layer exist; create only missing items, never overwrite existing files.
Available startup scripts (this skill is recommended):
bash "${SKILL_DIR}/scripts/init-wiki.sh" "$WIKI" "$DOMAIN"
printf '%s\n' "$WIKI" > "$HOME/.llm-wiki"
Minimal manual setup (topic layout):
raw/(may contain.gitkeep)wiki/(may contain.gitkeep)wiki/index.md— title# Knowledge Base Index/# Wiki 索引, body may be emptywiki/log.md— title# Wiki Log/# Wiki 日志, body may be empty
Wiki root resolution: user explicit path > WIKI_PATH > ~/.llm-wiki > current directory (already has index.md + log.md and exists raw/ or SCHEMA.md)> ~/wiki。
If Query / Lint cannot find the wiki structure: tell the user "run ingest once first to initialize the wiki", do not create it automatically. Do not initialize a non-empty and unrelated directory unless the user approves.
Ingest
Fetch sources into raw/, then compile into the knowledge layer.Both steps must be done, no exceptions.
Fetch(raw/)
-
Use the web/file tools provided by the environment to obtain content; if inaccessible, ask the user to paste it.
-
Choose a topic directory: first reuse an existing
raw/subdirectory; create a new one only when the topic is genuinely different. -
Save as
raw/<topic>/YYYY-MM-DD-descriptive-slug.md。- slug from the title, kebab-case, max 60 characters.
- Publication date unknown → the filename may omit the date prefix; metadata
Publishedis still written, with the valueUnknown。 - If the name is duplicated, add a
-2、-3suffix. - Metadata: source URL, Collected, Published; if
SCHEMA.mdrequires it, also add YAML frontmatter and bodysha256。 - Faithfully preserve the original text; clean up formatting noise; do not rewrite opinions.
For the format, see references/raw-template.md. For per-channel fields and cleaning rules, see references/source-adapters.md. Available
bash "${SKILL_DIR}/scripts/new-raw.sh" "$WIKI" <source-type> "标题"to generate a skeleton.
Compile (knowledge page)
Determine where the new content belongs:
- Same core thesis as an existing article → merge into that article; add the new source to Sources/Raw; update the affected sections.
- New concept → create a new article in the most relevant topic (or type) directory; use the concept name for the filename, not the raw filename.
- Spans multiple topics → place it in the most relevant directory; use See Also /
[[wikilink]]to cross-link.
The above can coexist: a single source can "merge into one article + create another article." Always check for factual conflicts: mark the source at contradictions; when merging, write it within that article; if they belong to two articles, note it in both and cross-link them.
For the article format, see references/article-template.md. Key points:
- Sources: author/organization/publication + date, separated by semicolons.
- Raw: a markdown link pointing to
raw/(or frontmattersources), separated by semicolons. - Under a topic layout, the relative path starting from
wiki/<topic>/is../../raw/<topic>/<file>.md。
Cascade Updates
After the main article, check for ripples:
- Scan the affected articles in the same topic (or same type) directory.
- Scan
index.mdfor related entries in other topics. - Update all articles whose content is substantively affected, and refresh their Updated.
Archive pages are never cascade-updated(point-in-time snapshots). When the change set is unspecified, do not blindly modify 10+ pages.
Post-Ingest
Update index.md: add or modify an entry for each touched article; add a one-line description for a new topic section. Updated = the date of the last substantive change to the knowledge content, not the filesystem mtime. For the format, see references/index-template.md。
Append log.md:
## [YYYY-MM-DD] ingest | <主文章标题>
- Updated: <级联更新的文章标题>
- Updated: <另一篇>
If there is no cascade, omit the - Updated: line.
Batch ingestion: first read all sources, identify shared concepts, then compile in batches.
Query
Search the wiki and answer. Trigger examples:
- "What do I know about X?"
- "Summarize everything related to Y"
- "Compare A and B based on my wiki"
Steps
- Read
index.mdto locate relevant articles; if there isSCHEMA.md, read it as well. - Read these articles and synthesize an answer.
- Prioritize wiki content, not training priors. Citations in conversation:
[文章标题](wiki/topic/article.md)or[[文章标题]](project-root-relative paths are used in conversation; within wiki files, use paths relative to the current file / wikilinks). - The answer is output in the conversation.Do not write files unless asked.
Archiving
Only when the user explicitly asks to archive or save the answer to the wiki:
-
Write it as a new wiki page. See references/archive-template.md. Rewrite project-root-relative paths in the dialogue as file-relative paths (use the filename for the same directory; for cross-topic use
../topic/file.md) or[[wikilink]]。- Sources: points to the wiki articlecited by the answer (not raw).
- No Raw field。
- Filename reflects the query topic, e.g.
transformer-architectures-overview.md。 - Placed in the most relevant topic directory (or this project's
queries/)。
-
Always create a new page. Never merge archived Q&A into an existing article.
-
Update
index.md; Summary prefix[Archived]or[归档]。 -
Append
log.md:## [YYYY-MM-DD] query | Archived: <page title>
Do not archive trivial queries.
Lint
Quality check. The two categories have different permissions.
Deterministic Checks (auto-fix)
Run first:
bash "${SKILL_DIR}/scripts/lint-wiki.sh" "$WIKI"
The script covers missing index entries/broken links, required frontmatter fields on knowledge pages, wikilinks, raw references, and orphan-page heuristics. The Agent is still responsible for heuristic items such as conflicts and outdated claims.
Index consistency — Compare index.md with the actual knowledge page files (excluding index.md、log.md、SCHEMA.md):
- File exists but is not in the index → add an entry, with summary
(no summary)/(无摘要); for Updated prefer in-file metadata, otherwise use mtime. - Index points to a nonexistent file → mark
[MISSING]/[缺失]; do not delete entries on your own.
Internal links — Check links / [[wikilink]]in the knowledge page body and Sources (the Raw field is validated by the next item; index/log is handled by the previous item):
- Target does not exist → search the knowledge layer by the same name.
- Exactly one match → change the path/link.
- Zero or multiple → report to the user.
Raw references — Raw / sources Every link in raw/ pointing to
- Does not exist → search
raw/by the same name; if there is a unique match, change the path; otherwise report.
See Also — Within each topic/type directory:
- Add obviously missing cross-references to related articles.
- Remove links pointing to deleted files.
Heuristic Checks (report only)
- Cross-article factual contradictions; source disagreements lacking a conflict annotation
- Outdated claims superseded by an updated source
- Orphan pages with no inbound links
- Missing cross-topic references
- Concepts mentioned frequently but lacking a standalone page
- Source articles cited by an archived page have been substantively updated since archiving
- (if frontmatter is used)
confidence: low/contested: true/ non-emptycontradictions
Post-Lint
## [YYYY-MM-DD] lint | <N> issues found, <M> auto-fixed
Conventions
- Standard Markdown; links use relative paths within a file, or this project's agreed
[[wikilink]]。 - Topic layout:
wiki/Only one level of topic subdirectories, no further nesting. - Log / Collected / Archived use the current date; Updated = the date the knowledge content substantively changed; Published comes from the source (if unknown,
Unknown)。 - Dialogue references use project-root-relative paths; within wiki files use paths relative to the current file.
- Ingest updates
index.md+log.md. Archive (from Query) updates both. Lint updateslog.md(only changesindex.mdwhen auto-fixing the index). Pure Query writes no files. - Prefer fewer but stronger pages; preserve uncertainty, and do not erase old contradictions with the latest view.
- The full conventions are governed by that wiki's
SCHEMA.md(if it exists).
Reference template
| File | Purpose |
|---|---|
| references/raw-template.md | Immutable source |
| references/source-adapters.md | Blog/PDF/conversation/Git/Feishu email meeting adaptation |
| references/ops-loop.md | Passwords, inbox, weekly/monthly review |
| references/article-template.md | Compiled knowledge articles |
| references/archive-template.md | Query archive (point-in-time snapshot) |
| references/index-template.md | Global index |
| references/log-template.md | Operation log |
| references/entity-template.md etc. | Type-specific layout page |