New to Claude Skills? Learn how to install them →

wshobson on GitHub

RAG Implementation

Free

Build knowledge-grounded AI systems with RAG.

by wshobson38.7k stars on wshobson/agents
1 views
Updated Jul 18, 2026
Get this skill

Free · Opens the source repo

What RAG Implementation does

The RAG Implementation skill enables developers to create Retrieval-Augmented Generation (RAG) systems that enhance large language model (LLM) applications by integrating external knowledge sources. This skill is particularly useful for building Q&A systems, chatbots, and semantic search applications that require accurate and up-to-date information. By leveraging vector databases and embeddings, users can implement solutions that reduce hallucinations and provide grounded responses based on real-world data.

At the core of this skill are several essential components, including vector databases like Pinecone and Weaviate, which efficiently store and retrieve document embeddings. Additionally, a variety of embedding models are available to convert text into numerical vectors for similarity searches. The skill also supports multiple retrieval strategies, such as dense and sparse retrieval, allowing for flexible and effective information retrieval tailored to specific use cases.

The RAG Implementation skill is ideal for developers and designers looking to enhance their applications with knowledge-driven capabilities. It provides the necessary tools to access domain-specific information, create documentation assistants, and develop research tools that require source citation. With a focus on practical implementation, this skill offers a structured approach to building robust AI systems that can deliver accurate responses based on external knowledge.

Whether you are working on proprietary document Q&A systems or chatbots that need to remain current with factual information, the RAG Implementation skill equips you with the resources needed to successfully integrate LLMs with external knowledge bases, ensuring that your applications are both reliable and informative.

When to use it

Use this skill when developing systems that require accurate information retrieval, such as Q&A systems or chatbots.

When not to use it

This skill is not suitable for applications that do not require external knowledge integration or for basic LLM tasks that do not need grounding in factual data.

What you can build with it

Building a Document Q&A System

Utilize RAG to create a system that answers questions based on proprietary documents, ensuring accurate and relevant responses.

Creating a Knowledge-Driven Chatbot

Develop a chatbot that retrieves and provides factual information from external sources, improving user interactions with up-to-date content.

Implementing Semantic Search Functionality

Leverage RAG to enhance search capabilities, allowing users to query documents in natural language and receive contextually relevant results.

How to install RAG Implementation

View source

1. Install with the skills CLI

npx skills add wshobson/agents/rag-implementation --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by wshobson

RAG Implementation

Master Retrieval-Augmented Generation (RAG) to build LLM applications that provide accurate, grounded responses using external knowledge sources.

When to Use This Skill

  • Building Q&A systems over proprietary documents
  • Creating chatbots with current, factual information
  • Implementing semantic search with natural language queries
  • Reducing hallucinations with grounded responses
  • Enabling LLMs to access domain-specific knowledge
  • Building documentation assistants
  • Creating research tools with source citation

Core Components

1. Vector Databases

Purpose: Store and retrieve document embeddings efficiently

Options:

  • Pinecone: Managed, scalable, serverless
  • Weaviate: Open-source, hybrid search, GraphQL
  • Milvus: High performance, on-premise
  • Chroma: Lightweight, easy to use, local development
  • Qdrant: Fast, filtered search, Rust-based
  • pgvector: PostgreSQL extension, SQL integration

2. Embeddings

Purpose: Convert text to numerical vectors for similarity search

Models (2026):

ModelDimensionsBest For
voyage-3-large1024Claude apps (Anthropic recommended)
voyage-code-31024Code search
text-embedding-3-large3072OpenAI apps, high accuracy
text-embedding-3-small1536OpenAI apps, cost-effective
bge-large-en-v1.51024Open source, local deployment
multilingual-e5-large1024Multi-language support

3. Retrieval Strategies

Approaches:

  • Dense Retrieval: Semantic similarity via embeddings
  • Sparse Retrieval: Keyword matching (BM25, TF-IDF)
  • Hybrid Search: Combine dense + sparse with weighted fusion
  • Multi-Query: Generate multiple query variations
  • HyDE: Generate hypothetical documents for better retrieval

4. Reranking

Purpose: Improve retrieval quality by reordering results

Methods:

  • Cross-Encoders: BERT-based reranking (ms-marco-MiniLM)
  • Cohere Rerank: API-based reranking
  • Maximal Marginal Relevance (MMR): Diversity + relevance
  • LLM-based: Use LLM to score relevance

Quick Start with LangGraph

from langgraph.graph import StateGraph, START, END
from langchain_anthropic import ChatAnthropic
from langchain_voyageai import VoyageAIEmbeddings
from langchain_pinecone import PineconeVectorStore
from langchain_core.documents import Document
from langchain_core.prompts import ChatPromptTemplate
from langchain_text_splitters import RecursiveCharacterTextSplitter
from typing import TypedDict, Annotated

class RAGState(TypedDict):
    question: str
    context: list[Document]
    answer: str

# Initialize components
llm = ChatAnthropic(model="claude-sonnet-5")
embeddings = VoyageAIEmbeddings(model="voyage-3-large")
vectorstore = PineconeVectorStore(index_name="docs", embedding=embeddings)
retriever = vectorstore.as_retriever(search_kwargs={"k": 4})

# RAG prompt
rag_prompt = ChatPromptTemplate.from_template(
    """Answer based on the context below. If you cannot answer, say so.

    Context:
    {context}

    Question: {question}

    Answer:"""
)

async def retrieve(state: RAGState) -> RAGState:
    """Retrieve relevant documents."""
    docs = await retriever.ainvoke(state["question"])
    return {"context": docs}

async def generate(state: RAGState) -> RAGState:
    """Generate answer from context."""
    context_text = "\n\n".join(doc.page_content for doc in state["context"])
    messages = rag_prompt.format_messages(
        context=context_text,
        question=state["question"]
    )
    response = await llm.ainvoke(messages)
    return {"answer": response.content}

# Build RAG graph
builder = StateGraph(RAGState)
builder.add_node("retrieve", retrieve)
builder.add_node("generate", generate)
builder.add_edge(START, "retrieve")
builder.add_edge("retrieve", "generate")
builder.add_edge("generate", END)

rag_chain = builder.compile()

# Use
result = await rag_chain.ainvoke({"question": "What are the main features?"})
print(result["answer"])

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Frequently asked questions about RAG Implementation

Similar skills