j4flmao/agent-skills/rag-design
Claude Code and agent skill by j4flmao/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Use this skill when the user says 'query rewriting', 'HyDE', 'multi-query retrieval', 'query decomposition', 'multi-hop RAG', 'step-back prompting', 'RAG prompt template', 'cite sources', 'GraphRAG', 'answer only from context'. Designs the LLM-side of RAG: transforming queries before retrieval, routing to indexes, iterative multi-hop retrieval, and grounded answer prompts with citations and abstention. Do NOT use for: ANN index tuning, hybrid fusion and reranking internals (ai/llm-engineering/rag-architecture), agent memory (ai/ai-agents/memory-systems), or vector database operations (data/vector-databases).
Install
npx vskill@latest install j4flmao/agent-skills/rag-designSKILL.md
RAG Query & Prompt Design
Purpose
User questions are often short, ambiguous, or compositional, and a single embedding search misses what they need. LLM-driven query transformation (rewrite, expand, decompose, route) improves recall; iterative retrieval handles multi-hop questions; a grounded answer prompt with citations and permission to abstain keeps the generator honest. Each technique adds latency and cost, so add them only when evals show retrieval misses.
Agent Protocol
Trigger
"query rewriting", "HyDE", "multi-query", "query decomposition", "multi-hop", "step-back", "query routing", "RAG prompt", "citations", "groundedness", "GraphRAG".
Input Context
- Sample of real user queries and failing cases (retrieval miss vs generation error).
- Indexes available (dense, BM25, SQL, graph) and their content.
- Latency budget; conversation context (follow-up questions?).
Output Artifact
Query pipeline (which transforms, in what order), routing rules, answer prompt with citation format, evaluation plan.
Response Format
Completion Criteria
- [ ] Failures classified before adding techniques.
- [ ] Follow-up questions condensed into standalone queries.
- [ ] Hop count and query fan-out capped.
- [ ] Answer prompt requires citations and allows "not found".
Diagnose First
| Symptom | Likely cause | Technique | |
|---|---|---|---|
| Follow-up "what about the second one?" fails | Missing conversation context | Condense to standalone question | |
| Vocabulary mismatch (user vs docs) | Lexical gap | Multi-query expansion, HyDE, hybrid search | |
| Question spans several facts/entities | Compositional | Decomposition, multi-hop | |
| Query about numbers/tables | Wrong store | Route to SQL / structured index | |
| Answer contradicts docs | Generation | Grounded prompt, citations, verification |
Query Transformations
Condense (conversational RAG)
Multi-query expansion: generate 3-5 paraphrases targeting different wordings; retrieve for each; fuse with reciprocal rank fusion.
HyDE (Gao et al., 2022): generate a hypothetical answer passage and embed it instead of the question; answer-like text sits closer to answer passages in embedding space. Risky for questions where the model's guess is confidently wrong in a way that steers retrieval; always combine with the original query.
Step-back prompting (Zheng et al., 2023): ask a more general question ("What are the rules for X?") alongside the specific one to retrieve principles.
Decomposition
Routing: a small classifier or LLM call maps the query to indexes (docs vector+BM25, SQL over metrics, knowledge graph) with a default fallback.
Multi-Hop Retrieval
Graph-based RAG: entity/relation extraction into a knowledge graph enables explicit relationship traversal; Microsoft's GraphRAG adds community summaries for corpus-wide ("global") questions. It costs an expensive indexing pass; use when questions are relational or global, not for simple lookups.
Grounded Answer Prompt
Post-check citations: every cited id must exist in the provided set; optionally verify each claim with an entailment/groundedness check and drop or flag unsupported sentences.
Evaluation
- Retrieval: recall@k / hit rate per technique on labeled query → doc pairs.
- Generation: faithfulness (claims supported by context), answer correctness, citation precision.
- Cost/latency: extra LLM calls per query; cap fan-out.
Anti-Patterns
- Stacking HyDE + multi-query + decomposition on every query without measurement.
- Using HyDE output instead of, rather than in addition to, the original query.
- Unbounded hop loops.
- Prompts that forbid abstaining (forces hallucination).
- Retrieved text treated as instructions (indirect prompt injection).
Checklist
- [ ] Failure taxonomy from real queries.
- [ ] Condensation for chat; routing for structured data.
- [ ] Expansion/decomposition only where they raise recall.
- [ ] Hop and fan-out caps; latency budget respected.
- [ ] Citation format + abstention + citation validation.
- [ ] Retrieval and faithfulness evals in CI.
References
- Gao et al., "Precise Zero-Shot Dense Retrieval without Relevance Labels" (HyDE, 2022).
- Zheng et al., "Take a Step Back" (2023); Press et al., "Self-Ask" (2022).
- Edge et al., "From Local to Global: A Graph RAG Approach" (Microsoft, 2024).
- Retrieval internals:
ai/llm-engineering/rag-architectureskill.
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 repositoryCheckingskills/prompt-engineering/rag-design/SKILL.md
Popularity
- Repository stars
- 29
- Repository forks
- 1
- 7-day trend score
- 22
Stars and forks are for the whole GitHub repository, not this skill alone. 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/j4flmao/agent-skills/rag-design)