Built-in Tools
This module is about choosing the right Claude Code built-in tool for codebase navigation and file modification.
The official task statement focuses on six tools:
Claude Code’s current tools reference confirms that these built-in tool names are used directly in permissions, subagent tool lists, CLI flags, and hooks. (Claude Code)
The exam will test whether you can distinguish:
Grep = search inside files
Glob = find files by path/name pattern
Read = inspect file contents
Edit = targeted exact replacement
Write = create or overwrite whole files
Bash = run commands, tests, builds, scripts
1. High-level decision table
| User / agent need | Best tool | Why |
|---|---|---|
Find all callers of calculateTotal |
Grep | Search file contents |
Find files named *.test.tsx |
Glob | Match file paths/names |
Inspect src/api/user.ts |
Read | Load file contents |
| Change one unique function body | Edit | Targeted exact replacement |
| Create a new test file | Write | New full-file operation |
| Replace an entire generated config | Write | Whole-file overwrite |
| Run tests/build/lint | Bash | Command execution |
| Find an error message string | Grep | Content search |
Find all route files under app/ |
Glob | Path pattern search |
| Edit fails because old text appears multiple times | Read + longer Edit anchor, or Read + Write fallback | Need reliable modification |
2. Grep: search file contents
Use Grep when you are looking for text inside files.
Claude Code’s docs define Grep as a file-content search tool: Glob finds files by name, while Grep finds lines inside files. Claude Code Grep is built on ripgrep, supports regex syntax, and can return file paths, matching content, or counts. (Claude Code)
Use Grep for
Function names
Class names
Import statements
Error messages
Feature flags
API endpoint strings
Environment variable names
Test names
Call sites
Exported symbols
Examples:
Search for all callers of getUser:
Grep pattern: "getUser("
Search for an error message:
Grep pattern: "Invalid order ID"
Search for imports from a module:
Grep pattern: "from ['\"]@/lib/auth"
Search for React hook usage:
Grep pattern: "useFeatureFlag"
Search only TypeScript React files:
Grep pattern: "useCheckout"
glob: "**/*.tsx"
Exam clue
If the question says:
Find all callers
Locate where this error is thrown
Find every import of this module
Find every usage of this function
Search for this string across the codebase
choose Grep.
Common exam trap
Wrong:
Correct:
3. Glob: find files by path/name pattern
Use Glob when you are looking for files by filename, extension, or path pattern.
Claude Code’s docs define Glob as file-name pattern matching and show patterns such as **/*.js, src/**/*.ts, and *.{json,yaml}. Results are sorted by modification time and capped, so overly broad patterns may need narrowing. (Claude Code)
Use Glob for
Find all test files
Find route files
Find migration files
Find config files
Find files by extension
Find files under a directory
Find files matching naming convention
Examples:
Find all TSX test files:
Glob pattern: "**/*.test.tsx"
Find all route files:
Glob pattern: "app/**/route.ts"
Find all migration files:
Glob pattern: "db/migrations/*.sql"
Find package configs:
Glob pattern: "**/package.json"
Find story files:
Glob pattern: "**/*.stories.tsx"
Find React components:
Glob pattern: "src/components/**/*.tsx"
Exam clue
If the question says:
Find files named...
Find all files ending in...
Find files under this directory...
Find all tests matching...
Find all .tsx files...
choose Glob.
Common exam trap
Wrong:
Correct:
4. Grep vs Glob: the most important distinction
Memorize this:
| Task | Correct tool |
|---|---|
Find useAuth() calls |
Grep |
Find **/*.auth.ts files |
Glob |
Find all throw new Error("...") occurrences |
Grep |
Find all *.spec.ts files |
Glob |
Find files importing lodash |
Grep |
Find files under src/pages/** |
Glob |
Find TODO comments |
Grep |
| Find all markdown docs | Glob |
A trick exam question might say:
Find all files that call
submitOrder.
That is still Grep, because the thing you are finding is a content pattern. The output may be file names, but the search target is inside file contents.
5. Read: inspect specific file contents
Use Read when you know which file you need to inspect.
The Anthropic text editor docs describe the view operation as the way Claude examines the contents of a file or a specific line range. (Claude) In Claude Code exam language, that maps to using Read for file inspection.
Use Read when
You already have a specific path.
Grep/Glob found a candidate file.
You need surrounding context before editing.
You need to understand imports, exports, or local logic.
You need to inspect only a range of a large file.
Examples:
Read src/services/orderService.ts
Read src/components/CheckoutButton.tsx
Read the file containing the matching Grep result
Read the entrypoint found via Glob
Bad pattern
Better pattern
Grep to find entry points.
Read the most relevant files.
Follow imports.
Search again for called symbols.
Read only the next relevant files.
This is what the official statement means by building codebase understanding incrementally.
6. Edit: targeted exact modifications
Use Edit when you need to modify a specific, known piece of text in an existing file.
Claude Code’s Edit tool performs exact string replacement: it takes an old_string and new_string; the old string must match exactly, including whitespace, and it must appear exactly once unless replacing all matches is intended. Claude Code also requires the file to have been read earlier in the current conversation before editing. (Claude Code)
Use Edit for
Small targeted function changes
Renaming a unique constant
Adding a branch to a known conditional
Changing one import line
Updating one config value
Fixing a typo in a known location
Example:
Good because the anchor is likely unique.
Edit requirements to remember
1. The file must have been read first.
2. The old string must match exactly.
3. Whitespace matters.
4. The old string should be unique.
5. If it appears multiple times, Edit may fail or affect the wrong place unless scoped.
Exam clue
If the task says:
Modify this one known block
Replace this exact function
Change this unique import
Patch this small section
choose Edit, after Read.
7. Write: full file create or overwrite
Use Write when creating a new file or replacing an entire file.
Claude Code’s tool reference describes Write as the tool that creates or overwrites files. (Claude Code) The text editor docs similarly describe file creation as providing a path and full file text. (Claude)
Use Write for
Create a new file
Overwrite a generated file
Rewrite an entire small file
Fallback when targeted Edit is unreliable
Replace a config file with known complete content
Examples:
Create src/services/userService.test.ts
Overwrite generated/openapi-types.ts
Rewrite a small config file
Replace a whole markdown doc
Exam trap
Write is powerful because it overwrites whole files. It is not the best first choice for a small targeted change unless Edit cannot be made reliable.
8. Edit failure: non-unique match fallback
This is one of the official task statement’s most important skills.
Situation
Claude tries to Edit:
But the file contains:
The old string is not unique.
Preferred recovery order
Step 1: Read the file
Use Read to inspect the surrounding context.
Step 2: Try a more unique Edit anchor
Instead of editing only:
use a larger unique block:
replace with:
Step 3: Use Read + Write fallback
If the file has too many repeated blocks, generated formatting, or the target cannot be anchored reliably, use Read to load the current full file, then Write the corrected full file.
Exam answer pattern
If Edit fails due to non-unique text, the best answer is:
Read the file to get full context, then either use a longer unique Edit anchor or use Write to replace the file reliably.
Do not blindly retry the same Edit.
9. Bash: run commands, tests, builds, scripts
Use Bash for command execution, not as the first-choice search/edit tool.
Anthropic’s Bash tool docs describe Bash as enabling command-line execution, including development workflows such as running tests, builds, scripts, package installation, and system automation. They also emphasize safety practices such as timeouts, logging, command filtering, minimal permissions, and output handling. (Claude)
Use Bash for
Run test suites
Run lint/typecheck/build
Install dependencies
Run scripts
Inspect git status
Generate files through project tooling
Run formatters
Run codemods carefully
Examples:
Do not overuse Bash for tasks with specialized tools
Bad:
Better:
Bad:
Better:
Bad:
Better:
Exam heuristic:
Use specialized Claude Code tools for codebase search and file edits.
Use Bash for actual command execution.
10. Incremental codebase understanding workflow
The official statement explicitly says:
Start with Grep to find entry points, then use Read to follow imports and trace flows, rather than reading all files upfront.
Bad workflow
Read every file in src/
Try to infer the architecture from raw volume
Edit based on partial understanding
Problems:
Wastes context
Misses actual call paths
Increases hallucination risk
Makes irrelevant files dominate
Better workflow
Suppose the task is:
“Update how checkout errors are handled.”
A strong Claude Code workflow:
1. Grep for known error string or function:
"Checkout failed"
2. Grep for likely symbols:
"handleCheckoutError"
"submitCheckout"
"checkoutService"
3. Read the most relevant files from Grep results.
4. Follow imports from those files:
Read imported service/module files.
5. Grep for callers of the key exported function:
"submitCheckout("
6. Read callers that matter.
7. Make targeted Edit changes.
8. Bash test/typecheck relevant package.
This is efficient because it uses Grep to discover, Read to understand, Edit to change, and Bash to validate.
11. Tracing function usage across wrapper modules
The official statement calls this out directly:
Trace function usage across wrapper modules by first identifying all exported names, then searching for each name across the codebase.
This matters because a function may be re-exported, aliased, or wrapped.
Example
Suppose you are tracing:
The implementation file contains:
But another file re-exports it:
And another wrapper exposes:
If you only search:
you miss calls to:
Strong tracing workflow
1. Grep for the original implementation:
"function getCurrentUser"
"const getCurrentUser"
"export.*getCurrentUser"
2. Read the implementation file.
3. Grep for exports/re-exports:
"getCurrentUser"
"getCurrentUser as"
4. Identify aliases:
getCurrentUser
getUser
loadUser
5. Grep for each exported or aliased name:
"getCurrentUser("
"getUser("
"loadUser("
6. Read important caller files.
7. Follow imports to verify that the symbol is the same one, not an unrelated same-name function.
Exam trap
Wrong:
Correct:
12. Practical examples by task
Task A: “Find all tests for checkout”
Correct:
Glob: "**/*checkout*.test.ts"
Glob: "**/*checkout*.spec.ts"
Glob: "**/*.test.tsx" with path narrowed to checkout directories if needed
Why not Grep? You are searching by file name/path.
Task B: “Find every place that throws this error”
Correct:
Why not Glob? You are searching file contents.
Task C: “Change the retry count from 3 to 5 in config.ts”
Correct sequence:
If maxRetries: 3 appears multiple times:
Task D: “Add a new unit test”
Correct:
Glob to find existing test naming patterns
Read nearby test file to match conventions
Write new test file
Bash run targeted test
Example workflow:
Glob: "src/**/*.test.ts"
Read: src/services/userService.test.ts
Write: src/services/orderService.test.ts
Bash: npm test -- orderService.test.ts
Task E: “Understand request flow for POST /api/orders”
Correct:
Grep: "POST"
Grep: "/api/orders"
Glob: "app/**/route.ts" or "src/**/routes/**/*.ts"
Read matching route file
Follow imports with Read
Grep key service function callers
This combines Glob and Grep correctly.
13. Built-in tool anti-patterns
Anti-pattern 1: Reading everything upfront
Better:
Anti-pattern 2: Using Glob for content search
Better:
Anti-pattern 3: Using Grep for file path search
Better:
Anti-pattern 4: Using Write for small targeted changes
Better:
Anti-pattern 5: Retrying failed Edit without new context
Better:
Anti-pattern 6: Using Bash instead of specialized tools
Better:
14. Scenario-based questions
Question 1
You need to find every caller of calculateDiscount across a TypeScript codebase. Which tool should you use first?
A. Glob
B. Grep
C. Write
D. Bash
Answer
B. Callers are content inside files. Use Grep.
Question 2
You need to find all files matching **/*.test.tsx.
A. Grep
B. Glob
C. Edit
D. Write
Answer
B. This is file path pattern matching. Use Glob.
Question 3
Claude needs to modify one known conditional block in src/auth/session.ts. What is the best sequence?
A. Write the entire file immediately
B. Read the file, then use Edit with a unique exact old string
C. Use Bash sed -i without reading
D. Use Glob
Answer
B. Edit requires exact matching and should be grounded in a prior Read.
Question 4
An Edit fails because the old string appears three times in the file. What should Claude do?
A. Retry the same Edit
B. Use Bash to randomly replace the first match
C. Read the file for context, then use a longer unique anchor or fall back to Read + Write
D. Give up
Answer
C. The official fallback pattern is Read + Write when Edit cannot reliably identify a unique target.
Question 5
You are asked to locate an error message: "User not authorised for refund".
A. Glob
B. Grep
C. Write
D. Edit
Answer
B. Error messages are file contents. Use Grep.
Question 6
You are asked to find every route file in a Next.js app.
A. Glob app/**/route.ts
B. Grep route.ts
C. Read every file under app/
D. Write a route file
Answer
A. You are finding files by path/name pattern.
Question 7
A file has several repeated blocks:
Claude needs to change only one of them.
Best approach?
A. Edit return null; directly
B. Read the file, include surrounding context in the Edit old string, or use Read + Write
C. Use Glob
D. Use Grep only
Answer
B. The edit anchor must be unique.
Question 8
You need to understand how submitOrder flows through the app. What is the best first step?
A. Read all files
B. Grep for submitOrder to find definitions and callers
C. Write a new implementation
D. Run all tests immediately
Answer
B. Start with content search to find entry points, then Read relevant files.
Question 9
A function getCurrentUser is re-exported as getUser from a barrel file. How should you trace usage?
A. Search only getCurrentUser(
B. Identify exported aliases first, then Grep each exported name
C. Use Glob only
D. Read every file manually
Answer
B. Wrapper modules and aliases require searching exported names, not just the implementation name.
Question 10
Which task is best suited for Bash?
A. Find **/*.test.tsx files
B. Search for getUser( across source files
C. Run npm test after edits
D. Replace one unique import line
Answer
C. Bash is for command execution such as tests, builds, and scripts. Use Glob, Grep, and Edit for the other tasks.
Question 11
Claude needs to create a new file src/utils/formatCurrency.ts. Which tool should it use?
A. Write
B. Edit
C. Grep
D. Glob
Answer
A. Write creates or overwrites files.
Question 12
Claude needs to inspect a file found by Grep before changing it.
A. Read
B. Write
C. Glob
D. Bash
Answer
A. Read loads the file contents for understanding and edit grounding.
15. Final D2.5 checklist
Memorize this:
1. Grep searches file contents.
2. Glob searches file paths/names.
3. Read loads known file contents.
4. Edit performs targeted exact replacement.
5. Write creates or overwrites whole files.
6. Bash runs commands, tests, builds, scripts, and project tooling.
7. Use Grep for callers, imports, function names, error messages.
8. Use Glob for **/*.test.tsx, route files, configs, migrations.
9. Use Read before Edit.
10. Edit requires exact, unique old text.
11. If Edit fails due to non-unique text, use longer context or Read + Write.
12. Do not read the whole codebase upfront.
13. Build understanding incrementally: Grep → Read → follow imports → Grep again.
14. To trace wrappers, identify exported aliases first, then search each name.
15. Prefer specialized tools over Bash for search and file modification.
Exam mental model
For D2.5, think:
Search what is inside files? Grep.
Search which files exist? Glob.
Need to inspect? Read.
Need a small precise change? Edit.
Need a whole file operation? Write.
Need to execute project commands? Bash.
The most exam-relevant workflow is: