Contract
- Input: corpus description, query patterns, quality requirements, latency target.
- Output: RAG architecture + chunking config + reranking config + evaluation plan.
- Scope: designs pipeline; does not index data or run inference unless explicitly executed.
- Rule: designs pipeline; does not index data or run inference unless explicitly executed.
- Rule: documented standards override defaults; explicit project rules take precedence.
- Rule: if blocked by missing context or dependencies, surface the blocker before proceeding.
Provenance
| Question |
Answer |
| What is the source of truth? |
The user's request, originating spec/issue, and the skill's declared outputs |
| What is in scope? |
Work covered by the skill's acceptance criteria and completion rules |
| What is explicitly out of scope? |
Files, behaviors, and decisions outside the skill's declared boundary |
| Who or what consumes this artifact afterward? |
The next skill in the workflow or the user |
| What evidence proves it is done? |
Completion criteria met, artifact saved, validation passed |
| What risk remains? |
Subjective judgment calls, missing context, or external dependency failures |
Artifact
Emit RagPipelineArtifact as both:
- JSON:
.agents/skills/platform/artifacts/rag-pipeline/{identifier}.json
- Markdown view: same filename with
.md extension
RAG Pipeline Design
Design a Retrieval-Augmented Generation (RAG) pipeline — retrieval, chunking, embedding, reranking, generation — with explicit data flow, latency budgets, and evaluation seams.
Process
1. Define retrieval scope
- Document corpus (size, format, update frequency).
- Query patterns (short factual, long analytical, conversational).
- Latency budget per stage (e.g. retrieval < 100ms, generation < 500ms).
- Grounding requirements (citation, quote extraction, provenance).
Completion criterion: retrieval scope and latency budget documented.
2. Chunking strategy
- Chunk size (tokens / characters); overlap ratio.
- Splitting logic (sentence, paragraph, section-aware, recursive).
- Metadata preservation (document ID, section, page, timestamp).
- Handling of tables, code blocks, and lists.
Completion criterion: chunking rules and metadata schema defined.
3. Embedding selection
- Model family (open / proprietary, dense / sparse / late interaction).
- Dimension budget and storage cost.
- Normalisation and pooling strategy.
- Batch indexing and update cadence.
Completion criterion: embedding model and dimension budget selected.
4. Retrieval configuration
- Retrieval mode (vector, keyword, hybrid with RRF or weighted fusion).
- Top-K recall and filtering (date, source, access control).
- Indexing pipeline (batch / streaming, reindex trigger).
Completion criterion: retrieval mode and top-K defined.
5. Reranking
- Reranker type (cross-encoder, late interaction, LLM rerank).
- Rerank window size (candidates from retrieval).
- Score threshold and fallback behaviour.
- Latency and cost trade-off.
Completion criterion: reranking config and fallback behaviour defined.
6. Generation orchestration
- Prompt template (system, context injection, query, citation format).
- Context window management (truncation, compression, multi-hop).
- Output contract (grounded answer, citations, confidence).
- Safety filters (hallucination guard, PII redaction).
Completion criterion: generation config and output contract defined.
7. Evaluation
- Retrieval metrics (Recall@K, MRR, NDCG).
- Generation metrics (faithfulness, answer relevance, citation accuracy).
- Latency and cost tracking.
- Regression suite (eval set with golden answers).
Completion criterion: evaluation plan with metrics and regression suite defined.
Rules
- Rule: treat the corpus as a first-class input; document its schema, freshness, and ownership.
- Rule: keep chunking deterministic so reindexing produces stable results.
- Rule: measure retrieval recall before adding reranking; reranking improves precision but not recall.
- Rule: expose provenance (document, section, page) at every stage for auditability.
- Rule: define fallback behaviour for empty retrieval, failed reranking, and generation errors.
Completion
- the skill's completion criteria are explicitly checked
- the artifact is saved and validated
- any blockers or skipped validations are documented
- the next consumer is identified or the work is handed off
@include .agents/skills/platform/contract-base.xml
1---2name: "rag-pipeline"3category: "ai"4maturity: "stable"5version: "1"6description: "Design RAG pipelines — retrieval, chunking, embedding, reranking, generation — with explicit data flow, latency budgets, and evaluation seams."7license: "MIT"8capabilities:9 - apply rag pipeline methods within explicit ai boundaries10 - analyze design rag pipelines — retrieval, chunking, embedding, reranking, generation — with explicit data flow, latency budgets, and evaluation seams with assumptions, constraints, and failure modes11 - produce and validate a ai artifact with evidence, decisions, and next steps12outputs: "RAG architecture + chunking config + reranking config + evaluation plan."13sideEffects: []14dependencies: []15stopCondition: "Architecture documented; chunking and embedding config defined; evaluation plan complete."16risk: "medium"17trustTier: "3"18maxIterations: "6"19promptVersion: "2.0"20artifactType: "ai"21modelTier: "reasoning"22evaluators: ["behavioral", "regression"]23fixturesPath: .agents/skills/platform/fixtures/behavioral/rag-pipeline.json24diataxis: "how-to"25tags: ["ai"]26compatibility: []27approvalRequired: "true"28approvalFor: []29metadata:30 source: https://skillmd.com/skills/quantumquirkxyz/rag-pipeline31---3233## Contract3435- Input: corpus description, query patterns, quality requirements, latency target.36- Output: RAG architecture + chunking config + reranking config + evaluation plan.37- Scope: designs pipeline; does not index data or run inference unless explicitly executed.38- Rule: designs pipeline; does not index data or run inference unless explicitly executed.39- Rule: documented standards override defaults; explicit project rules take precedence.40- Rule: if blocked by missing context or dependencies, surface the blocker before proceeding.4142## Provenance4344| Question | Answer |45|---|---|46| What is the source of truth? | The user's request, originating spec/issue, and the skill's declared outputs |47| What is in scope? | Work covered by the skill's acceptance criteria and completion rules |48| What is explicitly out of scope? | Files, behaviors, and decisions outside the skill's declared boundary |49| Who or what consumes this artifact afterward? | The next skill in the workflow or the user |50| What evidence proves it is done? | Completion criteria met, artifact saved, validation passed |51| What risk remains? | Subjective judgment calls, missing context, or external dependency failures525354## Artifact5556Emit `RagPipelineArtifact` as both:57- JSON: `.agents/skills/platform/artifacts/rag-pipeline/{identifier}.json`58- Markdown view: same filename with `.md` extension596061# 62# 63# RAG Pipeline Design6465Design a **Retrieval-Augmented Generation (RAG) pipeline** — retrieval, chunking, embedding, reranking, generation — with explicit data flow, latency budgets, and evaluation seams.6667## Process6869### 1. Define retrieval scope70- Document corpus (size, format, update frequency).71- Query patterns (short factual, long analytical, conversational).72- Latency budget per stage (e.g. retrieval < 100ms, generation < 500ms).73- Grounding requirements (citation, quote extraction, provenance).7475**Completion criterion:** retrieval scope and latency budget documented.7677### 2. Chunking strategy78- Chunk size (tokens / characters); overlap ratio.79- Splitting logic (sentence, paragraph, section-aware, recursive).80- Metadata preservation (document ID, section, page, timestamp).81- Handling of tables, code blocks, and lists.8283**Completion criterion:** chunking rules and metadata schema defined.8485### 3. Embedding selection86- Model family (open / proprietary, dense / sparse / late interaction).87- Dimension budget and storage cost.88- Normalisation and pooling strategy.89- Batch indexing and update cadence.9091**Completion criterion:** embedding model and dimension budget selected.9293### 4. Retrieval configuration94- Retrieval mode (vector, keyword, hybrid with RRF or weighted fusion).95- Top-K recall and filtering (date, source, access control).96- Indexing pipeline (batch / streaming, reindex trigger).9798**Completion criterion:** retrieval mode and top-K defined.99100### 5. Reranking101- Reranker type (cross-encoder, late interaction, LLM rerank).102- Rerank window size (candidates from retrieval).103- Score threshold and fallback behaviour.104- Latency and cost trade-off.105106**Completion criterion:** reranking config and fallback behaviour defined.107108### 6. Generation orchestration109- Prompt template (system, context injection, query, citation format).110- Context window management (truncation, compression, multi-hop).111- Output contract (grounded answer, citations, confidence).112- Safety filters (hallucination guard, PII redaction).113114**Completion criterion:** generation config and output contract defined.115116### 7. Evaluation117- Retrieval metrics (Recall@K, MRR, NDCG).118- Generation metrics (faithfulness, answer relevance, citation accuracy).119- Latency and cost tracking.120- Regression suite (eval set with golden answers).121122**Completion criterion:** evaluation plan with metrics and regression suite defined.123124## Rules125126- Rule: treat the corpus as a first-class input; document its schema, freshness, and ownership.127- Rule: keep chunking deterministic so reindexing produces stable results.128- Rule: measure retrieval recall before adding reranking; reranking improves precision but not recall.129- Rule: expose provenance (document, section, page) at every stage for auditability.130- Rule: define fallback behaviour for empty retrieval, failed reranking, and generation errors.131132## Completion133134- the skill's completion criteria are explicitly checked135- the artifact is saved and validated136- any blockers or skipped validations are documented137- the next consumer is identified or the work is handed off138---139@include .agents/skills/platform/contract-base.xml