Backend · Skill

Build RAG search over your docs

build-rag-search-over-docs

Builds retrieval-augmented generation (RAG) so an AI answers from your documents - split docs into chunks, embed them into a vector store, retrieve the best matches, and answer with citations or say it does not know. Use when the user wants a chatbot that knows their docs, AI search over a knowledge base, or answers grounded in their content.

Works with: Any AI Not yet model-tested; testing Jan 2027

Paste it into ChatGPT, Claude, Gemini or any AI chat, then tell it about your project. How it works

Install in Claude Code, Cursor or Codex (optional)

Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.

Claude Code (all your projects)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-rag-search-over-docs/raw' -o ~/'.claude/skills/build-rag-search-over-docs/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-rag-search-over-docs/files/LICENSE.txt' -o ~/'.claude/skills/build-rag-search-over-docs/LICENSE.txt'

Cursor (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-rag-search-over-docs/raw' -o '.cursor/skills/build-rag-search-over-docs/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-rag-search-over-docs/files/LICENSE.txt' -o '.cursor/skills/build-rag-search-over-docs/LICENSE.txt'

Codex and other Agent Skills tools (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-rag-search-over-docs/raw' -o '.agents/skills/build-rag-search-over-docs/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-rag-search-over-docs/files/LICENSE.txt' -o '.agents/skills/build-rag-search-over-docs/LICENSE.txt'

Or connect the whole library over MCP

Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):

{
  "mcpServers": {
    "theskillvault": {
      "url": "https://theskillvault.ai/mcp"
    }
  }
}

RAG means: find the most relevant passages first, then ask the model to answer only from them. It cuts made-up answers and lets you cite sources.

When to use

  • You want a help bot that answers from your docs, policies or notes.
  • Plain chat answers are wrong because the model never saw your content.
  • You need answers with links back to the source page.

When not to use

  • You only need a general chatbot. Use build-ai-chatbot-api-route.

Steps

  1. Collect the source docs and keep a URL or file path for each.
  2. Split them into chunks of about 300-800 words with a small overlap, keeping headings with each chunk.
  3. Create embeddings for every chunk with one embedding model, and store them with the text and source in a vector store (pgvector, a hosted vector database, or a local index).
  4. At question time, embed the question and fetch the top 5-10 chunks. Add keyword search too if exact names or codes matter.
  5. Optionally rerank the results and keep the best 3-5.
  6. Send the model the question plus those chunks, with the prompt below.
  7. Return the answer with its sources listed.
  8. Build a small test set of 20 real questions with known answers and check it after every change.
  9. Re-embed changed docs when content updates.
Answer the question using only the sources below. Cite sources as [1], [2].
If the sources do not contain the answer, say "I don't know based on these docs."
Sources:
{{numbered chunks with titles}}
Question: {{question}}

Gotchas

  • Do not index private or sensitive documents into a bot that the public can query.
  • Keep API keys for the model and the vector store on the server, never in browser code.
  • Chunks that are too small lose context; too large and retrieval gets vague. Test both.
  • Changing the embedding model means re-embedding everything.

Portability

Works with any model provider and vector store. If you use LangChain or LlamaIndex, they wrap these same steps; a plain Postgres table with pgvector is an equivalent option for small projects.

Example prompt

"Build a help chatbot that answers from the Markdown files in /docs, cites the page it used, and says when it does not know."

Done when

  • Answers cite the chunks they used.
  • Off-topic questions get "I don't know" rather than a guess.
  • A saved test set of real questions passes at an agreed rate.

---

Adapted from "rag-implementation" in wshobson/agents (MIT, Copyright (c) 2024 Seth Hobson). See LICENSE.txt.

Bundled files

Licence

Adapted from Seth Hobson (wshobson/agents, rag-implementation) (Copyright (c) 2024 Seth Hobson), MIT License. Adapted by TheSkillVault: rewritten as a framework-free build order for beginners with an original answer prompt; LangGraph quick start and long catalogues dropped; added privacy notes, gotchas and done-when.

Licence: MIT License. Attribution when you reuse it: Based on work by Seth Hobson (wshobson/agents, rag-implementation) (Copyright (c) 2024 Seth Hobson, MIT License), https://github.com/wshobson/agents/tree/7e2fb559cf4b824b27f1fec49fe88f7511066d26/plugins/llm-application-dev/skills/rag-implementation; adapted by TheSkillVault, https://theskillvault.ai