SnapshotJuly 2026a point-in-time write-up, left as written

The retrieval toolkit

If agentic retrieval is the concept, this chapter is the toolbox: the methods a modern harness actually reaches for, and the order it tends to reach for them in.

A useful frame: precise and local before fuzzy and remote. When the model can name what it’s looking for, fetch exactly that. Reach for similarity-based retrieval when you can’t.

The hierarchy

  1. Read a known file: exact path, highest signal. The dominant retrieval step in Claude Code.
  2. Glob and grep: find files by pattern, find literal strings across a tree. Precise and fast.
  3. Web search: for information that isn’t local, or that needs to be current.
  4. MCP tool calls: structured data from external systems (Linear, GitHub, Gmail, Slack, your own service). Precise because the tool knows what it’s asking for.
  5. Sub-agents: when the question is broad enough that a single retrieval step won’t do. A sub-agent runs its own retrieval loop with its own context, and returns a summary to the parent.
  6. Vector search: similarity across a large unstructured corpus. The right tool when no exact vocabulary connects the query to the answer.

Why this order

A 2026 LlamaIndex benchmark found file-system agents (glob, grep, read) outscored traditional vector-based RAG on both correctness (+2 points) and relevance (+1.6 points) on realistic knowledge-work tasks. Claude Code’s design reflects the same finding: CLAUDE.md drops naively into context, and glob and grep navigate the environment just-in-time.

Precision compounds. A precise file read or grep gives the model exactly the content it needs to reason about. Vector search gives it approximately the right chunk and asks the model to do the reasoning anyway. Both work; precision is faster, cheaper, and usually more accurate when precision is possible.

Each method, briefly

Read a known file

If the model already knows the path, reading it is a single cheap tool call that returns the exact content. Most Claude Code sessions are dominated by file reads. This is the retrieval step to design for: the more your project has well-named, discoverable files with short descriptions, the more often Claude can answer by reading instead of searching.

Glob and grep

When the model knows what to look for but not where, glob (filename patterns) and grep (content search) resolve the uncertainty in one or two calls. Glob for “all files matching **/*.sql”; grep for “every place the word rate_limit appears.” These are the workhorses of agentic retrieval. They’re deterministic, cheap, and return exactly what the model asked for.

Web search

Web search is the fallback for anything not on the local filesystem. It’s also the slowest step in a session; see Deep research for why. Reach for it when information is genuinely remote or genuinely current (news, pricing, a newly released library). Skip it when local material would do.

MCP tool calls

MCP (Model Context Protocol) is the standard way Claude Code talks to external services: Linear, GitHub, a database, a SaaS API you connect. An MCP call is precise because the tool’s schema narrows what’s being asked: “get issue IDENTIFIER,” “list open PRs in REPO.” Use MCP when the data lives behind an API and there’s a tool for it; it beats web-scraping.

Sub-agents

When a retrieval task is broad (“read these 30 files and tell me which three describe authentication”), a sub-agent runs its own full loop (file reads, grep, web search, whatever it needs) in an isolated context window, then returns a summary. The main session stays clean; the sub-agent absorbs the noise. See Modes and abilities for when to reach for one.

Vector search

Vector search earns its place in the stack for problem shapes where nothing above can find the connection: large corpora without a shared vocabulary, fuzzy semantic queries, cross-author writing. Think: “find all customer feedback that feels like a churn risk” across 50,000 unlabeled support tickets. It’s the right tool, narrowly. If you can name what you’re looking for, skip it.

Designing retrieval for your own application

If you’re building a product that needs retrieval:

Resources