rag

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

A pattern for answering questions by finding relevant information in documents or data before generating a response. RAG means retrieval-augmented generation.

In plain words
What is it for?
Use it to build document question-answering, knowledge-base search, vector search, or enterprise agents that need accurate source-based responses.
Why use it?
It grounds answers in current, private, or specialist sources instead of relying only on the model's stored knowledge, reducing unsupported answers.

Skill for Claude CodeCodex

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

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/hajekim/agentic-design-patterns-extension/rag
Any agent
npx skills add hajekim/agentic-design-patterns-extension --skill rag
Clone the repo
git clone --depth 1 https://github.com/hajekim/agentic-design-patterns-extension

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-extension/rag.svg)](https://agentmods.dev/skills/hajekim/agentic-design-patterns-extension/rag)
Your own site
<a href="https://agentmods.dev/skills/hajekim/agentic-design-patterns-extension/rag"><img src="https://agentmods.dev/badge/skills/hajekim/agentic-design-patterns-extension/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,391 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod 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.04391
Opus 5 $0.00211 $0.02195
Sonnet 5 $0.00084 $0.00878
Haiku 4.5 $0.00042 $0.00439

Measured 6d ago against content hash 98362dbec31e, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 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.

Origin

This is a copy

100% identical to rag — 3 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/rag/SKILL.md · 480 lines

How it starts

The opening of the file, as written. The whole thing — 480 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 · 480 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 · 480 lines · 421 tokens per session scan A 98362dbec31e

Subscribe to this mod's changes

rag is a skill published in the GitHub repository hajekim/agentic-design-patterns-extension (1 stars, last pushed 5mo ago), licensed MIT. It adds 421 tokens to every session and 4,391 once invoked, about $0.0021 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to rag, differing in 3 lines, and is treated as a copy.

Related

Other skills, from other repositories

help

Overview of all available Pinecone skills and what a user needs to get started. Invoke when a user asks what skills are available, how to get started with Pinecone, or what they need to set up before using any Pinecone skill.

pinecone-io/gemini-cli-extension · 50 tokens

index

Use when the user wants to index their vault for semantic search, rebuild the RAG index, or says "index", "reindex", or "rebuild index".

thoreinstein/gemini-obsidian · 36 tokens

assistant

Create, manage, and chat with Pinecone Assistants for document Q&A with citations. Handles all assistant operations - create, upload, sync, chat, context retrieval, and list. Recognizes natural language like "create an assistant from my docs", "ask my assistant about X", or "upload my docs to Pinecone".

pinecone-io/gemini-cli-extension · 68 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-skills · 421 tokens

quickstart

Interactive Pinecone quickstart for new developers. Choose between two paths - Database (create an integrated index, upsert data, and query using Pinecone MCP + Python) or Assistant (create a Pinecone Assistant for document Q&A). Use when a user wants to get started with Pinecone for the first time or wants a guided…

pinecone-io/gemini-cli-extension · 76 tokens

cli

Guide for using the Pinecone CLI (pc) to manage Pinecone resources from the terminal. The CLI supports ALL index types (standard, integrated, sparse) and all vector operations — unlike the MCP which only supports integrated indexes. Use for batch operations, vector management, backups, namespaces, CI/CD automation…

pinecone-io/gemini-cli-extension · 72 tokens