rag-implementation

A guide to building RAG systems, which answer questions by retrieving relevant information from documents before generating a response. It covers document splitting, text-embedding models, vector databases, and retrieval quality.

In plain words
What is it for?
Use it to build document search, semantic search, or RAG pipelines; choose a vector database or embedding model; design chunking; add hybrid search; and improve retrieval or production deployment.
Why use it?
It helps developers choose suitable search components and diagnose poor retrieval or slow vector-database performance. A vector database stores numerical representations of text so related content can be found by meaning.

Skill for Claude CodeCodex

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/stefan-jansen/claude-code-toolkit/rag-implementation
Any agent
npx skills add stefan-jansen/claude-code-toolkit --skill rag-implementation
Clone the repo
git clone --depth 1 https://github.com/stefan-jansen/claude-code-toolkit

Made for: Claude Code, Codex.

Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,565 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 $0.00050 $0.05565
Opus 5 $0.00025 $0.02782
Sonnet 5 $0.00010 $0.01113
Haiku 4.5 $0.00005 $0.00556

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

Security

Grade A, and why

rag-implementation 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.

skills/rag-implementation/SKILL.md · 866 lines

How it starts

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

RAG Implementation Patterns

Comprehensive guide to implementing Retrieval-Augmented Generation (RAG) systems including vector database selection, chunking strategies, embedding models, retrieval optimization, and production deployment patterns.


Quick Reference

When to use this skill:

  • Building RAG/semantic search systems
  • Implementing document retrieval pipelines
  • Optimizing vector database performance
  • Debugging retrieval quality issues
  • Choosing between vector database options
  • Designing chunking strategies
  • Implementing hybrid search

Technologies covered:

  • Vector DBs: Qdrant, Pinecone, Chroma, Weaviate, Milvus
  • Embeddings: OpenAI, Sentence Transformers, Cohere
  • Frameworks: LangChain, LlamaIndex, Haystack

Part 1: Vector Database Selection

Database Comparison Matrix

Database Best For Deployment Performance Cost
Qdrant Self-hosted, production Docker/K8s Excellent (Rust) Free (self-host)
Pinecone Managed, rapid prototyping Cloud Excellent Pay-per-use
Chroma Local development, embedded In-process Good (Python) Free
Weaviate Complex schemas, GraphQL Docker/Cloud Excellent (Go) Free + Cloud
Milvus Large-scale, distributed K8s Excellent (C++) Free (self-host)

Qdrant Setup (Recommended for Production)

from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams, PointStruct

# Initialize client (local or cloud)
client = QdrantClient(url="http://localhost:6333")  # or cloud URL

# Create collection
client.create_collection(
    collection_name="documents",
    vectors_config=VectorParams(
        size=1536,  # OpenAI text-embedding-3-small dimension
        distance=Distance.COSINE  # or DOT, EUCLID
    )
)

# Insert vectors with payload
client.upsert(
    collection_name="documents",
    points=[
        PointStruct(
            id=1,
            vector=[0.1, 0.2, ...],  # 1536 dimensions
            payload={
                "text": "Document content",
                "source": "doc.pdf",
                "page": 1,
                "metadata": {...}
            }
        )
    ]
)

# Search
results = client.search(
    collection_name="documents",
    query_vector=[0.1, 0.2, ...],
    limit=5,
    score_threshold=0.7  # Minimum similarity
)

Read the full file on GitHub · 866 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. 2d ago First seen · 866 lines · 50 tokens per session scan A f3ca89bb6e2a

Subscribe to this mod's changes

rag-implementation is a skill published in the GitHub repository stefan-jansen/claude-code-toolkit (85 stars, last pushed 1mo ago), licensed MIT. It adds 50 tokens to every session and 5,565 once invoked, about $0.0003 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.