rag-web-fallback

rag-web-fallback is a skill for Claude Code, Codex from lyonzin/knowledge-rag. It costs 61 tokens per session (1,470 once invoked), scanned A, original, MIT.

A rule for answering questions from a local collection of indexed documents before using an external web search.

In plain words
What is it for?
It helps agents search internal documentation first, try a different local query if needed, and record why they had to use the web when local information was insufficient.
Why use it?
It avoids unnecessary network requests, delay, cost, and accidental internet access when the needed information is already available locally.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/lyonzin/knowledge-rag/rag-web-fallback
Any agent
npx skills add lyonzin/knowledge-rag --skill rag-web-fallback
Clone the repo
git clone --depth 1 https://github.com/lyonzin/knowledge-rag

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for rag-web-fallback

README.md
[![agentmods](https://agentmods.dev/badge/skills/lyonzin/knowledge-rag/rag-web-fallback.svg)](https://agentmods.dev/skills/lyonzin/knowledge-rag/rag-web-fallback)
Your own site
<a href="https://agentmods.dev/skills/lyonzin/knowledge-rag/rag-web-fallback"><img src="https://agentmods.dev/badge/skills/lyonzin/knowledge-rag/rag-web-fallback.svg" alt="Measured on agentmods" height="20"></a>
Per session 61 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,470 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00061 $0.01470
Opus 5 $0.00030 $0.00735
Sonnet 5 $0.00012 $0.00294
Haiku 4.5 $0.00006 $0.00147

Measured 4d ago against content hash cb015a77be73, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

rag-web-fallback 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 4d 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.

skills/workflow/rag-web-fallback/SKILL.md · 136 lines

How it starts

The opening of the file, as written. The whole thing — 136 lines — stays where its author put it; the contents beside it link to each section on GitHub.

rag-web-fallback — local first, web only when necessary

When to use this skill

Whenever the agent is tempted to call an external tool for information (WebSearch, WebFetch, mcp__exa__*, mcp__context7__*, etc.), route through this skill's checklist first.

Applies to:

  • Any request that could be answered from indexed docs before hitting the network
  • Any factual claim the agent is about to look up externally
  • Any "give me the latest on X" question where X might be in the corpus

Does NOT apply to:

  • Deliberate freshness requests: "what happened today", "current news"
  • User explicitly asks for a web search
  • Live infra queries (external API calls that are the actual task, not for context)

What this skill commits to

The agent will:

  1. Attempt at least one search_knowledge call before any web call, using appropriately extracted keywords.
  2. Attempt a second call with alternative phrasing if the first returned nothing relevant.
  3. Only then, if genuinely no local coverage, escalate to web search — with an explicit note to the user that RAG was checked and came back empty.

Steps

  1. First-pass RAG:

    search_knowledge(query="<extracted keywords>", max_results=5, min_score=0.15)
    
  2. If 0 hits (or top score < 0.3), try a paraphrase. Common variants:

    • Swap synonyms ("auth" ↔ "authentication", "reindex" ↔ "rebuild", "ttl" ↔ "expiration")
    • Broaden ("payment refund cancellation" → "refund process")
    • Narrow ("architecture" → "authentication architecture")
  3. Second-pass RAG:

    search_knowledge(query="<paraphrased keywords>", max_results=5, min_score=0.10)
    

    Note: lower min_score (0.10) to catch weaker matches.

  4. Decide:

    Local result quality Action
    Solid hit (score > 0.5) Answer from RAG, do NOT hit web
    Weak hit (score 0.15–0.5) Answer from RAG and add a web-search suggestion "for more context"
    No hit Explicitly tell the user "corpus does not have this" then optionally invoke web search

Read the full file on GitHub · 136 lines

Changes

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.

  1. 4d ago First seen · 136 lines · 61 tokens per session scan A cb015a77be73

Subscribe to this mod's changes

rag-web-fallback is a skill published in the GitHub repository lyonzin/knowledge-rag (262 stars, last pushed 6d ago), licensed MIT. It adds 61 tokens to every session and 1,470 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-08-30.

Related

Other skills, from other repositories

rag-perf

Performance benchmarking for a deployed NVIDIA RAG Blueprint server: profiling pass + aiperf load test driven by a single YAML config. Not for accuracy / RAGAS scoring (use rag-eval) or for deploying / repairing services (use rag-blueprint).

NVIDIA-AI-Blueprints/rag · 56 tokens

rag-blueprint

NVIDIA RAG Blueprint — deploy, configure, troubleshoot, and manage. Handles any RAG action: deploy, install, start, enable, disable, toggle, change, configure, troubleshoot, debug, fix, shutdown, stop, or tear down any RAG feature or service (Agentic RAG, VLM, guardrails, query rewriting, models, search, ingestion…

NVIDIA-AI-Blueprints/rag · 92 tokens

rag-eval

Filesystem RAG benchmarks: corpus/, train.json, evaluaterag.py (RAGAS quality). Not for prod monitoring, latency/throughput benchmarking (use rag-perf), or evals outside this repo layout.

NVIDIA-AI-Blueprints/rag · 48 tokens

pinecone:n8n

Build n8n workflows using the Pinecone Assistant node or Pinecone Vector Store node. Use when building RAG pipelines, chat-with-docs workflows, configuring Pinecone nodes in n8n, troubleshooting Pinecone n8n nodes, or asking about best practices for Pinecone in n8n.

pinecone-io/pinecone-claude-code-plugin · 67 tokens

pinecone:quickstart

Interactive Pinecone quickstart for new developers. Choose between two paths - Database (create an integrated index, upsert data, and query using Pinecone MCP + Python) or Assistant (create a Pinecone Assistant for document Q&A). Use when a user wants to get started with Pinecone for the first time or wants a guided…

pinecone-io/pinecone-claude-code-plugin · 79 tokens

pinecone:cli

Guide for using the Pinecone CLI (pc) to manage Pinecone resources from the terminal. The CLI supports ALL index types (standard, integrated, sparse) and all vector operations — unlike the MCP which only supports integrated indexes. Use for batch operations, vector management, backups, namespaces, CI/CD automation…

pinecone-io/pinecone-claude-code-plugin · 75 tokens