Knowledge Base Search
Build a small, local search layer over your own documentation so answers cite the source passage instead of hallucinating.
Download this skill
3 files · SKILL.md + ZIP + Python · License CC BY 4.0
SKILL.md
3.2 KBv1.0.0skill mdskill.json
1.4 KBv1.0.0manifestlocal_search.py
1.6 KBv1.0.0python Executable
License: CC BY 4.0. Only download and use files you are licensed to use.
This resource includes executable scripts. Review the code before running it, run it in an isolated environment, and never pass secrets you do not intend to share with the script.
Retrieval first, generation second
The most common failure in a “chat with our docs” project is that the right passage was never retrieved. No amount of prompt engineering fixes missing context.
This skill starts with a local retrieval baseline: TF-IDF over Markdown and text files. It is not state of the art, but it is fast, free, inspectable and good enough to establish whether your corpus can answer the questions people actually ask.
Chunking and citations
Split by headings, not by a fixed character count. Keep the document title and path with each chunk. When the model answers, require a citation to the chunk. If no chunk supports the answer, the correct response is “I could not find that in the knowledge base”.
That refusal behaviour is a feature. An assistant that invents policy is worse than a search box.
Evaluate before scaling
Write twenty real questions and record the expected source document. Measure:
- Did the correct document appear in the top three results?
- Did the answer cite the correct passage?
- Did the model refuse when the answer was absent?
Only then decide whether to add embeddings, reranking or a managed search service. Many teams jump to a vector database before fixing headings, duplicates and outdated pages.
Freshness and permissions
Rebuild the index when documents change. Remove archived content. If different users have different access, filter at retrieval time rather than trusting the model to keep secrets.
At a glance
- Difficulty
- Intermediate
- Platforms
- Python, Claude, ChatGPT, Local models
- File format
- SKILL.md + ZIP + Python
- License
- CC BY 4.0
- Version
- 1.0.0
- Last reviewed
- May 17, 2026
- Source
- AI Skills Hub original
- Access
- Free
What it does
Capabilities included in this package.
- Local TF-IDF retrieval baseline
- Chunking with source metadata
- Answer prompt that must cite a passage
- Evaluation questions and failure log
Requirements
Check these before you start.
- A folder of Markdown or text documents you are allowed to index
- Python 3.10+
- scikit-learn for the example
- A review process for answers
Installation
Set up the skill in a working folder before you use it on real material.
- 1
Download the skill
Save SKILL.md and the example search script.
- 2
Install scikit-learn
The example uses a local TF-IDF index, so no API key is required.
python -m pip install scikit-learn - 3
Organise the corpus
Use one document per topic with a stable path. Remove drafts and duplicates.
How to use it
A reviewed sequence that keeps a person in the loop.
- 1
Start with keyword search
A TF-IDF baseline is fast and surprisingly strong for small, well-structured corpora. Use it to set a benchmark.
- 2
Chunk with context
Split documents into sections and keep the title and path with each chunk so the answer can cite a source.
- 3
Retrieve, then answer
Give the model only the top passages and require it to answer from those passages or say it does not know.
- 4
Build an evaluation set
Write 20 real questions with known source answers. Measure retrieval accuracy before improving generation.
- 5
Log misses
Record questions with no result and add synonyms, aliases or better headings. Retrieval quality is mostly a content problem.
Use cases
Tasks this skill is designed for.
- Search internal SOPs without sending them to a vendor
- Answer support questions from an approved help centre
- Prototype retrieval before investing in a vector database
Worked examples
Internal SOP assistant
Ask “How do I refund a damaged order?” The system retrieves the refund and damaged-goods sections and cites both. If the policy is ambiguous, it says so.
Support macro finder
Retrieve the closest approved macro and show the full text. The agent edits and sends; the AI does not improvise policy.
Security and privacy
Read this before running any downloaded script or sending material to an AI provider.
Treat downloaded code and extracted text as untrusted
An internal knowledge base can contain confidential procedures and personal data. Keep the index on approved infrastructure, enforce access control at retrieval time, and do not mix documents from different permission levels in one index unless the retrieval layer filters by user access.
Version history
v1.0.0
Initial reviewed release.
May 4, 2026
Frequently asked questions
Related resources
Spotted something out of date? Suggest the fix and an editor will review it.