Task statement 2.5 · Tool design and MCP integration

Select and apply built‑in tools (Read, Write, Edit, Bash, Grep, Glob) effectively

The engineer has never opened the billing code, so the agent does the reading through six built-in tools. Each wrong choice has a visible cost here: a search that finds nothing although the code exists, an edit that is refused every time, or a context window full of files the question never needed.

Scenario switchThis section leaves the support agent. Built-in tools read and change a codebase, so it runs on the declared secondary scenario, Developer Productivity with Claude: an Agent SDK agent helping an engineer understand and change a legacy billing system of about 900 files. The rest of Domain 2 stays with the support agent.
Why it's tested

The tempting moves all feel thorough. Reading the whole billing codebase first seems safe, but it fills the context window before the agent knows what matters. Retrying a rejected Edit seems persistent, but the rejection is deterministic, so the retry fails the same way. Searching for a function with a filename pattern returns no matches, which looks like "no callers" when the pattern simply never looked inside a file.

KnowledgeGrep searches contents, Glob matches paths

Grep opens files and searches their contents for a pattern, such as a function name, an error message or an import statement. Glob never opens a file. It matches file paths against a glob, a filename pattern such as **/*.test.tsx (every test file at any depth) or **/*.sql (every file with that extension). So the question "where is roundCurrency called?" is about contents and needs Grep, while "which files are migrations?" is about names and needs Glob. A Glob for a function name returns nothing, and an agent that reads that as "unused" draws the wrong conclusion.

Searches contents

Grep

Grep("roundCurrency")
src/invoices/close.ts:58
src/dunning/schedule.ts:112
Grep("Invoice total mismatch")
src/invoices/validate.ts:41

Built on ripgrep, so patterns use ripgrep regex, and it skips files listed in .gitignore.

Matches paths

Glob

Glob("**/*.sql")
db/migrations/0001_invoices.sql
db/migrations/0002_fees.sql
Glob("**/roundCurrency*")
// no matches: no file has that name

Results are sorted by modification time, and gitignored files are included by default.

More precise than the guide. Current Claude Code leaves Glob and Grep out of the default tool set on macOS, Linux and WSL, and Claude searches with find and grep through Bash instead. Naming either tool in the --tools or --allowedTools launch flags, or in the equivalent Agent SDK options, brings them back (checked 2026-10-01). Exam answer: Grep searches file contents and Glob matches file paths.

KnowledgeRead, Write, Edit and Bash

Read and Write work on whole files, while Edit makes a targeted change by unique text matching. Edit takes an old_string, the anchor text it searches for, and replaces it with a new_string. The match is exact, with no regex, and the anchor must appear exactly once, so an anchor that occurs three times is rejected rather than applied to a guess. Bash covers what no dedicated tool does, such as running the test suite.

Read

Returns a file with line numbers. A file over the token limit returns its first page with a PARTIAL view notice.

Write

Creates a file or overwrites all of it. It never appends or merges.

Edit

Replaces one exact, unique old_string in a file read earlier in the conversation. A PARTIAL view read does not count.

Bash

Runs a shell command. A cd inside the project carries over to later commands, but an export does not.

SkillWhen Edit cannot find unique anchor text

The engineer asks the agent to raise the refunds timeout, the second of three identical lines in billing/config.ts. The agent sends old_string: "timeout: 3000,", the edit is rejected, and the identical retry is rejected again, because the text appears three times. The docs give two ways out. Widening the anchor with the line above it (retries: 2,) makes it match once, and replace_all: true changes every occurrence, which is right only when all three should change. The guide's fallback is to Read the full file and Write it back with the one line changed, which works even when no nearby text is unique.

Interactive · one Edit, three outcomes

billing/config.ts holds three identical timeout lines. An Edit call searches the file for old_string, finds three matches and rejects the change; widening old_string with the line above makes one match; the Read plus Write fallback rewrites the whole file with one line changed. billing/config.ts timeout: 3000, retries: 2, timeout: 3000, verbose: false, timeout: 3000, Edit searches for old_string Read loads the whole file Edit 3 matches 1 match Read + Write old_string: timeout: 3000, not unique old_string widened with "retries: 2," whole file written back outcome not run yet rejected, every retry applied to line 3

Choose how to change one timeout. old_string is timeout: 3000,.

Edit is rejected: the text matches three times, so there is no single place to apply it. Retrying fails the same way.

Docs resolution: add the line above to old_string, so exactly one occurrence matches.

Guide fallback: Read the full file, then Write all of it back with only line 3 changed.

Time reads downward: the file is searched or read, then the verdict, then the outcome. The highlighted lines are the ones the current step matches or changes. In the Read + Write step the whole file is written back, but only the second timeout differs.

SkillExploring 900 files without reading 900 files

The engineer asks how a late fee ends up on an invoice. Reading every file first would fill the context window with code the question never touches, and the few relevant lines would be hard to find among them. Building understanding incrementally works better: Grep finds an entry point, then Read follows its imports and traces the flow, so every file in context is one the question needs.

Upfront

Read everything first

Glob("**/*.ts")   → 900 files
Read(...) × 900
Incremental

Follow the imports

Grep("applyLateFee")
  → src/invoices/close.ts:58
Read("src/invoices/close.ts")
  → imports lateFee from billing
Read("billing/index.ts")

That trace has just reached a wrapper module, which renames functions on the way out. Callers import lateFee, so a Grep for the original name calcLateFee finds only the definition and the wrapper. First identify all the names the wrapper exports, then search for each name across the codebase.

// billing/index.ts (the wrapper)
export { calcLateFee as lateFee, calcTax as salesTax } from './legacy/fees';
Grep("calcLateFee") → billing/legacy/fees.ts, billing/index.ts
Grep("lateFee")     → 14 files
Grep("salesTax")    → 9 files
Before you call a tool, ask: What am I looking for, or changing?
Text inside filesGrep, then Read only the files it returns.
Files by name or extensionGlob.
One line whose text is not uniqueWiden old_string if nearby text is unique; otherwise Read the file and Write it back.
Takeaway
  • A function name is content, so a filename pattern will never find its callers.
  • A rejected Edit fails identically on retry; the guide's fallback is a full Read then Write.
  • Start from one Grep hit and follow imports, and search every name a wrapper exports.

check yourself

0 / 3 answered

An engineer asks how a declined card payment becomes a dunning email in the legacy billing system. The only clue is the log line Payment declined, scheduling retry. The agent must finish a refactor in the same session afterwards, so its context window cannot fill with files unrelated to this flow.What is the most effective first step?

Select one.

A tax change needs two edits. In eu-vat.ts, all four lines reading vatRate: 0.20, must become 0.21. In uk-vat.ts, generated code repeats one block three times, and only the first block's rate must change. The blocks are identical line for line, so adding neighbouring lines to old_string still matches all three.Which TWO moves best make both changes?

Select two.

Before deprecating issueCreditNote, an engineer needs every caller. Grep finds only its definition in legacy/credits.js and one line in billing/index.js: export { issueCreditNote as credit, issueCreditNote as issueCredit }. About 600 files import from billing, and the agent's context window cannot hold them.Which next step most directly finds every caller?

Select one.

sources

  1. Claude Code Docs, "Tools reference": Glob and Grep absent from the default tool set on macOS, Linux and WSL, with searches going through find and grep in Bash, and restored by naming them in --tools, --allowedTools or the Agent SDK options; Grep on ripgrep and skipping gitignored files; Glob sorted by modification time and not respecting .gitignore by default; Edit's read-before-edit, exact-match and uniqueness checks, with a longer old_string or replace_all: true; Write overwriting whole files; Read's PARTIAL view; Bash cd and export persistence. Checked 2026-10-01.
  2. Grep for contents and Glob for paths, **/*.test.tsx, the Read + Write fallback when Edit cannot find unique anchor text, incremental exploration from entry points, and tracing wrapper modules by exported names: Claude Certified Architect — Foundations Exam Guide v1.0, Domain 2.5. Scenario: the guide's Scenario 4; the legacy billing system is the course's scenario detail.