All skills
Skillintermediate
/create-retriever - Create RAG Retriever
Build a retrieval component for RAG pipeline with optimized search.
Claude Code Knowledge Pack7/10/2026
Overview
/create-retriever - Create RAG Retriever
Build a retrieval component for RAG pipeline with optimized search.
Steps
- Configure the vector store connection and embedding model
- Implement the retrieval function with configurable parameters:
- Top-K results (default: 5)
- Similarity threshold (default: 0.7)
- Metadata filters (source, date range, category)
- Add hybrid search combining vector similarity with keyword BM25 search
- Implement re-ranking using a cross-encoder model for result quality
- Add contextual compression to extract only relevant parts of retrieved chunks
- Implement query transformation: expand, decompose, or rephrase the user query
- Add caching for repeated queries with a configurable TTL
- Build the prompt template that incorporates retrieved context
- Add source citation formatting to trace answers to specific documents
- Implement fallback behavior when no relevant documents are found
- Add evaluation metrics: retrieval precision, recall, and MRR
- Test the retriever with sample queries and verify relevance
Rules
- Always return source citations with retrieved content
- Set a minimum similarity threshold to avoid irrelevant results
- Use re-ranking to improve result quality beyond pure vector similarity
- Implement query decomposition for complex multi-part questions
- Cache embeddings for frequently asked queries
- Handle empty results gracefully with a "no relevant information found" response
- Log retrieval metrics for continuous improvement