rag-debug

rag-debug is a command for Claude Code from latestaiagents/agent-skills. It costs 11 tokens per session (407 once invoked), scanned A, original, MIT.

A diagnostic guide for finding problems in a RAG pipeline, from the user's query through document retrieval and answer generation.

In plain words
What is it for?
Use it to inspect queries, similarity scores, retrieved context, prompts, hallucinations, and possible fixes.
Why use it?
It helps identify whether poor answers come from missing documents, bad chunking, weak search results, ineffective prompts, or unsupported answers.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the rag-architect plugin — 7 skills, 3 commands shipped together

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 commands/latestaiagents/agent-skills/rag-debug
Clone the repo
git clone --depth 1 https://github.com/latestaiagents/agent-skills

Made for: Claude Code.

Or install rag-architect, the plugin that ships this one along with the rest of its 7 skills, 3 commands.

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 rag-debug

README.md
[![agentmods](https://agentmods.dev/badge/commands/latestaiagents/agent-skills/rag-debug.svg)](https://agentmods.dev/commands/latestaiagents/agent-skills/rag-debug)
Your own site
<a href="https://agentmods.dev/commands/latestaiagents/agent-skills/rag-debug"><img src="https://agentmods.dev/badge/commands/latestaiagents/agent-skills/rag-debug.svg" alt="Measured on agentmods" height="20"></a>
Per session 11 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 407 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.00011 $0.00407
Opus 5 $0.00005 $0.00204
Sonnet 5 $0.00002 $0.00081
Haiku 4.5 $0.00001 $0.00041

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

Security

Grade A, and why

rag-debug 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 2d 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.

plugins/rag-architect/commands/rag-debug.md · 81 lines

What it actually says

/rag-debug

Diagnose and fix RAG pipeline problems with systematic analysis.

What I Need

Tell me:

  • What query is producing poor results?
  • What answer did you expect vs what you got?
  • Which vector store are you using?

How It Works

Step 1: Query Analysis

I'll analyze your query to identify potential issues:

  • Query clarity and specificity
  • Potential keyword/semantic mismatch
  • Query complexity (single vs multi-hop)

Step 2: Retrieval Diagnosis

I'll check retrieval quality:

  • Are relevant documents in your index?
  • What's the similarity score distribution?
  • Are chunks properly sized?

Step 3: Generation Analysis

I'll examine the generation step:

  • Is context being used correctly?
  • Are there hallucinations?
  • Is the prompt template effective?

Step 4: Fix Recommendations

Based on findings, I'll recommend:

  • Chunking adjustments
  • Retrieval strategy changes
  • Prompt improvements
  • Hybrid search additions

Debug Checklist

[ ] Query understood correctly?
[ ] Documents indexed?
[ ] Chunks contain answer?
[ ] Top-k retrieving relevant docs?
[ ] Context passed to LLM?
[ ] LLM using context?
[ ] Answer grounded?

Common Issues & Fixes

Symptom Likely Cause Fix
Wrong docs retrieved Semantic gap Add hybrid search
Right docs, wrong answer Poor prompt Improve system prompt
Partial answer Chunk boundary Adjust overlap
Hallucination Context ignored Add grounding check
No answer Missing docs Check indexing

Quick Commands

# Test retrieval only
retriever.invoke("your query")

# Check similarity scores
vectorstore.similarity_search_with_score("query", k=10)

# Inspect chunk content
for doc in results: print(doc.page_content[:200])
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. 2d ago First seen · 81 lines · 11 tokens per session scan A 236cc2c74337

Subscribe to this mod's changes

rag-debug is a command published in the GitHub repository latestaiagents/agent-skills (5 stars, last pushed 4mo ago), licensed MIT. It adds 11 tokens to every session and 407 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-09-03.