rag

rag is a skill for Claude Code, Codex from hajekim/agentic-design-patterns-skills. It costs 421 tokens per session (4,390 once invoked), scanned A, original, MIT.

A method for answering questions by retrieving relevant documents or data before generating a response; it is also called retrieval-augmented generation.

In plain words
What is it for?
Use it for document question-answering, knowledge bases, technical or regulated information, and responses that need sources.
Why use it?
It grounds answers in current or private source material instead of relying only on the model's stored knowledge.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for document question-answering, knowledge bases, technical or regulated information, and responses that need sources.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hajekim/agentic-design-patterns-skills/rag
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 hajekim/agentic-design-patterns-skills --skill rag
Clone the repo
git clone --depth 1 https://github.com/hajekim/agentic-design-patterns-skills

Made for: Claude Code, Codex.

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/hajekim/agentic-design-patterns-skills/rag.svg)](https://agentmods.dev/skills/hajekim/agentic-design-patterns-skills/rag)
Your own site
<a href="https://agentmods.dev/skills/hajekim/agentic-design-patterns-skills/rag"><img src="https://agentmods.dev/badge/skills/hajekim/agentic-design-patterns-skills/rag.svg" alt="Measured on agentmods" height="20"></a>
Per session 421 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,390 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.
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.00421 $0.04390
Opus 5 $0.00211 $0.02195
Sonnet 5 $0.00084 $0.00878
Haiku 4.5 $0.00042 $0.00439

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

Security

Grade A, and why

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 8d 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

  • rag — 100% identical, 3 lines differ
skills/rag/SKILL.md · 479 lines

How it starts

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

Retrieval-Augmented Generation (RAG) Pattern

Overview

The Retrieval-Augmented Generation (RAG) Pattern grounds agent responses in external, up-to-date knowledge by retrieving relevant documents or data before generating a response. Rather than relying solely on knowledge baked into model weights (which has a training cutoff and may hallucinate), RAG agents dynamically fetch the most relevant context and use it to produce accurate, grounded responses.

Core Principle: Don't hallucinate what you can retrieve — anchor every response in verifiable, retrieved knowledge.

When This Skill Applies

Activate this pattern when:

  • The agent needs domain-specific knowledge not in the base LLM's training
  • Responses must be grounded in authoritative documents (legal, medical, technical)
  • Information changes frequently and training data is stale
  • Users need citations and sources for claims made
  • Private or proprietary knowledge must be accessed securely
  • Reducing hallucination is a critical requirement

Rule of thumb: If the answer exists in a document and you need it to be accurate and verifiable — use RAG.

RAG Architecture

Standard RAG Pipeline

Query → [Embedding] → Vector Search → Retrieved Chunks
                                              ↓
                                   LLM + Retrieved Context
                                              ↓
                                     Grounded Response

Advanced RAG Variants

Variant Description Use Case
Naive RAG Embed query → retrieve → generate Simple Q&A
Advanced RAG Query expansion, reranking, filtering High-accuracy enterprise
Modular RAG Pluggable retrieval strategies Complex, multi-source
Agentic RAG Agent decides when/what to retrieve Dynamic reasoning
Graph RAG Knowledge graph + vector retrieval Complex entity relationships

DEFINE → PLAN → ACTION Workflow

DEFINE

Map the knowledge retrieval requirements:

  1. What knowledge sources need to be indexed? (PDFs, databases, APIs, web)
  2. What query types will users ask? (factual, comparative, analytical)
  3. What is the required accuracy/hallucination tolerance?
  4. How frequently does the knowledge change? (indexing strategy)
  5. What metadata is available for filtering? (date, source, category)

Read the full file on GitHub · 479 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. 8d ago First seen · 479 lines · 421 tokens per session scan A e6c71900720c

Subscribe to this mod's changes

rag is a skill published in the GitHub repository hajekim/agentic-design-patterns-skills (4 stars, last pushed 5mo ago), licensed MIT. It adds 421 tokens to every session and 4,390 once invoked, about $0.0021 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-31.

Related

Other skills, from other repositories

ai-llm-application

Group skill: AI/LLM application — provider selection, app patterns, RAG, agents, prompts, evaluation, safety, and monitoring.

may215/antigravity-awesome-group-skills · 36 tokens

qdrant-edge

Expert guide for building applications with Qdrant Edge — the embedded, offline-capable vector search engine for edge devices (robots, kiosks, mobile phones, IoT, home assistants). Use this skill whenever the user mentions Qdrant Edge, qdrant-edge-py, EdgeShard, on-device vector search, offline vector search, embedded…

gururaser/qdrant-edge-skill · 129 tokens

rag

This skill should be used when the user wants to "retrieval augmented generation", "RAG", "ground agent in documents", "knowledge base search", "vector search for agents", "semantic document retrieval", "augment LLM with external knowledge", "document QA", "knowledge grounding", "enterprise knowledge agent", "PDF…

hajekim/agentic-design-patterns-extension · 421 tokens

ai-engineering-toolkit

6 production-ready AI engineering workflows: prompt evaluation (8-dimension scoring), context budget planning, RAG pipeline design, agent security audit (65-point checklist), eval harness building, and product sense coaching.

sickn33/agentic-awesome-skills · 47 tokens

ai-ml

AI and machine learning workflow covering LLM application development, RAG implementation, agent architecture, ML pipelines, and AI-powered features.

sickn33/agentic-awesome-skills · 30 tokens

arrowspace

Spectral vector search using graph Laplacian eigenstructure. Use when cosine/L2 similarity misses latent structure in your embeddings.

sickn33/agentic-awesome-skills · 28 tokens