From fablers-agentic-rag
Agentic RAG pipeline that answers questions about indexed documents using query analysis, hybrid retrieval, evaluation with CRAG validation, and answer synthesis. Triggers: ask question, search document, answer from book, agentic RAG.
How this skill is triggered — by the user, by Claude, or both
Slash command
/fablers-agentic-rag:askThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Answer the user's question using a streamlined pipeline with complexity-based branching and CRAG (Corrective RAG) loop.
Answer the user's question using a streamlined pipeline with complexity-based branching and CRAG (Corrective RAG) loop.
The user's question is: $ARGUMENTS
Read the settings file at ${CLAUDE_PROJECT_DIR}/.claude/fablers-agentic-rag.local.md (or .claude/fablers-agentic-rag.local.md relative to the current project).
Extract from the YAML frontmatter:
rag_data_path — absolute path to the data directory containing chunks.json, embeddings.npz, and bm25_corpus.jsonopenai_api_key — OpenAI API key for query embeddingIf the file doesn't exist, or rag_data_path still shows the placeholder /path/to/data, or openai_api_key is YOUR_OPENAI_API_KEY, stop and ask the user to configure it:
"Please configure
rag_data_pathandopenai_api_keyin.claude/fablers-agentic-rag.local.md."
Classify the question as simple or complex:
Launch the query-analyst agent with the user's question:
Agent(subagent_type="query-analyst", prompt="Analyze this question and generate optimized search queries:\n\n<question>\n$ARGUMENTS\n</question>")
Capture the SEARCH_QUERIES from the agent's response. Extract the individual queries as a list.
Generate 2 search queries yourself:
Format them as:
SEARCH_QUERIES:
1. <semantic query>
2. <keyword query>
Run the search script directly using Bash:
python3 ${CLAUDE_PLUGIN_ROOT}/scripts/search.py \
--data-dir "<rag_data_path from Step 0>" \
--queries <each query from Step 2, space-separated and quoted> \
--api-key "<openai_api_key from Step 0>" \
--top-k 20
Capture the RETRIEVAL_RESULTS JSON array from stdout.
Skip condition: If the question is simple AND the top retrieval results have high scores (top result score >= 0.75), you may skip the evaluator agent and directly select the top 5 results. Proceed to Step 5 with VERDICT=SUFFICIENT.
Otherwise, launch the evaluator agent:
Agent(subagent_type="evaluator", prompt="Evaluate these retrieval results: rerank by relevance to the question, select top 5, and validate sufficiency.\n\n<question>\n$ARGUMENTS\n</question>\n\n<retrieval_results>\n{RETRIEVAL_RESULTS JSON from Step 3}\n</retrieval_results>")
Capture RERANKED_TOP_5, VERDICT, REWRITE_QUERY, and TOP_5_CHUNKS.
Check the VERDICT:
If the verdict is RETRY_WITH_REWRITE:
REWRITE_QUERY from the evaluator's responseTrack the retry count. After 2 retries, treat the current results as the best available and proceed to Step 5 regardless of the verdict.
Launch the answer-synthesizer agent with the question, validated passages, and verdict:
Agent(subagent_type="answer-synthesizer", prompt="Synthesize a final answer with citations.\n\n<question>\n$ARGUMENTS\n</question>\n\n<verdict>\n{VERDICT from Step 4}\n</verdict>\n\n<passages>\n{TOP_5_CHUNKS — the best available from the last evaluation}\n</passages>")
Display the synthesizer's response directly to the user. The answer should include:
[Source N] citationsSimple questions (1 agent call):
Skill generates 2 queries → search.py → [skip evaluator] → answer-synthesizer
Complex questions (up to 3 agent calls):
query-analyst → search.py → evaluator → answer-synthesizer
↑ RETRY (max 2x)
└── search.py → evaluator
npx claudepluginhub flashwade03/fablers-rag --plugin fablers-agentic-ragQueries local document knowledge base using semantic vector search and hybrid retrieval for AI-powered answers with citations via Claude Haiku.
Guides designing RAG systems that ground LLM responses in retrieved documents to reduce hallucination and enable knowledge updates without retraining.