I still remember the night Glob came back empty on a search for TSX files. I dropped into the terminal, ran find . -name '*.tsx', and hundreds of paths scrolled past. The files were there, the pattern looked fine, and only Claude Code insisted there was nothing.
Moving between the web side of my wallpaper apps and the store-asset repositories, I hit this right after switching into any project where build output sits next to source. At first I kept rephrasing the same request to Claude three or four times. It didn't go well. A zero is not proof that the file is absent — it only says it wasn't visible under those conditions. Once I started treating it that way, the wasted rounds dropped sharply.
What I'd like to say up front: almost every case I've met fits into four boxes — ignore rules, hidden folders, pattern syntax, and the workspace boundary. I'll go through them in that order.
One caveat. How Glob and Grep treat ignored files can differ by version and settings. What follows is what I confirmed in my own setup; yours may differ. That's why the flow below leans on checking facts in the terminal before trusting what the tool says.
First, confirm in the terminal that the file exists
Before asking Claude again, spend ten seconds here.
# Does anything match the pattern at all?
find . -type f -name '*.tsx' | head -20
# Same check without node_modules
find . -type f -name '*.tsx' -not -path '*/node_modules/*' | head -20If find shows files that Claude Code doesn't, the filesystem is innocent, and the suspects are the four boxes. If find also comes back empty, the mistake is in the path or the filename. That single fork settles half the investigation.
Box one: ignore rules hide the place
Locations your Git setup ignores can drop out of search.
- Dependency sources under
node_modules/ - Build output in
dist/orbuild/ - Caches such as
.next/or.turbo/ - Environment files like
.env.local
Grep runs on ripgrep underneath, so as I understand it .gitignore applies by default. For Glob, I'd avoid assuming the same behavior; I've seen the visible range differ with settings and versions.
When I genuinely want to look inside ignored places, I ask Claude to use Bash with explicit ripgrep flags.
# List everything, ignoring .gitignore and including hidden files
rg --hidden --no-ignore --files | grep -E '\.(tsx?|jsx?)$'
# Search a string with no ignore rules applied
rg --hidden --no-ignore -l 'useEffect' src/I'm not aware of a switch on Glob that means "include ignored files," so I hand this kind of search to Bash from the start.
Box two: folders that start with a dot
A search for workflow files under .github/workflows/ once returned zero, and the cause wasn't .gitignore at all — the folder name starts with a dot. .vscode/ and .husky/ behave the same way. Because Git tracks them, it's easy to miss while you're busy suspecting ignore rules.
Adding rg --hidden usually clears this box.
Three reasons Grep misses a line you can see
The Grep tool is ripgrep underneath, and three habits of writing tripped me up.
Braces used as-is
When searching for Go's interface{} or chan struct{}, the braces are metacharacters.
# Unintended matches
rg 'interface{}' .
# Escape the braces
rg 'interface\{\}' .I once lost about thirty minutes on chan struct{} in a Go project. Plain grep hadn't needed the escape, so I only noticed after running out of other explanations.
A multi-line pattern without multiline
Grep matches within a single line by default. A pattern running from struct { down to a field a few lines later returns zero unless multiline: true is passed. The moment I realize the match spans lines, I ask Claude to set that argument.
A type filter narrower than expected
type: 'js' refers to the JavaScript extension group; .ts and .tsx belong to a different one. When I want both, a brace-expanded glob reads less ambiguously.
# JS and TS together
rg 'pattern' --glob '*.{js,jsx,ts,tsx}'
# type works per extension group
rg 'pattern' --type tsThe same "small difference in how input is interpreted" shows up in the Edit tool's old_string not being unique, and the mental model carries over.
The mirror-image failure — too many hits hiding what you need — is written up in the first 250 lines of Grep output.
Box three: Glob pattern syntax
The combinations I mix up most often:
**/*.tsx: any depth,.tsxfiles**/*.{ts,tsx}: brace expansion also workssrc/**: everything undersrc, including the folders themselvessrc/**/*: when you want files only!**/test/**: negation — I don't rely on it in Glob alone; I narrow things down inBash
I once wrote *.tsx meaning **/*.tsx, got only the root-level files back, and panicked that no components existed. The presence of **/ changes search depth directly.
Box four: the file is outside the working directory
Files outside the directory where the session started won't turn up in Glob or Grep. If you want Claude to consult another repository, allow it first with /add-dir.
- Grant extra search roots with
/add-dir <path> - Leave outside-the-boundary searches to
find ~/another-project -name '*.ts'inBash - Pass an absolute path to
Readdirectly
I've written up the cross-repository flow in editing across repositories with --add-dir. Postpone the permission and ask Claude to "look at the implementation in that other repo," and you get a very confident zero.
How Read treats an absolute path outside the allowed roots varies with settings and version. It worked in my setup at times, but I don't reason "it can read it, so it can find it." I run /add-dir before searching, every time.
Still nothing: suspect the filesystem
Only when all four boxes are empty do I look at the filesystem itself, in this order.
# 1. Case (macOS is often case-insensitive)
ls -la src/Components 2>&1
ls -la src/components 2>&1
# 2. Broken symlinks
find . -type l ! -exec test -e {} \; -print
# 3. Invisible characters in filenames (NBSP, zero-width space)
ls src/ | cat -A
# 4. Does the file really exist?
stat src/components/Button.tsxAfter I rebuilt a monorepo layout, links that pnpm install should have recreated were left behind as leftovers, and an evening disappeared. When I find broken links, deleting them and re-running pnpm install often resolves it. Still, this is the last box; most of my dead ends fit the first four.
The order I run in my head
When a search comes back empty, I check in this order. It takes about thirty seconds and beats rephrasing the same request by a wide margin.
First, find to confirm the file exists. Second, whether I'm looking in build output or dependencies — if so, I switch to Bash with rg --hidden --no-ignore. Third, whether a dot-folder is involved, or the pattern has a metacharacter or a missing **/. Last, whether I'm outside the workspace.
One opening line that prevents most of it
I add a few lines like these to the opening prompt of a session:
- When ignored or hidden files matter, use
rg --hidden --no-ignoreviaBash - When another repository might be involved, suggest
/add-dirfirst - When Glob returns zero, confirm with
findbefore giving up
Handing over how to choose tools has been faster, in my experience, than hoping the model reaches for find on its own. Over the past year, rework from "I can't see that file" has nearly disappeared.
Deciding whether to use a dedicated tool or drop to Bash is itself a debugging skill, and I touched on that in when Bash commands don't behave as expected.
When you get a zero, run find once before you ask again. I keep that rule even on rushed days. Next time Glob comes back empty, I'd suggest trying rg --hidden --no-ignore --files | grep <your-pattern> just once.