How Claude Code Reads Code: the Read, Grep, and Glob Tools
How Claude Code Reads Code: the Read, Grep, and Glob Tools
~6 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026
Chapter 4 already hinted at this: Claude Code doesn't read your entire project in one go, but in a targeted way, using the same principles a human would use to explore an unfamiliar project. For this, it has three fundamental, purely read-only tools available. This chapter explains each one individually, so you can follow what happens behind the scenes when Claude Code answers a question about your code.
Read: reading one specific file
Read opens a specific, named file and reads its content - just like you'd open a file in an editor yourself. Claude Code uses Read whenever it already knows (or just found out) which file is relevant: for example after you write "Look at server.js", or after a search has found a matching file.
For very long files, Read doesn't necessarily read the entire file at once - it can read a targeted section instead, similar to how you'd scroll to a specific spot in a long document rather than going through every line.
Grep: searching for a term or pattern
Grep searches the content of files for a specific piece of text or pattern - the name comes from a decades-old command-line tool of the same name from the Unix world. If you ask, for example, "Where is the function calculateDiscount called from?", Claude Code uses Grep to find every occurrence of that name across the whole project, without having to manually read through every single file.
Grep is therefore the tool of choice when you know what you're looking for (a function name, an error message, a config variable) but not where it is.
Glob: finding files by name pattern
Glob finds files by their name or path pattern, not by their content. A pattern like **/*.test.js, for example, finds every test file in the whole project, no matter which subfolder it's in. Glob is used whenever the question is more "Which files of this type exist?" than "What's inside the files?".
How the three tools work together
In practice, Claude Code often combines these tools within a single answer. If you ask, for example, "Where is the API key loaded, and is it accidentally hardcoded anywhere?", a typical flow might look like this:
- Glob finds every configuration file in the project.
- Grep searches these and other files for the term "API_KEY" or similar patterns.
- Read opens the matches found, to check the exact context and give a well-founded answer.
This interplay happens automatically in the background - you don't need to name or call the tools yourself. But it helps a lot to know how they work, so you can understand why an answer is sometimes fast and sometimes takes a bit longer, and so you can ask better questions yourself ("Search the whole project for ..." instead of "Look at some file").
Tipp: All three tools in this chapter are purely read-only - they don't change anything in your project. That's exactly why Claude Code doesn't ask for extra confirmation to use them by default, unlike the tools in the next chapter, which actually change things.