Agent skill

Evaluate RAG

by ai-evals-course in ai-evals-course/evals-skills

Guides evaluation of a RAG system by diagnosing failures in traces, building a retrieval test set and scoring retrieval and generation separately.

Apache-2.0Auto-check passedAI & LLM Engineering

Install Evaluate RAG

skills CLI
$ npx skills add ai-evals-course/evals-skills --skill evaluate-rag -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ai-evals-course/evals-skills evaluate-rag --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ai-evals-course/evals-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/evaluate-rag .claude/skills/evaluate-rag && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
evaluate-rag
GitHub stars
1.5k
Token cost
~1.9k tokens
SKILL.md length
877 words
Files
2
Skills in repo
9
Repo updated
First seen
Licence
Apache-2.0

At a glance

Guides evaluation of a RAG system by diagnosing failures in traces, building a retrieval test set and scoring retrieval and generation separately.

  • Works in 5 steps: Do error analysis on end-to-end traces… → Build a retrieval evaluation dataset:… → Measure retrieval quality with Recall@k… → …
  • Measuring how well a retrieval step finds the right chunks
  • SKILL.md covers Overview, Prerequisites, Core Instructions and Anti-Patterns
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

The skill insists on error analysis first: read end-to-end traces to see whether bad answers come from retrieval, generation or both, and fix retrieval before anything else. It then has you build a retrieval evaluation set of queries paired with the document chunks that answer them, either written by hand or produced by prompting an LLM to pull a fact from each chunk and write a question only that fact answers.

Harder adversarial questions are made by taking a target chunk, finding similar chunks through embedding search and writing questions that only the target can answer. Retrieval is scored per stage: Recall@k for first-pass retrieval, and Precision@k, MRR or NDCG@k for reranking. Generation is judged apart, on faithfulness to the retrieved context and relevance to the query. If retrieval is the bottleneck, chunking is tuned by grid search before generation is touched.

When your agent uses it

  • Measuring how well a retrieval step finds the right chunks
  • Judging whether generated answers stay grounded in the retrieved context
  • Creating synthetic question and answer pairs to test retrieval
  • Comparing chunk sizes or chunking strategies for a RAG pipeline

Example prompts

  • “Our support bot gives wrong answers; work out whether retrieval or generation is at fault using these traces.”
  • “Generate a retrieval test set from the docs in ./kb, including adversarial questions.”
  • “Compute Recall@5 for our retriever against the labeled queries and suggest chunking changes.”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Do error analysis on end-to-end traces first. Determine whether failures come from retrieval, generation, or both.
  2. Build a retrieval evaluation dataset: queries paired with relevant document chunks.
  3. Measure retrieval quality with Recall@k (most important for first-pass retrieval).
  4. Evaluate generation separately: faithfulness (grounded in context?) and relevance (answers the query?).
  5. If retrieval is the bottleneck, optimize chunking via grid search before tuning generation.

What it can do on your machine

Read from SKILL.md and the folder at commit 80d5f7b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Evaluate RAG loads about 1.9k tokens when it runs. Until then it costs about 77 tokens; SKILL.md has 877 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~77
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ai-evals-course/evals-skills at commit 80d5f7b, republished under its Apache-2.0 licence (© ai-evals-course). 877 words, ~1,906 tokens.

Download SKILL.mdSave it as .claude/skills/evaluate-rag/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
evaluate-rag
description
Guides evaluation of RAG pipeline retrieval and generation quality. Use when evaluating a retrieval-augmented generation system, measuring retrieval quality, assessing generation faithfulness or relevance, generating synthetic QA pairs for retrieval testing, or optimizing chunking strategies.

Evaluate RAG

Overview

  1. Do error analysis on end-to-end traces first. Determine whether failures come from retrieval, generation, or both.
  2. Build a retrieval evaluation dataset: queries paired with relevant document chunks.
  3. Measure retrieval quality with Recall@k (most important for first-pass retrieval).
  4. Evaluate generation separately: faithfulness (grounded in context?) and relevance (answers the query?).
  5. If retrieval is the bottleneck, optimize chunking via grid search before tuning generation.

Prerequisites

Complete error analysis on RAG pipeline traces before selecting metrics. Inspect what was retrieved vs. what the model needed. Determine whether the problem is retrieval, generation, or both. Fix retrieval first.

Core Instructions

Evaluate Retrieval and Generation Separately

Measure each component independently. Use the appropriate metric for each retrieval stage:

  • First-pass retrieval: Optimize for Recall@k. Include all relevant documents, even at the cost of noise.
  • Reranking: Optimize for Precision@k, MRR, or NDCG@k. Rank the most relevant documents first.
Building a Retrieval Evaluation Dataset

You need queries paired with ground-truth relevant document chunks.

Manual curation (highest quality): Write realistic questions and map each to the exact chunk(s) containing the answer.

Synthetic QA generation (scalable): For each document chunk, prompt an LLM to extract a fact and generate a question answerable only from that fact.

Synthetic QA prompt template:

Given a chunk of text, extract a specific, self-contained fact from it.
Then write a question that is directly and unambiguously answered
by that fact alone.

Return output in JSON format:
{ "fact": "...", "question": "..." }

Chunk: "{text_chunk}"

Adversarial question generation: Create harder queries that resemble content in multiple chunks but are only answered by one.

Process:

  1. Select target chunk A containing a clear fact.
  2. Find similar chunks B, C using embedding search (chunks that share terminology but lack the answer).
  3. Prompt the LLM to write a question using terminology from B and C that only chunk A answers.

Example:

  • Chunk A: "In April 2020, the company reported a 17% drop in quarterly revenue, its largest decline since 2008."
  • Chunk B: "The company experienced significant losses in 2008 during the financial crisis."
  • Generated question: "When did the company experience its largest revenue decline since the 2008 financial crisis?"

Only chunk A contains the answer. Chunk B is a plausible distractor.

Filtering synthetic questions: Rate synthetic queries for realism using few-shot LLM scoring. Keep only those rated realistic (4-5 on a 1-5 scale). Likert scoring is appropriate here, since the goal is fuzzy ranking for dataset curation, not measuring failure rates.

Retrieval Metrics

Recall@k: Fraction of relevant documents found in the top k results.

Recall@k = (relevant docs in top k) / (total relevant docs for query)

Prioritize recall for first-pass retrieval. LLMs can ignore irrelevant content but cannot generate from missing content.

Precision@k: Fraction of top k results that are relevant.

Precision@k = (relevant docs in top k) / k

Use for reranking evaluation.

Mean Reciprocal Rank (MRR): How early the first relevant document appears.

MRR = (1/N) * sum(1/rank_of_first_relevant_doc)

Best for single-fact lookups where only one key chunk is needed.

NDCG@k (Normalized Discounted Cumulative Gain): For graded relevance where documents have varying utility. Rewards placing more relevant items higher.

DCG@k  = sum over i=1..k of: rel_i / log2(i+1)
IDCG@k = DCG@k with documents sorted by decreasing relevance
NDCG@k = DCG@k / IDCG@k

Caveat: Optimal ranking of weakly relevant documents can outscore a highly relevant document ranked lower. Supplement with Recall@k.

Choosing k: k varies by query type. A factual lookup uses k=1-2. A synthesis query ("summarize market trends") uses k=5-10.

Metric Selection
Query TypePrimary Metric
Single-fact lookupsMRR
Broad coverage neededRecall@k
Ranked quality mattersNDCG@k or Precision@k
Multi-hop reasoningTwo-hop Recall@k
Show full SKILL.md (360 more words)Show less
Evaluating and Optimizing Chunking

Treat chunking as a tunable hyperparameter. Even with the same retriever, metrics vary based on chunking alone.

Grid search for fixed-size chunking: Test combinations of chunk size and overlap. Re-index the corpus for each configuration. Measure retrieval metrics on your evaluation dataset.

Example search grid:

Chunk sizeOverlapRecall@5NDCG@5
128 tokens00.820.69
128 tokens640.880.75
256 tokens00.860.74
256 tokens1280.890.77
512 tokens00.800.72
512 tokens2560.830.74

Content-aware chunking: When fixed-size chunks split related information:

  • Use natural document boundaries (sections, paragraphs, steps).
  • Augment chunks with context: prepend document title and section headings to each chunk before embedding.
Evaluating Generation Quality

After confirming retrieval works, evaluate what the LLM does with the retrieved context along two dimensions:

Answer faithfulness: Does the output accurately reflect the retrieved context? Check for:

  • Hallucinations: Information absent from source documents. In RAG, even correct facts from the LLM's own knowledge count as hallucinations.
  • Omissions: Relevant information from the context ignored in the output.
  • Misinterpretations: Context information represented inaccurately.

Answer relevance: Does the output address the original query? An answer can be faithful to the context but fail to answer what the user asked.

Use error analysis to discover specific manifestations in your pipeline. Identify what kind of information gets hallucinated and which constraints get omitted.

Diagnosing Failures by Metric Pattern
Context RelevanceFaithfulnessAnswer RelevanceDiagnosis
HighHighLowGenerator attended to wrong section of a correct document
HighLow--Hallucination or misinterpretation of retrieved content
Low----Retrieval problem. Fix chunking, embeddings, or query preprocessing
Multi-Hop Retrieval Evaluation

For queries requiring information from multiple chunks:

Two-hop Recall@k: Fraction of 2-hop queries where both ground-truth chunks appear in the top k results.

TwoHopRecall@k = (1/N) * sum(1 if {Chunk1, Chunk2} ⊆ top_k_results)

Diagnose failures by classifying: hop 1 miss, hop 2 miss, or rank-out-of-top-k.

Anti-Patterns

  • Using a single end-to-end correctness metric without separating retrieval and generation measurement.
  • Jumping directly to metrics without reading traces first.
  • Overfitting to synthetic evaluation data. Validate against real user queries regularly.
  • Using similarity metrics (ROUGE, BERTScore, cosine similarity) as primary generation evaluation. Use binary evaluators driven by error analysis.
  • Evaluating generation without checking context grounding.

© ai-evals-course, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file in skills/evaluate-rag of ai-evals-course/evals-skills.

  • SKILL.md
  • agents/openai.yaml

Open the folder on GitHubat commit 80d5f7b

Compare with similar skills

Evaluate RAG next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Evaluate RAG compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Evaluate RAG this skillai-evals-course/evals-skills1.5k—~1.9kAutomated safety check: PassApache-2.0
RAG ArchitectJeffallan/claude-skills12k1 repos~2kAutomated safety check: PassMIT
LLM Opsdavila7/claude-code-templates32k4 repos~2kAutomated safety check: PassMIT
Chroma Vector DatabaseOrchestra-Research/AI-Research-SKILLs13k8 repos~2.3kAutomated safety check: PassMIT
Chatbox Session RAG Evalchatboxai/chatbox42k—~758Automated safety check: PassGPL-3.0
Pgvector Semantic Searchtimescale/pg-aiguide1.9k1 repos~3.8kAutomated safety check: PassApache-2.0

Similar skills

  • RAG Architect

    Jeffallan/claude-skills

    Designs retrieval-augmented generation systems: document chunking, embeddings, vector store setup, hybrid search, reranking and retrieval evaluation, with checks at each step.

    12k GitHub starsUsed in 1 repo~2k tokens
    AI & LLM EngineeringAuto-check passed
  • LLM Ops

    davila7/claude-code-templates

    LLM Operations -- RAG, embeddings, vector databases, fine-tuning, prompt engineering avancado, custos de LLM, evals de qualidade e arquiteturas de IA para producao.

    32k GitHub starsUsed in 4 repos~2k tokens
    AI & LLM EngineeringAuto-check passed
  • Chroma Vector Database

    Orchestra-Research/AI-Research-SKILLs

    Shows how to store documents and embeddings in Chroma, query them by similarity with metadata filters, and persist them to disk for RAG and semantic search projects.

    13k GitHub starsUsed in 8 repos~2.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Chatbox Session RAG Eval

    chatboxai/chatbox

    Runs and debugs evaluations of how Chatbox models answer questions about large attached files, using synthetic and real long-document fixtures.

    42k GitHub stars~758 tokensUpdated 14 days ago
    AI & LLM EngineeringAuto-check passed
  • Pgvector Semantic Search

    timescale/pg-aiguide

    A skill your agent uses for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search.

    1.9k GitHub starsUsed in 1 repo~3.8k tokens
    AI & LLM EngineeringAuto-check passed
  • Sentence Transformers Embeddings

    Orchestra-Research/AI-Research-SKILLs

    Generates text embeddings locally with the sentence-transformers library for RAG, semantic search, clustering and similarity, with model picks for general, multilingual and legal text.

    13k GitHub starsUsed in 3 repos~1.6k tokens
    AI & LLM EngineeringAuto-check passed

More from ai-evals-course/evals-skills

All 9 skills in this repo
  • LLM Trace Review Interface

    ai-evals-course/evals-skills

    Builds a browser-based annotation page for reviewing LLM traces one at a time with pass/fail labels, notes and saved results, tailored to your data.

    1.5k GitHub stars~1.4k tokensUpdated 14 days ago
    Auto-check passed
  • LLM Eval Pipeline Audit

    ai-evals-course/evals-skills

    Inspects an LLM evaluation setup for missing error analysis, unvalidated judges and vanity metrics, and ranks the problems by impact with fixes.

    1.5k GitHub stars~2.5k tokensUpdated 14 days ago
    Auto-check passed
  • Synthetic Eval Data Generator

    ai-evals-course/evals-skills

    Builds diverse synthetic test inputs for LLM pipeline evaluation by defining failure-focused dimensions, drafting tuples with you and turning them into realistic queries.

    1.5k GitHub stars~1.4k tokensUpdated 14 days ago
    Auto-check passed
  • LLM Judge Validation

    ai-evals-course/evals-skills

    Checks an LLM judge against human labels using train, dev and test splits, TPR and TNR, and a bias correction applied to production data.

    1.5k GitHub stars~2.2k tokensUpdated 14 days ago
    Auto-check passed
  • LLM-as-Judge Prompt Writer

    ai-evals-course/evals-skills

    Designs a binary Pass/Fail LLM-as-Judge prompt for one subjective failure mode, built from a task statement, clear definitions, labeled examples and a structured output format.

    1.5k GitHub stars~1.9k tokensUpdated 14 days ago
    Auto-check passed
  • Write Code Eval

    ai-evals-course/evals-skills

    Write code evaluators for known failure modes with objective rules.

    1.5k GitHub stars~385 tokensUpdated 14 days ago
    Auto-check passed

Questions about Evaluate RAG

What does Evaluate RAG do?

Guides evaluation of a RAG system by diagnosing failures in traces, building a retrieval test set and scoring retrieval and generation separately. The skill insists on error analysis first: read end-to-end traces to see whether bad answers come from retrieval, generation or both, and fix retrieval before anything else. It then has you build a retrieval evaluation set of queries paired with the document chunks that answer them, either written by hand or produced by prompting an LLM to pull a fact from each chunk and write a question only that fact answers.

When should I use Evaluate RAG?

Evaluate RAG fits situations like: measuring how well a retrieval step finds the right chunks; judging whether generated answers stay grounded in the retrieved context; creating synthetic question and answer pairs to test retrieval; comparing chunk sizes or chunking strategies for a RAG pipeline.

How do I install Evaluate RAG in Claude Code?

Run `npx skills add ai-evals-course/evals-skills --skill evaluate-rag -a claude-code`. Or copy the skill folder (skills/evaluate-rag in ai-evals-course/evals-skills) into .claude/skills/evaluate-rag in your project. Claude Code loads it when a task matches its description.

How do I install Evaluate RAG in Codex?

Run `npx skills add ai-evals-course/evals-skills --skill evaluate-rag -a codex`. Or copy the skill folder (skills/evaluate-rag in ai-evals-course/evals-skills) into .agents/skills/evaluate-rag in your project. Codex loads it when a task matches its description.

Can I use Evaluate RAG in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ai-evals-course/evals-skills --skill evaluate-rag -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/evaluate-rag, .gemini/skills/evaluate-rag, .github/skills/evaluate-rag and .opencode/skills/evaluate-rag in your project.

What does Evaluate RAG need to run?

SKILL.md names no scripts, command-line tools or credentials: Evaluate RAG is instructions for the agent only.

Does Evaluate RAG access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Evaluate RAG safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Evaluate RAG use?

Evaluate RAG is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Evaluate RAG use?

About 1.9k tokens (SKILL.md is roughly 7.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Evaluate RAG?

Skills that share tags, products or a category with Evaluate RAG: RAG Architect (Jeffallan/claude-skills, 12k stars), LLM Ops (davila7/claude-code-templates, 32k stars), Chroma Vector Database (Orchestra-Research/AI-Research-SKILLs, 13k stars) and Chatbox Session RAG Eval (chatboxai/chatbox, 42k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Evaluate RAG?

ai-evals-course (a GitHub organization) maintains it in ai-evals-course/evals-skills, which has 1,468 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on September 24, 2026.

Source: ai-evals-course/evals-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.