agentleFS
dtsongdtsong/agentic-council/skills/oracle-rag-architecture/SKILL.md

rag-architecture

Skill0 starsChanged 6 months agoApache-2.0View on GitHub

Use when designing a Retrieval-Augmented Generation pipeline. Covers document processing, chunking strategy, embedding pipeline, vector database selection, retrieval optimization, and context assembly. Do not use for prompt design (use prompt-engineering) or evaluation framework design (use ai-evaluation).

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    No user-provided values are used in commands or file paths.

    line 39
  2. Distinctive:

    Recursive: Start large, recursively split until chunks fit size target.

    line 66

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

RAG Architecture

Purpose

Design a Retrieval-Augmented Generation pipeline, including document processing, chunking strategy, embedding pipeline, vector database selection, retrieval optimization, and context assembly.

Scope Constraints

Reads source document metadata, query patterns, and infrastructure requirements for pipeline design analysis. Does not execute embedding operations, provision vector databases, or access production data directly.

Inputs

  • Source documents (type, volume, update frequency)
  • Query patterns (user questions, search terms, structured queries)
  • Quality requirements (relevance threshold, hallucination tolerance)
  • Latency requirements (real-time, near-real-time, batch)
  • Cost constraints (embedding costs, storage costs, query costs)

Input Sanitization

No user-provided values are used in commands or file paths. All inputs are treated as read-only analysis targets.

Procedure

Progress Checklist

  • Step 1: Analyze source documents
  • Step 2: Design chunking strategy
  • Step 3: Select embedding model
  • Step 4: Select vector database
  • Step 5: Design retrieval pipeline
  • Step 6: Design quality metrics

Step 1: Analyze Source Documents

Understand what's being indexed:

  • Document types: PDFs, web pages, code, structured data, conversations
  • Volume: Number of documents, total size, growth rate
  • Update frequency: Static corpus, daily updates, real-time
  • Structure: Highly structured (tables, headers) vs unstructured (prose, transcripts)
  • Quality: Clean text vs noisy (OCR artifacts, HTML remnants, duplicates)

Step 2: Design Chunking Strategy

Choose how to split documents:

  • Fixed-size: 500-1000 tokens with 100-200 token overlap. Simple but may split concepts.
  • Semantic: Split on paragraph/section boundaries. Preserves meaning but variable size.
  • Hierarchical: Parent-child chunks (section summary + detail chunks). Best for complex docs.
  • Recursive: Start large, recursively split until chunks fit size target.
  • Metadata enrichment: Attach source, section title, page number to each chunk.

Step 3: Select Embedding Model

Choose the embedding approach:

  • OpenAI text-embedding-3-small/large: Best general-purpose, 1536/3072 dimensions
  • Cohere embed-v3: Strong multilingual, supports search and classification modes
  • Open source (BGE, E5): Self-hosted, lower cost at scale, variable quality
  • Considerations: Dimension size (storage), context length, multilingual support, cost per token

Step 4: Select Vector Database

Choose storage and retrieval:

DatabaseHostedOpen SourceHybrid SearchBest For
PineconeYesNoYes (sparse+dense)Production, managed
WeaviateYesYesYes (BM25+vector)Self-hosted, rich filtering
ChromaDBNoYesNoPrototyping, local dev
pgvectorVia SupabaseYesBM25 separateAlready using Postgres
QdrantYesYesYesHigh-performance, filtering

Step 5: Design Retrieval Pipeline

Build the query-time pipeline:

  1. Query preprocessing: Expand abbreviations, detect intent, generate sub-queries
  2. Embedding: Encode query with same model used for documents
  3. Initial retrieval: Top-K vector search (K=20-50)
  4. Reranking: Cross-encoder reranker to reorder by relevance (return top 5-10)
  5. Context assembly: Combine retrieved chunks into a prompt, add metadata
  6. Generation: LLM call with assembled context + user query

Step 6: Design Quality Metrics

Define how to measure RAG quality:

  • Retrieval metrics: Recall@K (are relevant docs in top K?), MRR (is the best doc ranked first?)
  • Generation metrics: Faithfulness (does the answer stick to context?), relevance (does it answer the question?)
  • End-to-end: Answer accuracy on golden dataset, hallucination rate
  • Monitoring: Track retrieval scores over time, flag low-confidence answers

Compaction resilience: If context was lost during a long session, re-read the Inputs section to reconstruct what system is being analyzed, check the Progress Checklist for completed steps, then resume from the earliest incomplete step.

Output Format

# RAG Architecture

## Source Analysis
| Attribute | Value |
|-----------|-------|
| Document types | [Types] |
| Corpus size | [Size] |
| Update frequency | [Frequency] |

## Chunking Strategy
**Method:** [Fixed/Semantic/Hierarchical]
**Target chunk size:** [X tokens]
**Overlap:** [X tokens]
**Metadata:** [Fields attached to each chunk]

## Embedding Pipeline
**Model:** [Name]
**Dimensions:** [N]
**Cost:** [$X per 1M tokens]
**Batch processing:** [Strategy for initial load vs incremental updates]

## Vector Database
**Choice:** [Database]
**Rationale:** [Why this DB]
**Index configuration:** [HNSW params, quantization, etc.]
**Hybrid search:** [BM25 + vector approach]

## Retrieval Pipeline

Query → [Preprocess] → [Embed] → [Vector Search (top 20)] → [Rerank (top 5)] → [Assemble Context] → [LLM] → [Validate] → Response


| Stage | Latency | Cost |
|-------|---------|------|
| Embedding | Xms | $X |
| Vector search | Xms | $X |
| Reranking | Xms | $X |
| Generation | Xms | $X |
| **Total** | **Xms** | **$X** |

## Quality Metrics
| Metric | Target | Measurement |
|--------|--------|-------------|
| Recall@10 | >90% | Golden dataset |
| Faithfulness | >95% | Automated scoring |
| Hallucination rate | <5% | Reference checking |

## Cost Model
| Component | Monthly Cost (at X queries/day) |
|-----------|-------------------------------|
| Embeddings | $X |
| Vector DB | $X |
| Reranking | $X |
| Generation | $X |
| **Total** | **$X** |

Handoff

  • Hand off to prompt-engineering if retrieval pipeline design reveals system prompt optimization needs for context assembly.
  • Hand off to ai-evaluation if RAG quality metrics require a formal evaluation framework or golden dataset creation.

Quality Checks

  • Chunking strategy is justified against document structure (not just default 500 tokens)
  • Embedding model matches the query language and domain
  • Retrieval pipeline includes reranking (not just raw vector similarity)
  • Cost model accounts for both indexing and query costs
  • Quality metrics have defined targets and measurement approach
  • Update strategy handles incremental changes (not re-index everything)
  • Latency budget is broken down by pipeline stage

Evolution Notes

<!-- Observations appended after each use -->

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.