Skip to content
BENIBIX Learn

Glob vs Grep

People often think Glob and Grep both search inside files. Only Grep does. Glob matches file names, such as every file that ends in .ts. Grep looks inside the files for a word or a pattern. There is one more catch. Glob also finds the files .gitignore hides, while Grep skips them.

AI⌨️ Claude Code

Glob Tool

The tool that finds files whose names match a pattern.

The Glob tool finds files by their names, using a pattern such as **/*.js for every JavaScript file. It lists up to 100 files, newest first. It does not skip the files your .gitignore hides. On Windows it is on by default. On macOS and Linux, Claude Code leaves it out and Claude uses the find command through Bash instead. You get it back by naming it in --allowedTools.

Example
Jack asks where the tests are. Claude searches for the pattern **/*.test.ts and gets a list of every test file in the project.
Why it matters
Finding the right files is the first step of almost any change.
Full entry
AI⌨️ Claude Code

Grep Tool

The tool that searches inside files for a word or pattern.

The Grep tool searches inside files for text that matches a pattern. It is built on a fast search program called ripgrep. By default it returns only the names of files that match. It can also return the matching lines, or a count per file. It skips the files your .gitignore hides. Like Glob, it is left out by default on macOS and Linux, where Claude uses grep through Bash.

Example
Lucy asks where an old function is still used. Claude searches for its name and gets back the six files that call it.
Why it matters
It finds the spots to change in a big project. It does not have to read each file.
Full entry

In one line

Glob Tool
The tool that finds files whose names match a pattern.
Grep Tool
The tool that searches inside files for a word or pattern.