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.
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.
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.
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.