Searching large repos fast in Claude Code: a Glob/Grep strategy, measured
As file counts grow, search gets slower — with real file counts and timings.
Search cost rises with repo size
In a project with a few hundred files, search speed barely matters. In one with thousands, how you use `Grep`/`Glob` changes the exploration cost a lot.
What Claude Code's Grep tool actually is
Per the official docs (code.claude.com/docs/en/tools-reference, fetched 2026-07-29), `Grep` is built on ripgrep (ripgrep regex syntax, not POSIX), respects `.gitignore`, and can run 5-10x faster with `USE_BUILTIN_RIPGREP=0` pointing at a system-installed ripgrep instead of the bundled one.
Measured: a real folder with 8,000+ files
On a real personal knowledge-base folder (8,149 Markdown files), searching for a keyword:
$ find . -name "*.md" | wc -l
8149
$ time (grep -rl "SEO" . --include="*.md" | wc -l)
216
0.376 totalNarrow with Glob, then Grep
Instead of grepping the whole tree every time, narrow with `Glob` first (e.g. `src/**/*.ts`) so there's simply less for Grep to scan.
Tell CLAUDE.md the directory layout
Stating which directory owns what (frontend, shared components, etc.) in CLAUDE.md cuts down on misdirected exploration.
Combine with --add-dir
When you need to cross multiple directories, adding just the relevant ones via `--add-dir` keeps the search scope tighter than treating the whole repo as one giant working directory.