rag
Skill35 starsChanged 53 days agoApache-2.0View on GitHub
Design RAG (Retrieval-Augmented Generation) pipelines. Use when building knowledge bases, document Q&A, or semantic search systems.
7 other projects use a version of this.
Adopted by
Most recently taken up by
- phucbm/skillstheir own version, first seen Oct 13, 2026
- nimadorostkar/Claude-Skills-collectiontheir own version, first seen Oct 13, 2026
- urmzd/saigetheir own version, first seen Oct 9, 2026
- belos-street/skill-kittheir own version, first seen Sep 16, 2026
- Shugar86/my-agenttheir own version, first seen May 28, 2026
- hajekim/agentic-design-patterns-extensiontheir own version, first seen Apr 1, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- nimadorostkar/Claude-Skills-collection★ 33same name
- belos-street/skill-kit★ 8same name
- urmzd/saige★ 6same name
- hajekim/agentic-design-patterns-skills★ 4same name
- phucbm/skills★ 2same name
- hajekim/agentic-design-patterns-extension★ 1same name
- Shugar86/my-agent★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository23 other files it gives its agents.
The file
Files
/craftsman:rag - Retrieval-Augmented Generation Design
Outcome Contract
- Outcome: a RAG pipeline design with explicit chunking, embedding, and retrieval decisions.
- Done when: chunk strategy, embedding model, and retrieval method are each chosen with a stated reason, and the evaluation method for retrieval quality is defined.
- Evidence: the design decisions listed with their trade-offs, and the evaluation plan.
Design production-ready RAG pipelines following best practices.
RAG Architecture Overview
┌─────────────────────────────────────────────────────────────────┐
│ RAG PIPELINE │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ INGESTION │───▶│ RETRIEVAL │───▶│ GENERATION │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ Documents → Chunks Query → Vectors Context → LLM → Answer │
│ → Embeddings → → Similar Chunks → Response │
│ Vector Store │
│ │
└─────────────────────────────────────────────────────────────────┘Three Pipelines
1. Ingestion Pipeline
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import PGVector
# Chunking Strategy
text_splitter = RecursiveCharacterTextSplitter(
chunk_size=1000, # Characters per chunk
chunk_overlap=200, # Overlap for context
separators=["\n\n", "\n", ". ", " ", ""],
)
# Embedding Model
embeddings = OpenAIEmbeddings(
model="text-embedding-3-small", # Cost-effective
# model="text-embedding-3-large", # Higher quality
)
# Vector Store
vectorstore = PGVector.from_documents(
documents=chunks,
embedding=embeddings,
collection_name="knowledge_base",
connection_string=DATABASE_URL,
)2. Retrieval Pipeline
from langchain.retrievers import ContextualCompressionRetriever
from langchain.retrievers.document_compressors import LLMChainExtractor
# Base Retriever
retriever = vectorstore.as_retriever(
search_type="similarity", # or "mmr" for diversity
search_kwargs={"k": 5}, # Top K results
)
# Optional: Contextual Compression
compressor = LLMChainExtractor.from_llm(llm)
compression_retriever = ContextualCompressionRetriever(
base_compressor=compressor,
base_retriever=retriever,
)3. Generation Pipeline
from langchain.chains import RetrievalQA
from langchain.chat_models import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4-turbo-preview",
temperature=0, # Deterministic for factual answers
)
qa_chain = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff", # or "map_reduce" for long contexts
retriever=retriever,
return_source_documents=True,
)Chunking Strategies
| Strategy | Use Case | Chunk Size |
| Fixed | General text | 500-1000 chars |
| Sentence | Precise retrieval | 1-3 sentences |
| Paragraph | Structured docs | Natural breaks |
| Semantic | Technical docs | Topic boundaries |
| Recursive | Mixed content | Adaptive |
Vector Database Comparison
| Database | Pros | Cons | Best For |
| pgvector | PostgreSQL native, ACID | Scale limits | Small-medium, existing PG |
| Pinecone | Managed, fast | Cost, vendor lock | Production, scale |
| Weaviate | Hybrid search | Complexity | Complex queries |
| Chroma | Simple, local | Not for prod | Development, prototypes |
| Qdrant | Fast, filtering | Self-host | Performance critical |
Design Checklist
## RAG Design: [Project Name]
### 1. Data Source Analysis
- [ ] Document types: [PDF, Markdown, HTML, etc.]
- [ ] Total volume: [X documents, Y MB]
- [ ] Update frequency: [Real-time, Daily, Weekly]
- [ ] Quality: [Clean, Needs preprocessing]
### 2. Chunking Strategy
- [ ] Strategy: [Recursive, Semantic, etc.]
- [ ] Chunk size: [X characters]
- [ ] Overlap: [Y characters]
- [ ] Metadata: [Title, Source, Date, etc.]
### 3. Embedding Choice
- [ ] Model: [text-embedding-3-small, etc.]
- [ ] Dimensions: [1536, 3072, etc.]
- [ ] Cost estimate: [$X per 1M tokens]
### 4. Vector Store
- [ ] Database: [pgvector, Pinecone, etc.]
- [ ] Index type: [HNSW, IVF, etc.]
- [ ] Hosting: [Self-hosted, Managed]
### 5. Retrieval Strategy
- [ ] Search type: [Similarity, MMR, Hybrid]
- [ ] Top K: [3-10]
- [ ] Reranking: [Yes/No]
- [ ] Filtering: [Metadata filters]
### 6. Generation
- [ ] Model: [GPT-4, Claude, etc.]
- [ ] Temperature: [0 for factual, 0.7 for creative]
- [ ] Context window: [Token limit]
- [ ] Fallback: [When no relevant docs found]Common Pitfalls
| Pitfall | Solution |
| Chunks too small | Increase size, lose context |
| Chunks too large | Decrease, add overlap |
| Wrong embedding model | Match to domain (code, medical, etc.) |
| No metadata | Add source, date, section |
| No evaluation | Implement retrieval metrics |
Evaluation Metrics
# Retrieval Quality
- Recall@K: % of relevant docs in top K
- Precision@K: % of top K that are relevant
- MRR: Mean Reciprocal Rank
# Generation Quality
- Faithfulness: Does answer match sources?
- Relevance: Does answer address query?
- Groundedness: Is answer supported by context?Process
- Understand the use case (Q&A, search, chatbot)
- Analyze data sources
- Choose chunking strategy
- Select embedding model
- Design vector store schema
- Implement retrieval pipeline
- Configure generation
- Set up evaluation
- Deploy and monitor
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

