debug-rag

debug-rag is a skill for Claude Code from TakaGoto/rag-learning-academy. It costs 13 tokens per session (1,413 once invoked), scanned A, original, MIT.

A guided troubleshooting workflow for RAG systems, where RAG retrieves source documents before an answer is generated. It helps identify common problems such as irrelevant or missing context, unsupported answers, contradictions, incomplete responses, and slow performance.

In plain words
What is it for?
Use it when a RAG pipeline hallucinates, retrieves the wrong information, misses relevant documents, gives incomplete or repetitive answers, returns the wrong format, or responds too slowly.
Why use it?
It turns a vague bad result into a specific failure mode that can be investigated. The process also explains the diagnosis while working toward a fix.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/takagoto/rag-learning-academy/debug-rag
Any agent
npx skills add TakaGoto/rag-learning-academy --skill debug-rag
Clone the repo
git clone --depth 1 https://github.com/TakaGoto/rag-learning-academy

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for debug-rag

README.md
[![agentmods](https://agentmods.dev/badge/skills/takagoto/rag-learning-academy/debug-rag.svg)](https://agentmods.dev/skills/takagoto/rag-learning-academy/debug-rag)
Your own site
<a href="https://agentmods.dev/skills/takagoto/rag-learning-academy/debug-rag"><img src="https://agentmods.dev/badge/skills/takagoto/rag-learning-academy/debug-rag.svg" alt="Measured on agentmods" height="20"></a>
Per session 13 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,413 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00013 $0.01413
Opus 5 $0.00006 $0.00707
Sonnet 5 $0.00003 $0.00283
Haiku 4.5 $0.00001 $0.00141

Measured 6d ago against content hash 197c76bc06c6, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

debug-rag scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/debug-rag/SKILL.md · 114 lines

How it starts

The opening of the file, as written. The whole thing — 114 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Debug RAG: Diagnose and Fix Pipeline Issues

Scope: This skill teaches debugging through guided diagnosis and explanation. For a fast fix without the teaching, use /fix.

An interactive debugging workflow that helps learners identify and resolve common RAG failure modes. This skill builds debugging intuition alongside technical problem-solving.

Language awareness: See .claude/LANGUAGE_AWARENESS.md.

Step 1: Identify the Symptom

Ask the learner to describe the problem they are seeing. Common symptoms include:

  1. Hallucination: The model generates information not in the retrieved context
  2. Irrelevant retrieval: The retrieved documents do not match the query
  3. Missing context: Relevant information exists in the corpus but is not retrieved
  4. Incomplete answers: The answer is partially correct but missing key details
  5. Contradictory answers: The answer contradicts the source documents
  6. Repetitive or generic responses: The model ignores context and gives generic answers
  7. Wrong format: The answer is correct but not in the expected format
  8. High latency: The pipeline is too slow

If the learner is not sure, ask them to share an example query, the expected answer, and the actual answer.

Step 2: Follow the Diagnostic Tree

Based on the symptom, walk through the appropriate diagnostic path:

For Retrieval Issues (irrelevant results, missing context)

Start by inspecting what the retriever actually returns:

Provide diagnostic code in the learner's chosen language that retrieves results and prints scores, sources, and text previews.

  1. Check the query: Is the query well-formed? Try rephrasing it.
  2. Inspect chunks: Look at the actual chunks in the vector store. Are they the right size? Do they contain the expected information?
  3. Test embedding similarity: Compute the similarity between the query embedding and the expected chunk embedding. Is it above the retrieval threshold?
  4. Check top-k: Are you retrieving enough documents? Try increasing top-k.
  5. Examine metadata filters: Are any filters accidentally excluding relevant results?
  6. Compare search methods: Try keyword search alongside vector search to see if the issue is in the embeddings.

Read the full file on GitHub · 114 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 114 lines · 13 tokens per session scan A 197c76bc06c6

Subscribe to this mod's changes

debug-rag is a skill published in the GitHub repository TakaGoto/rag-learning-academy (18 stars, last pushed 5mo ago), licensed MIT. It adds 13 tokens to every session and 1,413 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

rag-blueprint

NVIDIA RAG Blueprint — deploy, configure, troubleshoot, and manage. Handles any RAG action: deploy, install, start, enable, disable, toggle, change, configure, troubleshoot, debug, fix, shutdown, stop, or tear down any RAG feature or service (Agentic RAG, VLM, guardrails, query rewriting, models, search, ingestion…

NVIDIA-AI-Blueprints/rag · 92 tokens

debug-evals

Debug haiku.rag evaluation runs in Logfire. Use when asked to look at Logfire for an eval run, find failing or low-scoring eval cases, compare runs, check citation quality (citedmap) or judge pass rate (answerequivalent), or explain why an eval case failed. Drives the Logfire MCP against the evals service, or the…

ggozad/haiku.rag · 103 tokens

debug-ingestion

Debug haiku.rag ingestion in Logfire. Use when asked to look at Logfire for ingestion, find failed or dead ingestion jobs, investigate retries or circuit-breaker events, trace a document through convert/chunk/embed/store, find which docling-serve instance served a request, spot slow conversions, or tell concurrent…

ggozad/haiku.rag · 87 tokens

rag-index-decisions

After making a non-obvious architectural decision, solving a novel bug, agreeing on a coding standard, or reaching a conclusion worth remembering, index it back into the knowledge base so the next occurrence is one search away. Uses adddocument or addfromurl. Closes the feedback loop that makes a RAG-backed team…

lyonzin/knowledge-rag · 72 tokens

rag-troubleshoot

When the user reports a bug, error message, stack trace, unexpected behavior, or "why is this broken" question, search the corpus first for prior occurrences, known fixes, or related runbooks. Prevents re-solving problems the team already solved. Trigger on any error signature, exception name, stack trace snippet, or…

lyonzin/knowledge-rag · 78 tokens

retrieval-system-audit

Audit and improve stellar-raven-codemode retrieval across every exposed service operation and skill. Use for comprehensive endpoint, response-shape, catalog-description, search-ranking, execute-grounding, evaluation-coverage, golden-truth, or cross-source weighting reviews that require live probes and measured A/B…

stellar-experimental/stellar-raven · 66 tokens