一键导入
kb-init
初始化一个 LLM 驱动的知识库。当用户说"初始化知识库"、"创建知识库"、"新建知识库"、"kb init"时触发。 基于 Karpathy 的 LLM Knowledge Base 模式:raw/ 存原始资料,LLM 编译成 wiki/,索引替代 RAG。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
初始化一个 LLM 驱动的知识库。当用户说"初始化知识库"、"创建知识库"、"新建知识库"、"kb init"时触发。 基于 Karpathy 的 LLM Knowledge Base 模式:raw/ 存原始资料,LLM 编译成 wiki/,索引替代 RAG。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
展示知识库整体状态仪表盘。当用户说"知识库状态"、"kb status"、"看看知识库"时触发。
对知识库进行健康检查。当用户说"检查知识库"、"知识库健康度"、"lint"、"kb lint"时触发。 检查断链、孤岛、溯源、一致性、覆盖度,发现潜在的新文章候选。
将查询输出回填到 wiki 知识库。当用户说"回填"、"归档到 wiki"、"kb file"时触发。 审阅 output/ 中的报告,经用户确认后将有价值的内容并入 wiki。
对知识库提问,生成结构化报告。当用户说"查知识库"、"问知识库"、"kb query", 或在知识库目录下提出研究性问题(如"对比 A 和 B"、"总结 XX 的要点")时触发。
将 raw/ 中已导入但未编译的文件编译为 wiki 文章。当用户说"编译知识库"、"编译"、"更新 wiki"、"kb compile"时触发。 LLM 读取原始资料,按本体定义生成结构化 wiki 文章,自动维护索引和反向链接。
预处理 raw/ 中的新文件并登记到索引。当用户说"导入文件"、"处理新文件"、"ingest"、"kb ingest"时触发。 支持 PDF、Excel、图片 OCR、Word 文档的自动提取。
| name | kb-init |
| description | 初始化一个 LLM 驱动的知识库。当用户说"初始化知识库"、"创建知识库"、"新建知识库"、"kb init"时触发。 基于 Karpathy 的 LLM Knowledge Base 模式:raw/ 存原始资料,LLM 编译成 wiki/,索引替代 RAG。 |
| user-invocable | true |
| argument-hint | ["可选:目标目录路径,默认当前目录"] |
Initialize an LLM-driven knowledge base directory structure.
Use $ARGUMENTS as the target directory path if provided; otherwise use the current working directory. Store this as {target}.
Use the Read tool to check if {target}/index/MASTER-INDEX.md exists. If it does, warn the user:
⚠️ 目标目录已包含知识库(发现 index/MASTER-INDEX.md)。继续操作可能覆盖现有配置。是否继续?
Wait for user confirmation before proceeding. If user declines, abort.
Use the Bash tool to create the following directories under {target}:
mkdir -p {target}/raw
mkdir -p {target}/wiki/concepts
mkdir -p {target}/wiki/sources
mkdir -p {target}/wiki/comparisons
mkdir -p {target}/output/analysis
mkdir -p {target}/output/slides
mkdir -p {target}/index
mkdir -p {target}/scripts/extractors
Directory purposes:
raw/ — 原始资料(只读,LLM 不改动)wiki/concepts/ — 核心概念文章wiki/sources/ — 来源摘要wiki/comparisons/ — 对比分析output/analysis/ — 查询输出的分析报告output/slides/ — Marp 幻灯片输出index/ — 索引文件scripts/extractors/ — 预处理脚本Determine the kb-skills installation directory by finding where this SKILL.md lives and going up 2 levels to the repo root. Store this as {kb-skills-repo}.
KB_SKILLS_REPO="$(cd "$(dirname "$0")/../.." && pwd)"
In practice, use the Bash tool to resolve the path relative to this skill file's known location under skills/kb-init/SKILL.md.
Copy template files from {kb-skills-repo}/templates/general/ to {target}/index/:
cp {kb-skills-repo}/templates/general/ONTOLOGY.md {target}/index/
cp {kb-skills-repo}/templates/general/MASTER-INDEX.md {target}/index/
cp {kb-skills-repo}/templates/general/TOPIC-MAP.md {target}/index/
cp {kb-skills-repo}/templates/general/RAW-REGISTRY.md {target}/index/
Do NOT overwrite existing index files without user confirmation. If any target file already exists, ask before overwriting.
Copy preprocessing scripts from {kb-skills-repo}/scripts/ to {target}/scripts/:
cp {kb-skills-repo}/scripts/*.py {target}/scripts/
cp {kb-skills-repo}/scripts/requirements.txt {target}/scripts/
Run the following to check which dependencies are installed:
pip show pymupdf openpyxl pandas pytesseract python-docx Pillow 2>&1
Parse the output and report which packages are missing. If any are missing, ask the user:
以下 Python 依赖缺失:{missing_list}。是否运行
pip install -r scripts/requirements.txt安装?
If user agrees, run pip install -r {target}/scripts/requirements.txt.
Ask the user:
是否配置 SessionStart 钩子?该钩子会在每次会话启动时自动检测 raw/ 目录中的新文件。
If user agrees:
{kb-skills-repo}/hooks/check_raw.py~/.claude/settings.json using the Read toolpython {kb-skills-repo}/hooks/check_raw.py {target}/raw to the hooks.SessionStart array in ~/.claude/settings.jsonPrint a summary like:
✅ 知识库初始化完成!
📁 目录结构:
{target}/raw/ — 原始资料
{target}/wiki/concepts/ — 核心概念
{target}/wiki/sources/ — 来源摘要
{target}/wiki/comparisons/ — 对比分析
{target}/output/analysis/ — 分析报告
{target}/output/slides/ — 幻灯片
{target}/index/ — 索引文件
{target}/scripts/ — 预处理脚本
📄 模板文件:已复制 ONTOLOGY.md, MASTER-INDEX.md, TOPIC-MAP.md, RAW-REGISTRY.md
🐍 Python 依赖:{status}
🔗 SessionStart 钩子:{hook_status}
Print:
📌 下一步:把资料文件放入 raw/ 目录,然后运行 /kb-ingest