kb-retriever
面向本地知识库目录的检索和问答助手。核心流程:(1)分层索引导航 (2)遇到PDF/Excel时必须先读取references学习处理方法 (3)处理文件后再检索。按文件类型组合使用 grep、Read、pdfplumber、pandas 进行渐进式检索,避免整文件加载。用户问题涉及"从知识库目录回答问题/检索信息/查资料"时使用。
npx skills add ConardLi/garden-skills --skill kb-retriever --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 本地知识库检索 Skill(kb-retriever) ## 知识库目录说明 - 知识库存放在一个根目录下,包含多种文件类型(如 `.md`/`.txt`、`.pdf`、`.xlsx` 等),通常按类型或业务用途拆分为多级子目录。 - 采用**分层目录索引文件**: - 根目录有一个 `data_structure.md`,说明主要的「领域目录」及其用途。 - 每个领域目录下可以有自己的 `data_structure.md`,说明该目录下有哪些子目录/文件,以及各自用途。 - 更深一层的子目录也可以继续有 `data_structure.md`,形成多级索引树。 - 知识库根目录约定: - 默认认为知识库位于当前项目根目录下的 `knowledge/` 目录。 - 如果用户在对话中明确指定了其他路径(例如“我的知识库在 /data/kb”或“用 ./docs 这个目录作为知识库”),则以用户指定的路径作为根目录。 - 当默认路径 `knowledge/` 不存在或访问失败时,应向用户确认实际的知识库根目录位置,而不是随意猜测。 - 单个业务文件可能很大: - 不要直接用 Read 读取整文件 - 对 PDF、Excel 使用对应 Skill 进行结构化处理后,再结合 grep/局部读取做精细检索 ### 定位 `knowledge` 根目录 - 根目录优先听用户:如果用户给了路径(如 `./docs`、`./knowledge-personal`),直接用用户提供的路径。 - 默认根目录:否则约定根目录为当前项目下的 `knowledge/`。 - 使用 shell 显式检查目录是否存在:优先使用 `test -d knowledge`,或退而求其次使用 `ls -d knowledge`。 - 注意:禁止使用 `Glob "knowledge" in .` 这类模式来判断目录是否存在,`Glob` 只返回文件路径,不返回目录本身,空结果并不能区分“目录不存在”和“目录存在但为空”。 - 只有在根目录已通过 `test -d` 等方式确认存在时,才使用 Glob 在该目录下检索内容,并把目录作为 `path`,例如: - 索引文件:`pattern="**/data_structure.md"`, `path="knowledge"` - 所有 Markdown:`pattern="**/*.md"`, `path="knowledge"` - 如果默认 `knowledge/` 不存在(`test -d` 失败):不要猜测其他目录,明确告诉用户未找到默认根目录,并让用户指定实际知识库路径。 ## 关键原则:先学习,再处理 **遇到 PDF 或 Excel 文件时的强制检查清单**: - [ ] ✅ 已读取对应的 references 文档学习处理方法
- 知识库目录说明
- 定位 knowledge 根目录
- 关键原则:先学习,再处理
- 总体流程
- 公共检索原则
- 关键词选择策略
- grep 检索基本原则
- 多轮迭代检索机制(最多 5 次)
- 注意事项
- 针对不同文件类型的具体策略
- 1. Markdown / 文本类文件(.md, .txt, .log 等)
- 2. PDF 文件检索策略
- 3. Excel 文件检索策略
- 与其他工具的协同
What does the kb-retriever skill do?
面向本地知识库目录的检索和问答助手。核心流程:(1)分层索引导航 (2)遇到PDF/Excel时必须先读取references学习处理方法 (3)处理文件后再检索。按文件类型组合使用 grep、Read、pdfplumber、pandas 进行渐进式检索,避免整文件加载。用户问题涉及"从知识库目录回答问题/检索信息/查资料"时使用。
How do I install it?
Run `npx skills add ConardLi/garden-skills --skill kb-retriever --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ConardLi/garden-skills, a repository with 10,047 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
