build-rag

build-rag is a command for Claude Code from latestaiagents/agent-skills. It costs 12 tokens per session (506 once invoked), scanned A, original, MIT.

A step-by-step guide for building a RAG pipeline, which lets an AI answer questions using information retrieved from your documents or data.

In plain words
What is it for?
Use it to plan document processing, embeddings, vector search, prompts, citations, and quality checks for a RAG system.
Why use it?
It turns a broad RAG project into concrete stages, from loading documents and creating a searchable index to generating and evaluating answers.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the rag-plugin plugin — 7 skills, 3 commands shipped together

Good fit Use it to plan document processing, embeddings, vector search, prompts, citations, and quality checks for a RAG system.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/latestaiagents/agent-skills/build-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.

Clone the repo
git clone --depth 1 https://github.com/latestaiagents/agent-skills

Made for: Claude Code.

Or install rag-plugin, the plugin that ships this one along with the rest of its 7 skills, 3 commands.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/latestaiagents/agent-skills/build-rag/github.svg)](https://agentmods.dev/commands/latestaiagents/agent-skills/build-rag)
Your own site
<a href="https://agentmods.dev/commands/latestaiagents/agent-skills/build-rag"><img src="https://agentmods.dev/badge/commands/latestaiagents/agent-skills/build-rag/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 build-rag

Your own site · 80×15
<a href="https://agentmods.dev/commands/latestaiagents/agent-skills/build-rag"><img src="https://agentmods.dev/badge/commands/latestaiagents/agent-skills/build-rag.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 12 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 506 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.00012 $0.00506
Opus 5.5 $0.00005 $0.00202
Sonnet 5.5 $0.00002 $0.00101
Haiku 4.5 $0.00001 $0.00051

Measured 27d ago against content hash 87c8066782c7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

build-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 27d 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.

plugins/rag-architect/commands/build-rag.md · 91 lines

How it starts

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

/build-rag

Build a complete RAG pipeline with best practices.

What I Need

Tell me:

  • What documents/data will you be querying?
  • What's your use case (Q&A, search, chatbot)?
  • Any technology preferences (LangChain, LlamaIndex, custom)?
  • Scale expectations (documents, queries/day)?

Workflow

Step 1: Document Processing

I'll help you set up:

  • Document loading (PDF, web, database)
  • Chunking strategy based on content type
  • Metadata extraction

Step 2: Embedding & Indexing

We'll configure:

  • Embedding model selection
  • Vector store setup
  • Index optimization

Step 3: Retrieval Pipeline

I'll implement:

  • Basic vector search
  • Hybrid search (if needed)
  • Reranking layer

Step 4: Generation

We'll build:

  • Prompt template
  • Context formatting
  • Citation handling

Step 5: Evaluation

I'll set up:

  • Test dataset creation
  • Retrieval metrics
  • Quality monitoring

Architecture Options

Simple RAG:

Query → Embed → Search → Context → Generate → Answer

Production RAG:

Query → Cache Check → Hybrid Search → Rerank → Generate → Validate → Cache → Answer

Quick Start Templates

LangChain:

from langchain_chroma import Chroma  # pip install langchain-chroma
from langchain_openai import OpenAIEmbeddings, ChatOpenAI

vectorstore = Chroma.from_documents(docs, OpenAIEmbeddings())
retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
llm = ChatOpenAI(model=CHAT_MODEL)  # CHAT_MODEL from your config

def answer(question: str) -> str:
    context = "\n\n".join(d.page_content for d in retriever.invoke(question))
    prompt = f"Answer using only this context. If it is not there, say so.\n\n{context}\n\nQuestion: {question}"
    return llm.invoke(prompt).content

LlamaIndex:

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()

Read the full file on GitHub · 91 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. 27d ago Changed · +2 lines 87c8066782c7
  2. 2mo ago First seen · 89 lines · 12 tokens per session scan A e542e3b3640c

Subscribe to this mod's changes

build-rag is a command published in the GitHub repository latestaiagents/agent-skills (6 stars, last pushed 27d ago), licensed MIT. It adds 12 tokens to every session and 506 once invoked, about $0.0000 per session on Opus 5.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-03.

Related

build-rag compared with commands from other repositories

build-rag next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
build-raglatestaiagents/agent-skillsCommand627d agoMITA12Claude Code
datasetnvk/llm-wikiCommand1.6k1mo agoMITA30Claude Code
aiolehsvyrydov/AI-development-teamCommand1811d agoMITA29Claude Code
fdk-refactorfreshworks-developers/fw-dev-toolsCommand62mo agoMITA41Claude Code
checklistgithub/spec-kitCommand153ktodayMITA13Claude Code
clarifygithub/spec-kitCommand153ktodayMITA27Claude Code
specifygithub/spec-kitCommand153ktodayMITA13Claude Code