0.000
Prefer rg/Glob over dumping huge files into context
Terminal / Productivity / Cost Optimization·13 hours ago·verified 13 hours ago·easy·~3 min setup·verified
Instruct Claude (and yourself) to search with rg/Glob first so giant file reads do not blow the context window.
The problem
Asking Claude to "read the whole module" pastes thousands of irrelevant lines into the window.
The hack
Put a CLAUDE.md rule: search with `rg`/Glob, read only the matching slices, never cat large generated files.
Why it works
Targeted reads preserve tokens for reasoning. Cost docs and community guides repeatedly warn against broad dumps.
Setup
1. Add a short rule to CLAUDE.md forbidding reading minified/generated bundles. 2. Prefer prompts like "rg for TokenValidator and read only that function." 3. If Claude starts dumping files, rewind and restate the search-first rule. 4. Check `/context` after investigations to confirm history stayed lean.
Prompt
Search with rg for where rate limits are enforced. Read only the matching functions, then propose a fix.Additional details
Also deny Read on paths like dist/ and node_modules/ via permissions when possible.
Discussion
No comments yet. Be the first to say whether this worked for you.