CertSafari
    Anthropic Claude Certified Architect – Foundations (CCAR-F)· Lessons

    Domain 2 · Lesson 12/30

    Built-in tools in Claude Code: Grep, Glob, Read, Edit, Write and Bash

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

    12 min read
    3.6% of exam
    3 sources
    Published 17 Nov 2026
    Docs as of 11 Nov 2026

    What you will be able to do

    • Choose Grep for searching file contents and Glob for matching file paths, and explain why each is the wrong tool for the other's job
    • Recover from a failed Edit by lengthening old_string, by setting replace_all when every match should change, or by using Read + Write when no unique anchor exists
    • Explore an unfamiliar codebase step by step: search for an entry point, then read along the call chain
    • Trace a function through a wrapper module by listing its exported names and searching for each one

    Key concept

    Content search vs path search — Grep looks inside files for text such as a function name, an error string or an import. Glob looks only at file names and paths, such as every file matching **/*.test.tsx. Picking the right built-in tool starts with knowing which of the two questions you are asking.

    1.Grep searches contents, Glob matches paths

    Claude Code comes with a small set of built-in tools for working with a project's files, and each one answers a different kind of question. Read loads a file's contents. Write creates a file or replaces one completely. Edit changes a targeted span of text inside an existing file. Bash runs any shell command. Grep and Glob both search, but they search different things, and that difference is the one to learn first.

    Six built-in tools: what each does and whether it needs permission
    ToolDescriptionPermission required
    ReadReads the contents of filesNo
    GrepSearches for patterns in file contentsNo
    GlobFinds files based on pattern matchingNo
    EditMakes targeted edits to specific filesYes
    WriteCreates or overwrites filesYes
    BashExecutes shell commands in your environmentYes

    Grep looks inside files. Use it when the thing you want is a string in the code: every caller of validateToken, the file that raises "session expired", every module that imports authClient. The search pattern is a regular expression, so a single search covers validateToken( everywhere it is called. The result tells you where that text lives, which is what you need to find callers, error sources and dependencies.

    Glob looks only at names. Use it when what you know is a naming convention: **/*.test.tsx for every React test file, or src/components/**/*.tsx for every component. Glob never opens a file. That makes it the right tool for structural questions like "which components have no test file?" when tests follow a fixed naming pattern. Glob the components, Glob the tests, and compare the two lists of paths. Searching file contents for the word test answers a different question: it misses tests that live in separate files, and it matches comments that mention testing.

    Both are better choices than doing the same search through Bash with grep or find. Grep, Glob and Read need no permission because they only observe. Bash can run anything, so every Bash call needs permission, even a harmless search. That is why the read-only analysis set for an Agent SDK agent is exactly Read, Glob and Grep, with Bash added only when the agent has to execute something. Which tools each agent gets is covered in distributing tools across agents.

    Agent SDK tool sets by job
    ToolsWhat the agent can do
    Read, Glob, GrepRead-only analysis
    Read, Edit, GlobAnalyze and modify code
    Read, Edit, Bash, Glob, GrepFull automation

    Checkpoint 1 of 6· Check yourself

    Your project's tests always sit in their own files named *.test.tsx. You need to know which React components under src/components have no test file yet. Which approach answers this?

    Checkpoint 2 of 6· Exam question

    An architect asks Claude Code to count how many files in the src/components directory tree currently have no matching test file at all, as a first step in planning test coverage work. Assume that the project follows a consistent and reliable naming convention that pairs each component file with its corresponding test file (for example, Button.tsx is tested by Button.test.tsx). Which approach most directly answers this without unnecessary file reads?

    Sources12

    2.Edit needs a unique anchor; Read + Write is the fallback

    Edit replaces text it finds by exact match. You give it an old_string and a new string, and it swaps one for the other. It has no line numbers and no function names, only that string. Two rules decide whether the call works. The first is matching: old_string must appear in the file exactly as written, and one character of different whitespace or indentation is enough to miss. The second is uniqueness: old_string must appear exactly once. Edit also expects Claude to have read the file earlier in the same conversation, so Read normally comes before Edit.

    A duplicate match has two correct fixes, and the intent decides which one. If only one occurrence should change, make old_string longer: include the function signature or the line above, so the combined text appears once in the file. If every occurrence should change, set replace_all: true. That flag replaces all of them, never just the first. Searching with Grep first doesn't help with this. Grep can show you where the duplicates are, but Edit picks its target from old_string alone, so retrying the same string fails the same way.

    When no unique anchor can be built, use Read, then Write. Some files repeat the same text so many times, such as generated config, repeated blocks or identical boilerplate, that no amount of context makes a string appear only once. In that case, Read the whole file, make the change in the full contents, and Write the complete result back. Write creates or overwrites a file. It does not patch it. Pass it a single line and the file becomes that single line. This is why Write is the fallback and not the first choice: it rewrites the whole file, while Edit touches only the matched span.

    Recovering from a failed Edit
    SituationCorrect move
    old_string differs by whitespace or indentationCopy the exact text from a fresh Read and retry Edit
    old_string matches several times, only one should changeExtend old_string with surrounding context and retry Edit
    old_string matches several times, all should changeRetry Edit with replace_all: true
    No unique anchor exists at allRead the full file, then Write the complete new contents

    Checkpoint 3 of 6· Check yourself

    A generated config file repeats the same block so many times that adding surrounding context never makes any old_string match only once. Only one copy of the block should change. Which recovery works?

    Checkpoint 4 of 6· Exam question

    A developer wants Claude Code to update a deprecated log statement logger.warn("legacy-path") that appears twice in the same file, in two different functions, where only one of the two occurrences should change. Claude issues an Edit call with old_string set to exactly that log statement and the call fails. What is the correct next step?

    Sources1

    3.Exploring a codebase: search first, then read

    Understanding builds up one hop at a time, not in one bulk load. Claude Code's own working loop shows the order: search for the relevant source files, read those files, then act. Reading every file under src/ before you know where the login flow starts fills the context window with code that has nothing to do with the task. Picking files by size or by recent modification date is guessing, and it has the same cost. Why that context matters over a long exploration is covered in context management in large codebases.

    Take a concrete task: trace a login request from its HTTP route handler down to the database call, in a repository Claude has never seen.

    1. Read CLAUDE.md, or AGENTS.md if the repo has one, for architecture and conventions. That is the purpose of those files (CLAUDE.md hierarchy).
    2. Grep for an entry point, such as the login route path or the handler's name.
    3. Read the handler file, and note what it imports.
    4. Read the next module along the call chain. Grep again whenever a name's definition isn't obvious.
    5. Stop when you reach the database call. Files outside the chain are never loaded.

    Wrapper modules break a simple search, so list their exports first. A module that wraps a library or an internal service often re-exposes its functionality under its own names. Grepping for the underlying function finds only the wrapper and misses the code that calls the wrapper. The reliable procedure is in two steps. First, Read the wrapper and write down every name it exports. Then Grep for each exported name across the codebase. The combined results are the real set of call sites, including callers that never mention the original function.

    Checkpoint 5 of 6· Check yourself

    Claude has to trace how a password-reset request goes from its HTTP route to the database write, in a repository it has never seen. After reading CLAUDE.md, what should it do next?

    Checkpoint 6 of 6· Exam question

    A newly onboarded architect asks Claude Code to trace how a login request flows from the HTTP route handler through to the database call, in a codebase Claude has not explored yet. To build this understanding efficiently while keeping context usage low, what is the best incremental strategy?

    Sources231

    Sources

    (3)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Searches for patterns in file contents.”
      ↩︎ Grep searches contents, Glob matches paths
      “Finds files based on pattern matching.”
      ↩︎ Grep searches contents, Glob matches paths
      “Executes shell commands in your environment. See Bash tool behavior | Yes”
      ↩︎ Grep searches contents, Glob matches paths
      “Match: old_string must appear in the file exactly as written. A single character of whitespace or indentation difference is enough to miss.”
      ↩︎ Edit needs a unique anchor; Read + Write is the fallback
      “Uniqueness: old_string must appear exactly once.”
      ↩︎ Edit needs a unique anchor; Read + Write is the fallback
      “Claude reads the file in the current conversation before editing it”
      ↩︎ Edit needs a unique anchor; Read + Write is the fallback
      “Searches for patterns in file contents.”
      ↩︎ Exploring a codebase: search first, then read
      “Searches for patterns in file contents.”
      ↩︎ Key concept
      “Finds files based on pattern matching.”
      ↩︎ Exam trap 1
      “or sets replace_all: true to replace them all”
      ↩︎ Exam trap 2
      “Creates or overwrites files.”
      ↩︎ Exam trap 3
      “Glob | Finds files based on pattern matching.”
      ↩︎ Checkpoint
      “Claude either supplies a longer string with enough surrounding context to pin down one occurrence”
      ↩︎ Prediction
      “Write | Creates or overwrites files.”
      ↩︎ Checkpoint
    2. 2.
      “Find files by pattern, search content with regex, explore codebases”
      ↩︎ Grep searches contents, Glob matches paths
      “Read those files to understand the code”
      ↩︎ Exploring a codebase: search first, then read
      “A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session.”
      ↩︎ Exploring a codebase: search first, then read
      “Search for the relevant source files”
      ↩︎ Exam trap 4
      “Search for the relevant source files”
      ↩︎ Checkpoint
    3. 3.
      “trace the login process from front-end to database”
      ↩︎ Exploring a codebase: search first, then read

    Spotted a mistake, or was something unclear? Tell us.