kb-retriever
面向本地知识库目录的检索和问答助手。核心流程:(1)分层索引导航 (2)遇到PDF/Excel时必须先读取references学习处理方法 (3)处理文件后再检索。按文件类型组合使用 grep、Read、pdfplumber、pandas 进行渐进式检索,避免整文件加载。用户问题涉及"从知识库目录回答问题/检索信息/查资料"时使用。
Security Assessment
Detected risks:
About kb-retriever
A retrieval and question-answering assistant for a local knowledge base directory that holds mixed file types such as Markdown/text, PDF, and Excel, usually split into multiple levels of subdirectories. The core workflow is hierarchical index navigation: a root data_structure.md describes the main domain folders and their purpose, and each folder may contain its own data_structure.md, forming a multi-level index tree the assistant walks to narrow down the most relevant subdirectories and files for a question. By default the knowledge base is assumed to live in a knowledge/ directory under the project root, but an explicit user-supplied path takes precedence; directory existence is checked with shell commands like test -d rather than with Glob, since Glob only returns file paths.
Use it when a user asks to answer a question, look something up, or retrieve information from a knowledge-base directory. A central rule is 'learn before processing': when a PDF or Excel file is encountered, the matching reference under references/ (pdf_reading.md for PDFs, excel_reading.md and excel_analysis.md for Excel) must be read first so the recommended tools and commands are understood before any extraction. Files are then processed with the right tool — pdftotext or pdfplumber for PDFs (extracting to a file rather than stdout to save tokens), pandas for Excel (reading limited rows, filtering, and aggregating) — and searched progressively with grep plus localized Read calls instead of loading whole files.
Retrieval follows a unified multi-round iteration mechanism capped at five attempts: keywords are extracted and expanded with synonyms, candidate files are searched, matched context is read locally, and the loop stops once enough supporting context is found or the attempt limit is reached. Answers lead with a conclusion followed by brief evidence, cite the source files and approximate locations, and explicitly flag assumptions or missing information rather than fabricating facts, prompting the user to narrow scope when needed.
FAQ
Where does the skill expect the knowledge base to be located?
By default it assumes a knowledge/ directory under the project root, but if the user specifies another path (such as ./docs or /data/kb) that path is used instead. If the default does not exist it asks the user to confirm the real location rather than guessing.
What must happen before processing a PDF or Excel file?
The matching reference document must be read first: references/pdf_reading.md before any PDF, and references/excel_reading.md plus references/excel_analysis.md before any Excel. This ensures the correct extraction tools and commands are used before retrieval begins.
How many retrieval rounds does it perform before giving up?
It uses a unified multi-round iteration mechanism capped at five attempts. It stops earlier once it finds enough context to answer, and if it still cannot find the information it tells the user and suggests how to narrow the scope.
Why does it avoid reading entire files directly?
Individual business files can be very large, so loading them whole wastes tokens. Instead it uses the hierarchical data_structure.md indexes, grep, and localized Read calls (with limits and offsets) to read only the regions around matches.
Which tools does it recommend for each file type?
For Markdown/text it uses Grep with a specific include and localized Read; for PDFs it prefers pdftotext or pdfplumber (extracting to a file, not stdout); and for Excel it uses pandas to read limited rows, filter, and aggregate.
Install kb-retriever
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
conardli/garden-skills