Getting it into your agent
It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.
git clone --depth 1 https://github.com/softspark/ai-toolkitnpx agentmods add skills/softspark/ai-toolkit/rag-patternsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/softspark/ai-toolkit/rag-patterns)<a href="https://agentmods.dev/skills/softspark/ai-toolkit/rag-patterns"><img src="https://agentmods.dev/badge/skills/softspark/ai-toolkit/rag-patterns.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00057 | $0.01768 |
| Opus 5 | $0.00028 | $0.00884 |
| Sonnet 5 | $0.00011 | $0.00354 |
| Haiku 4.5 | $0.00006 | $0.00177 |
Grade A, and why
rag-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 231 lines — stays where its author put it; the contents beside it link to each section on GitHub.
RAG Patterns Skill
Core Patterns
1. Hybrid Search
Combine dense (vector) and sparse (BM25) retrieval with RRF fusion:
# RAG-MCP hybrid search
result = await hybrid_search_kb(
query="rate limiting configuration",
service="nginx",
limit=10
)
2. Corrective RAG (CRAG)
Self-correcting retrieval with relevance validation:
result = await crag_search(
query="fuzzy query",
relevance_threshold=0.4,
max_retries=2
)
# Or via smart_query
result = await smart_query(query="...", use_crag=True)
3. HyDE (Hypothetical Document Embeddings)
Generate hypothetical answers for better retrieval on conceptual queries:
result = await smart_query(
query="conceptual question about design patterns",
use_hyde=True
)
4. Multi-hop Retrieval
Complex queries requiring multiple retrieval steps:
result = await multi_hop_search(
query="Compare nginx with varnish for Magento cache",
max_hops=3
)
# Or via smart_query
result = await smart_query(query="compare A vs B", use_multi_hop=True)
Indexing Best Practices
| Aspect | Recommendation |
|---|---|
| Chunk size | 512-1024 tokens |
| Overlap | 10-20% of chunk |
| Structure | Preserve headers, sections |
| Metadata | Include title, path, date, category, tags |
| Frontmatter | YAML with standardized fields |
Frontmatter Template
---
title: "Document Title"
service: {project-name}
category: reference|howto|procedures|troubleshooting|decisions|best-practices
tags: [tag1, tag2, tag3]
last_updated: "YYYY-MM-DD"
---
MCP Tools Reference (v5.5.0)
| Tool | Use Case | Speed |
|---|---|---|
smart_query ⭐ |
Default for 90% of queries | 2-4s |
hybrid_search_kb |
Raw vector + text search | <1s |
get_document |
Full document content | <1s |
crag_search |
Vague/fuzzy queries | 1-3s |
multi_hop_search |
Complex reasoning | 20-30s |
Tool Selection Guide
# Default - auto-routing
smart_query("specific technical question")
# Vague query - self-correcting
crag_search("jak to skonfigurować")
# Complex comparison
multi_hop_search("nginx vs varnish performance comparison")
# Known document
get_document(path="kb/reference/architecture.md")
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 3d ago First seen · 231 lines · 57 tokens per session scan A f082b8361665
rag-patterns is a skill published in the GitHub repository softspark/ai-toolkit (170 stars, last pushed 2d ago), licensed Apache-2.0. It adds 57 tokens to every session and 1,768 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
ai-portable-setup
Erstellt einen portablen KI-Arbeitsbereich auf einem USB-Stick oder beliebigen Laufwerk. RAG-Pipeline mit lokalen LLM-Modellen (Ollama), Vektordatenbank (ChromaDB) und vorkonfigurierten Prompts.
document-chunker
Split documents into overlapping token chunks for RAG pipelines and LLM context windows. Zero dependencies.
continue-gemini-explicit
Continue's Gemini provider doesn't use the cachedContents API at all. Add explicit caching for sessions over the minimum token threshold.
roo-fix-volatile-msg
Ladder-aware Roo Code Anthropic caching — verify the rolling read/write ladder on the wire, then close the real gaps (Vertex 4-block budget, MiniMax path).
roo-bedrock-custom-arn
Roo Code's Bedrock provider silently disables caching for custom ARNs. Populate cachableFields to fix.
langchain
Apply when building LangChain pipelines, LCEL chains, agents, or retrieval-augmented generation systems.