Turn fragmented information into a continuously accumulating, interlinked knowledge base. Knowledge is compiled once and continuously maintained; it is not re-derived from the original documents on every query.
Core Philosophy
The problem with traditional RAG: every time a question is asked, the AI reads the original files from scratch, with no accumulation. The value of a knowledge base lies incompile once, continuously maintain—you only need to provide the material, and the AI does all the organizing work.
Mindset
When handling any request, first run through three judgments in your head:
- Judge the value of the material: Is this piece of information worth keeping permanently? Worth it → process fully; not worth it but has key concepts → process in simplified form; pure noise → skip
- Judge the depth of processing: Is the material a 10,000-word in-depth article or a 200-word fragment? The former requires extracting entities, linking topic pages, and generating a summary; the latter only requires recording key concepts
- Judge the strength of the association: Is the concept in the new material the same thing as an existing entity, or does it just happen to share the same name? High-value association → merge into the existing entity page; weak association → mark it on the material page
[待创建]
Tool Selection Framework
flowchart TD
A[用户请求] --> B{知识库存在?}
B -->|否| C[→ init]
B -->|是| D{请求类型?}
D -->|URL/文件/粘贴文本| E[→ ingest]
D -->|疑问句/定义/查询| F[→ query]
D -->|综述/深度分析/对比| G[→ digest]
D -->|健康检查/lint| H[→ lint]
D -->|状态/统计/有什么| I[→ status]
D -->|图谱/关联图| J[→ graph]
E --> K{素材类型?}
K -->|> 1000字| L[完整处理:实体+主题+摘要]
K -->|≤ 1000字| M[简化处理:摘要+标记待创建]
F --> N[先读 index → search.py 搜索 → 综合回答]
G --> O[读 index → search.py 全量搜索 → 生成深度报告]
Fallback rule: If a URL/file is given directly but it is not said what to do with it → default to ingest. If no related content can be found → suggest adding more material.
Boundaries and Pitfalls
When the knowledge base gets large, the index will become outdated. index.md is a manually maintained directory, and once there are many wiki pages it will inevitably miss some. Not finding something does not mean it is not in the knowledge base—the query workflow must check both the index and use search.py for full-text search, and must not only look at the index.
[[双向链接]] does not represent a semantic association. Two pages linking to each other may simply be because they happen to mention the same word (for example, "model" has completely different meanings in ML and in fashion). When associating entity pages, judging "whether it is the same thing" is far more important than "whether this word is mentioned".
Short material may also contain high-value concepts. A 200-word tweet may contain an entirely new framework/term and be worth creating an entity page for. Do not use word count as the sole criterion for "whether it is worth processing in depth"—concept density is more important than word count.
Accumulated Experience
references/source-patterns/ The directory stores processing experience for different material sources. When the AI hits pitfalls or discovers a better extraction strategy while processing a certain type of source (such as WeChat public accounts, Twitter, PDF papers), append the experience to the corresponding file.
- Existing experience files: named by material source domain, such as
mp.weixin.qq.com.md、twitter.com.md - When processing a new source for the first time, create an experience file recording "the page structure characteristics of this site" and "points to note during extraction"
These experience files will be automatically read during subsequent ingests of the same source, helping the AI extract knowledge more precisely.
Script Directory
Scripts located in scripts/ subdirectory (Python 3.10+, zero external dependencies).
SKILL_DIR = this SKILL.md's directory. Script path = ${SKILL_DIR}/scripts/<script-name>.
Cross-platform compatibility: all scripts use
pathlib.Path, compatible with Windows/Linux/macOS. When invoking, uniformly usepython3(Linux/macOS) orpython(Windows), choosing according to the current environment.
Multi-platform Skill Directories
| Platform | Skill installation path |
|---|---|
| WorkBuddy | ~/.workbuddy/skills/my-wiki/ |
| Claude Code | ~/.claude/skills/my-wiki/ |
| OpenCode | ~/.config/opencode/skills/my-wiki/ |
| OpenClaw | ~/.openclaw/skills/my-wiki/ |
SKILL_DIR resolution differs by platform, but path handling inside the scripts is fully cross-platform. If the platform does not support the
{SKILL_DIR}variable, you can use the__FILE__equivalent mechanism to get the directory where the current SKILL.md is located.
General Pre-check
Except for init , other workflows first execute:
- Check whether the current working directory has
.wiki-schema.md→ if yes, use the current directory - No → read
{SKILL_DIR}/wiki-config.json, getwikis[current]'s path - Neither exists → fallback check
~/.my-wiki-pathfile to get the default path (backward compatible) - Neither exists →
ingestautomatically runs init first; other workflows prompt the user to initialize first
Workflow 1: init (Initialize Knowledge Base) [PROCEDURE]
- Ask for the topic: "What is the knowledge base about? For example, 'AI study notes', 'DevOps practices'"
- Ask for the path: default
~/Documents/my-wiki/, user can customize - Ask for the name: "Give this knowledge base a name for easy switching? For example, 'devops', 'reading'. If left blank, the directory name will be used."
- Run the script:
python {SKILL_DIR}/scripts/init.py --wiki-root "<路径>" --topic "<主题>" --name "<名称>" - The script will automatically update
{SKILL_DIR}/wiki-config.json, recording the name, path, and topic - Output guidance: tell the user they can provide links, files, or paste text, or say "query XX" to search
wiki-config.jsonsupports multiple knowledge bases, and thecurrentfield marks the currently active knowledge base. The pre-check locates the knowledge base path based on this file.
Workflow 2: ingest (Digest Material) [MIXED]
This is the most core workflow. Use scripts for deterministic operations, and AI judgment for knowledge extraction.
Part 1: Deterministic operations [PROCEDURE]
- Execute the pre-check to determine the knowledge base path
- Call
ingest_prepare.pyto process the material:
The script outputs JSON, with key fields:# URL 类素材 python {SKILL_DIR}/scripts/ingest_prepare.py --wiki-root "<路径>" --url "<URL>" --title "<标题>" # 本地文件 python {SKILL_DIR}/scripts/ingest_prepare.py --wiki-root "<路径>" --file "<文件路径>" --title "<标题>" # 粘贴文本 python {SKILL_DIR}/scripts/ingest_prepare.py --wiki-root "<路径>" --text "<文本内容>" --title "<标题>" # 强制覆盖重复素材 python {SKILL_DIR}/scripts/ingest_prepare.py --wiki-root "<路径>" --url "<URL>" --forceis_long(whether > 1000 characters),raw_path、status - If the material is a URL → first check whether there is an experience file for that domain under
references/source-patterns/, and if so, read it; then use web tools to extract the webpage content
Part 2: AI knowledge extraction [REASONING]
Based on the is_long returned by the script, judge the processing depth, butdo not execute mechanically—use your judgment to adjust:
Full processing(is_long: true, or the material is short but has extremely high concept density):
- Extract core viewpoints (3-5) and key concepts (3-5)
- Generate a material summary page →
wiki/sources/{日期}-{标题}.md - For each key concept, judge its relationship with existing entity pages:
- It is the same thing → read the entity page, append new information in the "Viewpoints in Different Materials" section, and update
updateddate - Exactly the same name but different meaning → create a new entity page, add a disambiguation note
- New concept, not in the knowledge base → create a new entity page →
wiki/entities/{概念名}.md
- It is the same thing → read the entity page, append new information in the "Viewpoints in Different Materials" section, and update
- Judge whether a topic page needs to be created or updated (only worth it when the material provides enough new information to enrich a topic)
Simplified processing(is_long: false and general concept density):
- Extract core viewpoints (1-3) and key concepts (1-3)
- Generate material summary page →
wiki/sources/{日期}-{标题}.md - When a concept has no corresponding entity page, mark it on the summary page
[待创建: [[概念名]]],do not proactively create an entity page - Skip topic page creation/update
Third paragraph: wrap-up [PROCEDURE]
- Perform format validation on each newly created/updated page:
python {SKILL_DIR}/scripts/validate_page.py --wiki-root "<路径>" --page-path "<页面路径>" --page-type <entity|topic|source> - Update
index.md(add an entry under the corresponding category) andlog.md(add an operation record) - If the material comes from a domain that has not been processed before, under
references/source-patterns/create an experience file to record the discoveries made during extraction
Workflow 3: query (query the knowledge base) [REASONING]
This is a workflow that requires judgment—searching is only the means; a synthesized answer is the goal.
- Perform pre-checks
- First read
index.mdto quickly locate relevant entries—the index is a manually maintained curated catalog with higher priority than full-text search - Use search.py full-text search as a supplement:
python {SKILL_DIR}/scripts/search.py --wiki-root "<路径>" --query "<关键词>"Do not look only at the index. Once the knowledge base grows, the index becomes outdated, and search.py can find pages not included in the index.
- After reading the relevant pagessynthesize an answer, do not simply list the search results
- Cite the source pages in the answer (use
[[链接]]or[来源](路径)format) - Judgment: if the query triggered valuable analysis, suggest saving it as a new page
Search tips: separate multiple-word queries with spaces (AND logic); use --type entity to search only entity pages; use --include-raw to search raw materials.
Workflow 4: digest (in-depth comprehensive analysis) [REASONING]
The value of digest lies incross-material comprehensive analysis, not simple concatenation.
- Perform pre-checks
- Read
index.mdto locate all relevant materials and pages - Use search.py to search all relevant keywords in full to ensure nothing is missed:
python {SKILL_DIR}/scripts/search.py --wiki-root "<路径>" --query "<关键词>" --include-raw - Comprehensive analysis(not concatenation): after reading all relevant pages, judge:
- Are the viewpoints across different materials consistent or conflicting?
- Which viewpoints are supported by multiple materials (high credibility)?
- Which viewpoints have only a single source (need more evidence)?
- What is the knowledge thread (by timeline or logical chain)?
- What issues remain unresolved?
- Generate a structured in-depth report →
wiki/synthesis/{主题}-深度报告.md - Update
index.mdandlog.md
Workflow 5: lint (knowledge base health check) [MIXED]
The script handles structural checks, and the AI handles semantic checks.
First paragraph: structural check [PROCEDURE]
python {SKILL_DIR}/scripts/lint.py --wiki-root "<路径>"
The script returns JSON:orphan_pages(orphan pages),broken_links(broken links),index_mismatches(index inconsistency),registry_mismatches(registry inconsistency).
Second paragraph: semantic check [REASONING]
Based on the script report, the AI additionally does:
- Contradiction detection: randomly sample 5-10 pages and check whether different pages contain contradictory descriptions of the same concept
- Cross-reference suggestions: check whether related pages lack mutual links
- Outdatedness assessment: Determine whether any page content is outdated (based on the timestamps of source materials and knowledge timeliness)
Workflow 6: status (knowledge base status) [PROCEDURE]
- Perform pre-checks
- Run the script:
python {SKILL_DIR}/scripts/status.py --wiki-root "<路径>" - Based on the JSON output by the script, generate a user-friendly status report
- Provide suggestions based on the current status (e.g., "You may want to learn more about X, or run a digest on Y")
Workflow 7: graph (knowledge graph) [MIXED]
The script generates Mermaid code, and the AI renders it directly to the user in the chat.
Part 1: Generate the graph [PROCEDURE]
python {SKILL_DIR}/scripts/graph.py --wiki-root "<路径>" --max-nodes 30
The script outputs JSON, with key fields:nodes(number of nodes),edges(number of relationships),mermaid(Mermaid code),truncated(whether truncated).
Part 2: Display the graph [REASONING]
- Extract from the script output the
mermaidfield - Output the Mermaid code block directly in the chat(WorkBuddy/VS Code will render it as a visual graph):
```mermaid {mermaid 代码} ``` - Include a text summary: number of nodes, number of relationships, type distribution
- If
truncated: true, inform the user that "the graph is large, so only the {N} most core nodes are shown; you can expand the scope via--max-nodes 50" - If the user requests detailed interaction (zoom/drag/search), generate an HTML version:
Then preview the generatedpython {SKILL_DIR}/scripts/graph.py --wiki-root "<路径>" --max-nodes 50 --format htmlwiki/knowledge-graph.html
Page generation specification
All wiki pages must follow the format below.
Frontmatter (required)
---
tags: [标签1, 标签2]
created: YYYY-MM-DD
updated: YYYY-MM-DD
sources: [素材引用]
---
Content structure
# 一级标题: page name> 引用块: one-sentence summary (immediately below the title)## 二级标题: each section[[双向链接]]: references between pages (Obsidian-compatible)[待创建: [[概念名]]]: mark entities that have not yet been created
Sections that entity pages must include
- Introduction
- Key information
- Detailed content
- Viewpoints in different source materials (the core value section—this is where cross-source verification and viewpoint comparison are stored)
- Related pages
Sections that source material summary pages must include
- Basic information
- Core viewpoints
- Key concepts
- Associations with other source materials
- Notable excerpts from the original text
- Related pages