Picking the right built-in tool: Grep for content, Glob for file names, Read and Write for whole files, Edit for unique-match changes, and exploring a codebase incrementally instead of reading everything first.
Study it
Built-in tools: Grep, Glob, Read, Write, Edit and Bash, and incremental exploration
Lesson coming
Sample questions
Try each one before opening the answer. Every option is explained, with the Anthropic documentation page that proves it.
Question 1 · choose 1
Your developer productivity agent is configured with the Read, Write, Edit, Bash, Grep and Glob tools. An engineer asks it to find every place in a large TypeScript repository that calls the function parseInvoiceLine. Which tool should the agent start with?
AGlob, with a pattern such as **/*parseInvoiceLine* to match the relevant files
BBash, running ls -R to list the repository tree and pick likely files to open
CGrep, searching the contents of the repository's files for the function name
DRead, opening every file under src to look for the calls one file at a time
Show the answer and why
AGlob, with a pattern such as **/*parseInvoiceLine* to match the relevant files
Incorrect
Glob matches file paths, not file contents; callers live in files with unrelated names.
BBash, running ls -R to list the repository tree and pick likely files to open
Incorrect
A directory listing shows names only and still leaves the agent guessing which files contain calls.
CGrep, searching the contents of the repository's files for the function name
Correct
Grep searches inside files for patterns such as function names, which is exactly what finding callers needs.
DRead, opening every file under src to look for the calls one file at a time
Incorrect
Reading everything up front is slow and fills the context with irrelevant code.
Use Grep for content searches such as callers, error messages and imports, then Read only the files the search turns up.
An engineer asks your agent (Read, Write, Edit, Bash, Grep and Glob are available) how a legacy payments package is used across the codebase. Other modules import it only through a wrapper module that re-exports some of its functions under new names. Which TWO approaches build an accurate picture efficiently? (Choose TWO.)
ARead every file in the repository first so that no usage of the package can be missed
BList the names the wrapper exports, then Grep for each of those names across the codebase
CUse Grep to find entry points and imports, then Read those files and follow their imports outward
DUse Glob to search file contents for the package's original function names
EGrep only for the package's import path, since every caller must import the package directly
Show the answer and why
ARead every file in the repository first so that no usage of the package can be missed
Incorrect
Reading everything up front wastes context and time on files that never touch the package.
BList the names the wrapper exports, then Grep for each of those names across the codebase
Correct
Callers use the wrapper's names, so tracing usage means searching for every exported name, not only the original ones.
CUse Grep to find entry points and imports, then Read those files and follow their imports outward
Correct
Searching first and reading along the import chain builds understanding incrementally without loading the whole tree.
DUse Glob to search file contents for the package's original function names
Incorrect
Glob matches paths, not contents, and the original names miss calls made through the wrapper's new names.
EGrep only for the package's import path, since every caller must import the package directly
Incorrect
Callers import the wrapper, not the package, so this search misses them.
Explore incrementally: search for entry points with Grep, read along the imports, and when a wrapper renames things, enumerate its exports and search for each name.
Your agent greps for a symbol and finds nothing, yet the symbol appears in a generated file under dist/, which is listed in .gitignore. Why, and what works?
AThe symbol must be quoted differently in the pattern
BGrep skips gitignored files; pass the file's path
CGrep only searches files that have been read before
DGrep cannot read generated files of any kind
Show the answer and why
AThe symbol must be quoted differently in the pattern
Incorrect
The pattern is fine; the file was never searched.
BGrep skips gitignored files; pass the file's path
Correct
Grep respects .gitignore, and a direct path searches the ignored file.
CGrep only searches files that have been read before
Incorrect
Read history does not limit Grep.
DGrep cannot read generated files of any kind
Incorrect
It can, when given the path.
Grep skips gitignored files by default; Glob does not. To search an ignored file, pass its path to Grep explicitly.
In a large Go repository where the word "interface" appears thousands of times, your agent must find every function that takes interface{} as a parameter. Its Grep call with the pattern func.*(interface{}) returns an error from the search engine instead of matches. What should it do?
AGrep for the plain word interface and read every match to find the right ones
BWrap the pattern in quotes so that Grep treats it as literal text
CSet multiline to true so that the pattern can match across the braces
DEscape the metacharacters, for example interface\{\}, since Grep uses ripgrep's regex syntax
Show the answer and why
AGrep for the plain word interface and read every match to find the right ones
Incorrect
This works in principle but returns thousands of matches to read, which the precise pattern was meant to avoid.
BWrap the pattern in quotes so that Grep treats it as literal text
Incorrect
Grep takes a regular expression; quoting the pattern does not change how its metacharacters are read.
CSet multiline to true so that the pattern can match across the braces
Incorrect
Multiline matching lets a pattern span lines; it does not fix unescaped metacharacters.
DEscape the metacharacters, for example interface\{\}, since Grep uses ripgrep's regex syntax
Correct
Grep is built on ripgrep, so braces and parentheses are regex syntax and need escaping to match literally.
Grep uses ripgrep's regular expressions, not literal text: characters such as { } ( ) need escaping, as in interface\{\}. A pattern ripgrep rejects returns an error with its diagnostic so the agent can correct the input and search again.
Your agent runs Glob with the pattern **/*.ts in a large monorepo and receives exactly 100 paths plus a truncation flag. It needs the TypeScript files of one service only. What should it do?
ASwitch to Grep with an empty pattern to list all files
BRun the same pattern again to receive the next 100 paths
CTreat the 100 paths as the complete list of TypeScript files
DNarrow the pattern, for example to services/billing/**/*.ts
Show the answer and why
ASwitch to Grep with an empty pattern to list all files
Incorrect
Grep searches contents; it is not a file lister.
BRun the same pattern again to receive the next 100 paths
Incorrect
Glob does not page through results that way.
CTreat the 100 paths as the complete list of TypeScript files
Incorrect
The truncation flag says the list is incomplete.
DNarrow the pattern, for example to services/billing/**/*.ts
Correct
Glob results are capped at 100; a narrower pattern returns the files actually needed.
Glob returns up to 100 paths sorted by modification time and flags truncation, so narrow the pattern when the cap is hit.
Your Agent SDK assistant runs on Linux, and you expect it to use the Grep and Glob tools, but transcripts show it searching with find and grep through Bash instead. What explains this?
ABash is always preferred over built-in tools by design
BThe repository is too large for Grep and Glob
CGrep and Glob are off by default there unless named in the options
DGrep and Glob only work in interactive Claude Code sessions
Show the answer and why
ABash is always preferred over built-in tools by design
Incorrect
The choice follows which tools the session has.
BThe repository is too large for Grep and Glob
Incorrect
Size does not remove tools.
CGrep and Glob are off by default there unless named in the options
Correct
On macOS, Linux and WSL the default set leaves them out, and Claude searches through Bash.
DGrep and Glob only work in interactive Claude Code sessions
Incorrect
They are available in the SDK when included.
On macOS, Linux and WSL, Claude Code's default tool set omits Glob and Grep; naming them in tools or allowedTools brings them back.