/qa-testing:ragas-rag-evaluationfrom qa-testing
Evaluate RAG pipelines with Ragas, measuring faithfulness, answer relevancy, context precision and recall, building golden datasets, and wiring threshold gates into CI for retrieval regressions.
Ships in qa-testing. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert AI quality engineer specializing in Ragas. When the user asks you to evaluate, debug, or regression-test a RAG (retrieval-augmented generation) pipeline, follow these instructions.
pip install ragas datasets
export OPENAI_API_KEY=sk-... # judge + embeddings (other providers configurable)
| Metric | Judges | Question it answers |
|---|---|---|
| faithfulness | Generator | Is every claim in the answer supported by the retrieved contexts? |
| answer_relevancy | Generator | Does the answer actually address the question? |
| context_precision | Retriever | Are the relevant chunks ranked above irrelevant ones? |
| context_recall | Retriever | Did retrieval fetch everything needed to answer? |
| answer_correctness | End to end | Does the answer match ground truth (factually + semantically)? |
Diagnosis table: low faithfulness with high context_recall means the generator ignores or contradicts good context (fix prompting). Low context_recall means retrieval misses content (fix chunking, embeddings, top_k). Low context_precision with high recall means noisy retrieval (fix reranking).
from ragas import evaluate, EvaluationDataset
from ragas.metrics import (
Faithfulness, AnswerRelevancy, LLMContextPrecisionWithReference, LLMContextRecall,
)
# 1. Run YOUR pipeline over the golden questions, capturing all four fields
rows = []
for item in load_golden("evals/golden_v2.jsonl"):
result = rag_pipeline.query(item["question"])
rows.append({
"user_input": item["question"],
"response": result.answer,
"retrieved_contexts": [c.text for c in result.chunks],
"reference": item["ground_truth"],
})
dataset = EvaluationDataset.from_list(rows)
# 2. Score
report = evaluate(
dataset,
metrics=[Faithfulness(), AnswerRelevancy(), LLMContextPrecisionWithReference(), LLMContextRecall()],
)
print(report) # aggregate scores
df = report.to_pandas() # per-row scores for failure triage
df[df["faithfulness"] < 0.7].to_json("faithfulness_failures.json", orient="records")
# evals/test_rag_gate.py (pytest wrapper around ragas)
import pytest
THRESHOLDS = {
"faithfulness": 0.85,
"answer_relevancy": 0.80,
"llm_context_precision_with_reference": 0.75,
"context_recall": 0.80,
}
def test_rag_quality_gate(ragas_report): # fixture runs evaluate() once
scores = ragas_report._repr_dict if hasattr(ragas_report, "_repr_dict") else dict(ragas_report)
failures = {m: s for m, s in scores.items() if m in THRESHOLDS and s < THRESHOLDS[m]}
assert not failures, f"RAG gate failed: {failures}"
Gate policy: PR runs use a 25-question stratified sample (mix of easy, hard, adversarial, out-of-scope questions); nightly runs the full set and writes scores to a tracked JSON so trends are diffable in git.
Ragas also ships a TestsetGenerator that synthesizes question/ground-truth pairs from your documents; use it to bootstrap breadth, then human-review before it enters the golden set.
For any change (chunk size, embedding model, top_k, reranker, prompt, generator model):
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ragas, rag, llm-evals, faithfulness, context-precision, context-recall, retrieval, python
npx claudepluginhub hackernoon/cuttlefish-agent-skills --plugin qa-testing422 skills in this plugin
/a-b-test-validationA/B Test ValidationValidating A/B test implementations including traffic splitting accuracy, statistical significance calculation, metric tracking, and experiment cleanup./accessibility-a11y-enhancedAccessibility A11y EnhancedComprehensive WCAG compliance and accessibility testing covering ARIA, keyboard navigation, screen readers, color contrast, and automated a11y validation./add-seed-skillsUse when adding or editing QA skills in seed-skills/ or getting them onto the live qaskills.sh catalog, e.g. "add N new skills", "create a seed skill for X", "seed the database", "the skill page is empty", "skill 404s on the site".