CCA-FChapters13

Chapter 13

Built-in Tools

One job per tool, Grep-first investigation, and what to do when Edit has nothing unique to match.

D2guide part i

13.1

Tool selection

Six tools, one job each. Scenario questions here are really asking which job you are doing.

toolthe jobexample
Globfind files by name or pattern**/*.test.tsx, src/components/**/*.ts
Grepsearch inside filesa function name, an error message, an import
Readload a file in fullread it once you know it matters
Writecreate a file from scratcha new module, a new config
Editchange an existing file preciselyreplace a snippet matched by unique text
Bashrun a shell commandgit, npm, tests, build

13.2

Investigate in steps, not in one gulp

Search narrows, read confirms, search again from what you learned. Never read everything first.

1 · Grep — find entry points2 · Read — the files it found3 · Grep — find the usages4 · Read — the consumersrepeat until thepicture is completecontext spentonly on matches
Each Grep is cheap and targeted; each Read is paid for by a match. The loop ends when the picture closes.

13.3

When Edit cannot match

Edit needs unique text. If the snippet appears twice, it fails — and retrying it fails identically.

Readfull contents
modifyprogrammatically
Writethe updated version
The fallback is not a different edit tool; it is taking responsibility for the whole file.

Recall in 60 seconds

  1. Glob finds files by name; Grep searches inside them.
  2. Read loads a file in full — after a search told you it matters.
  3. Edit replaces a snippet matched by unique text; Write creates a file.
  4. Bash is for shell commands — git, npm, tests, builds.
  5. Investigate incrementally: Grep entry points → Read → Grep usages → Read consumers → repeat.
  6. Never read every file up front; each Read should be earned by a match.
  7. Edit fails on a non-unique match — fall back to Read, modify, Write.