rag-expert

rag-expert is a skill for Claude Code from personamanagmentlayer/pcl. It costs 97 tokens per session (2,474 once invoked), scanned A, original, Apache-2.0.

A guide to retrieval-augmented generation, or RAG: an AI system searches a collection of documents and gives the relevant passages to a language model before it answers. It covers splitting documents, embeddings, vector and keyword search, reranking, grounding, and evaluation.

In plain words
What is it for?
Use it to design document-question-answering systems, choose a search method, improve chunking, and measure retrieval and answer quality.
Why use it?
It helps make answers depend on your own source material rather than only on the model's built-in knowledge, and helps diagnose missing or irrelevant retrieved text.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it to design document-question-answering systems, choose a search method, improve chunking, and measure retrieval and answer quality.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/personamanagmentlayer/pcl/rag-expert
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.

Any agent
npx skills add personamanagmentlayer/pcl --skill rag-expert
Clone the repo
git clone --depth 1 https://github.com/personamanagmentlayer/pcl

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/personamanagmentlayer/pcl/rag-expert/github.svg)](https://agentmods.dev/skills/personamanagmentlayer/pcl/rag-expert)
Your own site
<a href="https://agentmods.dev/skills/personamanagmentlayer/pcl/rag-expert"><img src="https://agentmods.dev/badge/skills/personamanagmentlayer/pcl/rag-expert/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rag-expert

Your own site · 80×15
<a href="https://agentmods.dev/skills/personamanagmentlayer/pcl/rag-expert"><img src="https://agentmods.dev/badge/skills/personamanagmentlayer/pcl/rag-expert.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 97 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,474 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.00097 $0.02474
Opus 5 $0.00048 $0.01237
Sonnet 5 $0.00019 $0.00495
Haiku 4.5 $0.00010 $0.00247

Measured 4d ago against content hash 1bc804d7debb, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

rag-expert 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 4d 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.

stdlib/ai/rag-expert/SKILL.md · 290 lines

How it starts

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

RAG Expert

Retrieval-augmented generation answers from your corpus rather than from model memory. Almost every failure is a retrieval failure: the model cannot ground an answer in a passage it was never given.

Core Concepts

The Pipeline

ingest → chunk → embed → index
                              ↘
query → rewrite → retrieve → rerank → assemble context → generate → cite

Debug it in that order. When answers are wrong, look at what was retrieved before touching the prompt — the passage is usually missing, not misread.

Retrieval Quality Sets the Ceiling

Generation cannot exceed retrieval. Measure them separately: recall@k for retrieval, groundedness for generation. Conflating the two produces months of prompt tuning against a chunking problem.

Semantic Search Is Not Search

Embeddings capture similarity of meaning, which is exactly wrong for exact identifiers, error codes, product SKUs and rare terms. Vector-only retrieval reliably fails on ERR_4021 and on surnames. Hybrid retrieval — dense plus lexical — is the default, not an optimisation.

Chunking Is the Highest-Leverage Decision

The chunk is the unit of retrieval and the unit of context. Too small and it loses the meaning that makes it findable; too large and it dilutes the embedding and wastes budget.

Chunking

Split on structure first, size second. Markdown headings, HTML sections, legal articles and code functions are natural boundaries; a fixed character count is a fallback, not a strategy.

def chunk_markdown(doc: str, target: int = 900, overlap: int = 120) -> list[Chunk]:
    """Split on headings, then pack sections up to a target size."""
    sections = split_on_headings(doc)          # keeps the heading with its body
    chunks, buffer, heading_path = [], "", []

    for section in sections:
        if len(buffer) + len(section.text) > target and buffer:
            chunks.append(Chunk(text=buffer, heading_path=list(heading_path)))
            buffer = buffer[-overlap:]         # carry context across the seam
        heading_path = section.heading_path
        buffer += section.text

    if buffer.strip():
        chunks.append(Chunk(text=buffer, heading_path=list(heading_path)))
    return chunks

Read the full file on GitHub · 290 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 290 lines · 97 tokens per session scan A 1bc804d7debb

Subscribe to this mod's changes

rag-expert is a skill published in the GitHub repository personamanagmentlayer/pcl (40 stars, last pushed 2d ago), licensed Apache-2.0. It adds 97 tokens to every session and 2,474 once invoked, about $0.0005 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-05.

Related

Other skills, from other repositories

rag-retrieval

Retrieval-Augmented Generation patterns for grounded LLM responses. Use when building RAG pipelines, embedding documents, implementing hybrid search, contextual retrieval, HyDE, agentic RAG, multimodal RAG, query decomposition, reranking, or pgvector search.

yonatangross/orchestkit · 58 tokens

rag

Use when building grounded Q&A over your own corpus — chunk, retrieve hybrid, rerank, ground, cite chunk ids, refuse when the sources fall short — or when the right document is retrieved but the answer is still wrong, invented, or unmeasured. NOT operating the store itself — collection schema, HNSW efsearch…

ericrisco/rsc-harness · 79 tokens

RAG Chunking Strategy Advisor

Given a document type and retrieval goal, recommends the optimal chunking strategy for a RAG pipeline to minimize retrieval failures.

Notysoty/openagentskills · 31 tokens

nemotron-retrieval-recipes

Use when planning, debugging, tuning, evaluating, exporting, or deploying public Nemotron embed/rerank retrieval recipes.

NVIDIA-NeMo/Nemotron · 36 tokens

embeddings-search

Use when choosing an embedding model, chunk size, or query form, when semantic search returns irrelevant results, when adding hybrid BM25+vector or a reranker, or when a retrieval change needs a number (recall@k, nDCG, MRR). NOT operating the store — index tuning, quantization (that is vector-db) — nor the…

ericrisco/rsc-harness · 88 tokens

qdrant-vector-search

High-performance vector similarity search engine for RAG and semantic search. Use when building production RAG systems requiring fast nearest neighbor search, hybrid search with filtering, or scalable vector storage with Rust-powered performance.

davila7/claude-code-templates · 46 tokens