Make the AI answer from your documents, and say when it can't.

“The AI keeps making up our pricing. What is RAG, and do I actually need it?”

Builds a small RAG over your own documents: finds the passages that match a question and answers from them with a citation on every sentence, or says the answer is not there.

RUN THE OPERATOR SYSTEMADVANCEDANTHROPIC API KEYYOUR DOCUMENTS AS MARKDOWN, FOR THE RAG SKILLS✓ APPROVED 4/4
EXAMPLE PROMPTS
>What is RAG, and do I need it for our sales playbook?
>Make the AI answer from our docs and cite the passage for each sentence
>Do I need a vector database to build a chat-with-our-playbook bot?
ABOUT THIS SKILL

What this skill does

Ask a chatbot what your discount policy is and it will tell you. Confidently. With a number nobody at your company ever approved.

The model is answering from memory, and it has never seen your discount policy. RAG fixes that by changing the exam. Retrieval-augmented generation means: before the model answers, look up the passages in your documents that hold the answer, hand it those passages, and tell it to answer from them only, citing each one. Closed-book becomes open-book. And an open-book student who cannot find the answer in the book should say so, which is the part most RAG builds forget.

This skill teaches it by building one. A small pipeline you can read in one sitting splits your documents into passages, finds the ones that match a question, and has Claude answer from them with a citation on every sentence, or reply "Not in the sources." Then it saves each answer next to the passages it was shown, so rag-judge can grade whether the retrieval found the right passage and whether the answer stuck to it.

RAG is a retrieval problem first. The model can only answer from what the search hands it.

Inputs

  • Works today with: a folder of your documents as .md or .txt files. Export from Notion, Google Docs, or a wiki to Markdown first.
  • An Anthropic API key: only the answer step calls Claude. Indexing and search are plain Python.
  • Ten real questions your team actually asks, with the phrase from the document that answers each one. Those become your test set.
  • Better with rag-judge: it grades whether retrieval found the right passage and whether each answer stuck to it.

How it works

  1. 1
    Step 1: Decide whether you need RAG at all

    Three options, simplest first:

    • Paste the documents in. If everything fits in one prompt and rarely changes, put it all in the prompt and skip retrieval entirely. Current Claude models read very long prompts. This is the simplest RAG there is, and often the right one.
    • RAG. When there are too many documents to paste every time, when they change often, or when every answer needs a citation someone can check.
    • Fine-tuning. Almost never for facts. Training a model on your pricing teaches it to sound like your pricing, not to know this quarter's price.
  2. 2
    Step 2: Split the documents into passages

    Each passage should answer one kind of question on its own. Split on headings first, then paragraphs, and keep each passage's heading with it, because the heading is often the words a question uses. Around 200 words is a reasonable start. Too small and a passage loses its context. Too big and the model is shown a page to find one line.

    Write your documents for retrieval as much as for reading: one topic per section, a heading that says what the section answers, and no key fact stranded in a table with no words around it.

  3. 3
    Step 3: Find the passages that match the question

    The kit uses BM25, a keyword ranking: a passage scores high when it contains the question's rarer words. No embeddings, no vector database, nothing to host. It misses synonyms and paraphrases. Add embeddings when your test set shows keyword search missing passages it should find, not before.

  4. 4
    Step 4: Answer from the passages only

    The instructions do three jobs: answer only from the passages shown, cite the passage behind every sentence, and say the exact NOT_FOUND line when the passages do not hold the answer. The citation is what lets a reader, and a judge, check the answer.

  5. 5
    Step 5: Save what the model saw

    Save each answer next to the question and the passages it was shown. Without that record nobody can tell a retrieval miss from an answer that drifted, and those need different fixes.

  6. 6
    Step 6: Grade it before anyone relies on it

    Run rag-judge on the saved answers. A script checks whether the passage holding the answer was found. Two trust-tested judges check whether every claim is supported by the passages, and whether the answer declined exactly when it should have.

Output format

One answer from the fictional library, as rag.py ask returns it.


Tips

  • Every answer cites a passage for every sentence, or says the NOT_FOUND line exactly.
  • Every answer is saved with the question and the passages it was shown.
  • The test set includes questions with no answer in the documents, and every one of them was declined.
  • Retrieval misses are counted at the passage level, not the document level.
  • Nobody relies on the answers until a person has read them and rag-judge has graded them.
  • No em dashes anywhere.
RELATED SKILLS
ALL RUN THE OPERATOR SYSTEM SKILLS →