/05-rag-eval
Use when the user has a RAG (Retrieval-Augmented Generation) system and wants to evaluate its quality — separating retrieval issues from generation issues. Also use when the user mentions RAG evaluation, faithfulness checking, hallucination detection in RAG, retrieval quality,
$ npx -y skills add agentscope-ai/OpenJudge --skill 05-rag-eval --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/05-rag-eval
Context preview
The summary Claude sees to decide when to auto-load this skill.
Use when the user has a RAG (Retrieval-Augmented Generation) system and wants to evaluate its quality — separating retrieval issues from generation issues. Also use when the user mentions RAG evaluation, faithfulness checking, hallucination detection in RAG, retrieval quality,
SKILL.md
05-rag-eval.SKILL.mdname: rag-eval
description: >
Use when the user has a RAG (Retrieval-Augmented Generation) system and wants to
evaluate its quality — separating retrieval issues from generation issues. Also use
when the user mentions RAG evaluation, faithfulness checking, hallucination detection
in RAG, retrieval quality, chunking optimization, or "is my RAG pipeline working."
Outputs a diagnostic matrix that pinpoints whether problems are in retrieval or generation.
RAG Eval
Evaluate RAG systems by diagnosing retrieval and generation separately. A single "RAG accuracy" number hides whether the problem is finding the right documents or using them correctly. This skill separates them so you know what to fix.
When to Activate
- User has a RAG pipeline (retriever + generator) with traces
- User wants to know if their RAG system hallucinates
- User is optimizing chunking strategy and needs before/after comparison
- User wants to build a RAG evaluation dataset
Checklist
You MUST create a task for each item and complete them in order:
1. **Load RAG traces** — validate query + context + answer triples 2. **Separate retrieval vs generation** — determine which layers to evaluate 3. **Run faithfulness evaluation** — is the answer grounded in retrieved docs? 4. **Run retrieval evaluation** — are the right documents retrieved? 5. **Build diagnostic matrix** — cross-tabulate to find root cause 6. **Output findings** — prioritized issues with concrete fixes
Fast path: run the bundled script
Once each trace has a faithfulness judgment (and ideally a retrieval signal), build the retrieval-vs-generation diagnostic matrix with the bundled, tested script (`scripts/rag_diagnostic.py`, standard library only, **no OpenJudge dependency**):
python scripts/rag_diagnostic.py --traces traces.jsonl
Trace rows: `{"faithful":bool}` or `{"faithfulness_score":1-5}` (>= 4 = faithful), plus an optional retrieval signal `{"retrieval_good":bool}` or `{"recall_at_k":0-1}` (>= 0.5 = good). It prints the generation faithful/hallucinating split, the 2×2 matrix when a retrieval signal is present, and the primary issue (retrieval vs generation). `--self-test` to verify it.
Steps below explain how to separate the layers and produce the faithfulness/retrieval signals (with OpenJudge graders or any judge).
Step 1: Load RAG Traces
The minimum data needed per trace:
# Each trace must contain:
trace = {
"query": "What is the return policy?",
# retrieved_docs are dicts with id + text (the id is required for retrieval
# metrics like Recall@k; the text is required for the faithfulness check).
"retrieved_docs": [
{"id": "doc_1", "text": "Returns are accepted within 30 days..."},
{"id": "doc_2", "text": "Refunds are issued to the original..."},
],
"answer": "You can return items within 30 days for a full refund.",
"reference_answer": "Our 30-day return policy allows full refunds.", # optional
"gold_doc_ids": ["doc_1", "doc_3"], # optional — which docs should have been retrieved
}If your traces only have raw strings (no ids), wrap them first so retrieval metrics work: `retrieved_docs = [{"id": f"d{i}", "text": t} for i, t in enumerate(raw_strings)]`.
Validate data completeness and report any gaps. If > 20% of traces are missing key fields, ask the user to confirm the schema before proceeding.
Step 2: Separate Retrieval vs Generation
RAG failures come from two independent sources:
| Source | What goes wrong | Metric to use | |--------|----------------|---------------| | **Retrieval** | Wrong/missing documents returned | Recall@k, Precision@k, MRR | | **Generation** | Model misuses or fabricates beyond docs | Faithfulness (HallucinationGrader) | | **Generation** | Answer doesn't address the query | Relevance (RelevanceGrader) |
Why separate them? A system with perfect retrieval but poor generation needs prompt engineering. A system with poor retrieval needs chunking/embedding work. Treating them as one problem wastes effort.
Step 3: Faithfulness Evaluation
Use OpenJudge `HallucinationGrader` to check if the answer stays grounded in retrieved documents:
from openjudge.graders.common.hallucination import HallucinationGrader
from openjudge.runner.grading_runner import GradingRunner
faithfulness_grader = HallucinationGrader(model=model)
runner = GradingRunner(
grader_configs={"faithfulness": faithfulness_grader},
max_concurrency=8,
)
# Dataset format for HallucinationGrader
dataset = [
{
"query": trace["query"],
"response": trace["answer"],
"context": "\n\n".join(doc["text"] for doc in trace["retrieved_docs"]),
}
for trace in traces
]
results = await runner.arun(dataset)
# HallucinationGrader scores 1-5 (5 = no hallucination, fully grounded)
# Binarize: score >= 4 → faithful, score < 4 → hallucinationAlso evaluate **answer relevance** — does the response actually address the query?
from openjudge.graders.common.relevance import RelevanceGrader
relevance_grader = RelevanceGrader(model=model)
Step 4: Retrieval Evaluation
If gold_doc_ids are available, compute retrieval metrics:
def recall_at_k(retrieved_docs, gold_ids, k=5):
"""Fraction of gold docs found in top-k retrieved docs."""
retrieved_ids = set(doc["id"] for doc in retrieved_docs[:k])
gold_set = set(gold_ids)
if not gold_set:
return None
return len(retrieved_ids & gold_set) / len(gold_set)
def precision_at_k(retrieved_docs, gold_ids, k=5):
"""Fraction of top-k docs that are relevant."""
retrieved_ids = set(doc["id"] for doc in retrieved_docs[:k])
gold_set = set(gold_ids)
if not retrieved_ids:
return 0
return len(retrieved_ids & gold_set) / len(retrieved_ids)
def mrr(retrieved_docs, gold_ids):
"""Mean Reciprocal Rank — how early the first relevant doc appears."""
for i, doc in enumerate(retrieved_docs):Read more
name: rag-eval description: > Use when the user has a RAG (Retrieval-Augmented Generation) system and wants to evaluate its quality — separating retrieval issues from generation issues. Also use when the user mentions RAG evaluation, faithfulness checking, hallucination detection in RAG, retrieval quality, chunking optimization, or "is my RAG pipeline working." Outputs a diagnostic matrix that pinpoints whether problems are in retrieval or generation.
RAG Eval
Evaluate RAG systems by diagnosing retrieval and generation separately. A single "RAG accuracy" number hides whether the problem is finding the right documents or using them correctly. This skill separates them so you know what to fix.
When to Activate
- User has a RAG pipeline (retriever + generator) with traces
- User wants to know if their RAG system hallucinates
- User is optimizing chunking strategy and needs before/after comparison
- User wants to build a RAG evaluation dataset
Checklist
You MUST create a task for each item and complete them in order:
1. **Load RAG traces** — validate query + context + answer triples 2. **Separate retrieval vs generation** — determine which layers to evaluate 3. **Run faithfulness evaluation** — is the answer grounded in retrieved docs? 4. **Run retrieval evaluation** — are the right documents retrieved? 5. **Build diagnostic matrix** — cross-tabulate to find root cause 6. **Output findings** — prioritized issues with concrete fixes
Fast path: run the bundled script
Once each trace has a faithfulness judgment (and ideally a retrieval signal), build the retrieval-vs-generation diagnostic matrix with the bundled, tested script (`scripts/rag_diagnostic.py`, standard library only, **no OpenJudge dependency**):
python scripts/rag_diagnostic.py --traces traces.jsonl
Trace rows: `{"faithful":bool}` or `{"faithfulness_score":1-5}` (>= 4 = faithful), plus an optional retrieval signal `{"retrieval_good":bool}` or `{"recall_at_k":0-1}` (>= 0.5 = good). It prints the generation faithful/hallucinating split, the 2×2 matrix when a retrieval signal is present, and the primary issue (retrieval vs generation). `--self-test` to verify it.
Steps below explain how to separate the layers and produce the faithfulness/retrieval signals (with OpenJudge graders or any judge).
Step 1: Load RAG Traces
The minimum data needed per trace:
# Each trace must contain:
trace = {
"query": "What is the return policy?",
# retrieved_docs are dicts with id + text (the id is required for retrieval
# metrics like Recall@k; the text is required for the faithfulness check).
"retrieved_docs": [
{"id": "doc_1", "text": "Returns are accepted within 30 days..."},
{"id": "doc_2", "text": "Refunds are issued to the original..."},
],
"answer": "You can return items within 30 days for a full refund.",
"reference_answer": "Our 30-day return policy allows full refunds.", # optional
"gold_doc_ids": ["doc_1", "doc_3"], # optional — which docs should have been retrieved
}If your traces only have raw strings (no ids), wrap them first so retrieval metrics work: `retrieved_docs = [{"id": f"d{i}", "text": t} for i, t in enumerate(raw_strings)]`.
Validate data completeness and report any gaps. If > 20% of traces are missing key fields, ask the user to confirm the schema before proceeding.
Step 2: Separate Retrieval vs Generation
RAG failures come from two independent sources:
| Source | What goes wrong | Metric to use | |--------|----------------|---------------| | **Retrieval** | Wrong/missing documents returned | Recall@k, Precision@k, MRR | | **Generation** | Model misuses or fabricates beyond docs | Faithfulness (HallucinationGrader) | | **Generation** | Answer doesn't address the query | Relevance (RelevanceGrader) |
Why separate them? A system with perfect retrieval but poor generation needs prompt engineering. A system with poor retrieval needs chunking/embedding work. Treating them as one problem wastes effort.
Step 3: Faithfulness Evaluation
Use OpenJudge `HallucinationGrader` to check if the answer stays grounded in retrieved documents:
from openjudge.graders.common.hallucination import HallucinationGrader
from openjudge.runner.grading_runner import GradingRunner
faithfulness_grader = HallucinationGrader(model=model)
runner = GradingRunner(
grader_configs={"faithfulness": faithfulness_grader},
max_concurrency=8,
)
# Dataset format for HallucinationGrader
dataset = [
{
"query": trace["query"],
"response": trace["answer"],
"context": "\n\n".join(doc["text"] for doc in trace["retrieved_docs"]),
}
for trace in traces
]
results = await runner.arun(dataset)
# HallucinationGrader scores 1-5 (5 = no hallucination, fully grounded)
# Binarize: score >= 4 → faithful, score < 4 → hallucinationAlso evaluate **answer relevance** — does the response actually address the query?
from openjudge.graders.common.relevance import RelevanceGrader relevance_grader = RelevanceGrader(model=model)
Step 4: Retrieval Evaluation
If gold_doc_ids are available, compute retrieval metrics:
def recall_at_k(retrieved_docs, gold_ids, k=5):
"""Fraction of gold docs found in top-k retrieved docs."""
retrieved_ids = set(doc["id"] for doc in retrieved_docs[:k])
gold_set = set(gold_ids)
if not gold_set:
return None
return len(retrieved_ids & gold_set) / len(gold_set)
def precision_at_k(retrieved_docs, gold_ids, k=5):
"""Fraction of top-k docs that are relevant."""
retrieved_ids = set(doc["id"] for doc in retrieved_docs[:k])
gold_set = set(gold_ids)
if not retrieved_ids:
return 0
return len(retrieved_ids & gold_set) / len(retrieved_ids)
def mrr(retrieved_docs, gold_ids):
"""Mean Reciprocal Rank — how early the first relevant doc appears."""
for i, doc in enumerate(retrieved_docs):OpenJudge: A Unified Framework for Holistic Evaluation and Quality Rewards
Other skills on openjudge.
- /auto-arena
Automatically evaluate and compare multiple AI models or agents without pre-existing test data. Generates test queries from a task description, collects responses from all target endpoints, auto-generates evaluation rubrics, runs pairwise comparisons via a judge model, and
Open skill - /bib-verify
Verify a BibTeX file for hallucinated or fabricated references by cross-checking every entry against CrossRef, arXiv, and DBLP. Reports each reference as verified, suspect, or not found, with field-level mismatch details (title, authors, year, DOI). Use when the user wants to
Open skill - /claude-authenticity
Detect whether an API endpoint is backed by genuine Claude (not a wrapper, proxy, or impersonator) using 9 weighted rule-based checks that mirror the claude-verify project. Also extracts injected system prompts from providers that override Claude's identity. Fully self-contained
Open skill - /00-meta-eval
Use when the user wants to build an evaluation system for an LLM/agent application but doesn't know where to start — they have traces, prompts, RAG pipelines, or nothing at all. Also use when the user mentions evaluation, eval, benchmarking, testing LLM quality, measuring agent
Open skill - /01-eval-design
Use when the user needs to design evaluation datasets, create test cases, stratify samples, generate adversarial examples, extract eval dimensions from traces/specs, or build a labeled evaluation set. Also use when the user mentions test data design, eval coverage, difficulty
Open skill - /02-metric-design
Use when the user has evaluation principles or a dataset but needs help choosing the right graders, designing evaluation metrics, creating LLM-as-judge prompts, combining multiple metrics into a composite score, or building an automated evaluation pipeline. Also use when the
Open skill

