Grep Tool - Claude Code
Search file contents by pattern with regex support.
Grep searches the contents of files in the repo. It's how Claude finds usages, references, and matching lines without reading every file.
What it does
Grep runs a regex (or plain string) against file bodies and returns matching lines with file paths. You can scope it to a subdirectory, filter by glob, and ask for counts or file-only output. It's powered by a fast recursive search so it handles large repos comfortably.
When to use it
- Finding usages of a function, component, or constant.
- Hunting down TODO comments or error strings.
- Pre-filtering files before a multi-file edit.
- Confirming that a symbol doesn't leak beyond expected modules.
Gotchas
- Regex special characters need escaping - parens, brackets, pipes, dots.
- Grep returns bounded output. Very noisy patterns get truncated - narrow the scope.
- Results respect
.gitignoreby default, so node_modules stays out of the way.
Official docs: https://code.claude.com/docs/en/tools-reference.md
Technical content at the intersection of AI and development. Building with AI agents, Claude Code, and modern dev tools - then showing you exactly how it works.
Get the weekly deep dive
Tutorials on Claude Code, AI agents, and dev tools - delivered free every week.
Was this helpful?




