build-rag

build-rag is a command for Claude Code from latestaiagents/agent-skills. It costs 12 tokens per session (432 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-architect 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-architect, 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.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.svg" alt="Measured on agentmods" 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 432 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.00432
Opus 5 $0.00006 $0.00216
Sonnet 5 $0.00002 $0.00086
Haiku 4.5 $0.00001 $0.00043

Measured 4d ago against content hash e542e3b3640c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, 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 4d 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 · 89 lines

What it actually says

/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_community.vectorstores import Chroma
from langchain_openai import OpenAIEmbeddings, ChatOpenAI
from langchain.chains import RetrievalQA

vectorstore = Chroma.from_documents(docs, OpenAIEmbeddings())
qa = RetrievalQA.from_chain_type(
    llm=ChatOpenAI(),
    retriever=vectorstore.as_retriever()
)

LlamaIndex:

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
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. 4d 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 (5 stars, last pushed 4mo ago), licensed MIT. It adds 12 tokens to every session and 432 once invoked, about $0.0001 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-09-03.