matrixx0070/sudo-skills/ai-rag-pipeline
Claude Code and agent skill by matrixx0070/sudo-skills
- community
Checking that the SKILL.md file is still in the repository.
Design a retrieval-augmented generation pipeline covering chunking, embeddings, hybrid search, reranking, and retrieval evaluation.
Install
npx vskill@latest install matrixx0070/sudo-skills/ai-rag-pipelineSKILL.md
The same SKILL.md was published earlier as matrixx0070/sudo-skills/ai-rag-pipeline.
When to use
Use this when an LLM needs facts it was not trained on — internal docs, a knowledge base, changing data — and you must ground answers in retrieved passages with citations.
Not for: static knowledge already in the model, tasks needing reasoning over the WHOLE corpus at once (use a map-reduce summarizer), or deciding to fine-tune instead (see ai-fine-tune-plan).
Method
- Define the retrieval unit: what a single answer-supporting passage looks like. This drives chunking, not the reverse.
- Chunk by structure (headings, sections) before falling back to fixed tokens. Decision point: prose → 300-500 tokens with ~15% overlap; code/tables → keep semantic units whole.
- Add a contextual prefix to each chunk (document title + section + a one-line summary) before embedding. This alone cuts retrieval failures materially.
- Embed with a current model; store vectors plus the raw text and metadata (source, section, timestamp).
- Retrieve hybrid: dense (cosine) + sparse (BM25/keyword), then fuse with Reciprocal Rank Fusion. Decision point: exact IDs/error codes/names → weight sparse higher.
- Rerank the top ~30 with a cross-encoder down to the top 3-5. Skip only if latency budget forbids it (see
ai-cost-latency). - Build the prompt: retrieved passages + a rule to answer ONLY from them and cite, else say "not found".
- Evaluate retrieval separately from generation: recall@k on a labeled query set BEFORE judging answers (see
ai-eval-harness).
Example
Query: "What is the timeout for the billing webhook?"
Dense search returns a "webhooks overview" chunk (topic match, no number). BM25 catches the chunk containing BILLING_WEBHOOK_TIMEOUT=30s. RRF fuses both; the reranker floats the config chunk to rank 1. The model answers "30 seconds" and cites billing/config.md#timeouts. Recall@5 measured at 0.92 on 40 labeled queries.
Pitfalls
- Chunk-then-think. Picking 512 tokens before knowing what an answer needs. Design the retrieval unit first.
- Dense-only. Cosine similarity misses exact tokens (IDs, versions, error codes). Always add a sparse channel.
- No retrieval eval. Blaming the LLM when the right passage was never retrieved. Measure recall@k first.
- Stale index. Serving deleted/updated docs. Store timestamps and re-index on source change.
Output format
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdocs/skills/ai-rag-pipeline/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/matrixx0070/sudo-skills/ai-rag-pipeline)