Skip to content

CCAR-F · Domain 2: Tool Design & MCP Integration · 18% of the exam

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

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?

  1. AGlob, with a pattern such as **/*parseInvoiceLine* to match the relevant files
  2. BBash, running ls -R to list the repository tree and pick likely files to open
  3. CGrep, searching the contents of the repository's files for the function name
  4. 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.

Question 2 · choose 2

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.)

  1. ARead every file in the repository first so that no usage of the package can be missed
  2. BList the names the wrapper exports, then Grep for each of those names across the codebase
  3. CUse Grep to find entry points and imports, then Read those files and follow their imports outward
  4. DUse Glob to search file contents for the package's original function names
  5. 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.

Question 3 · choose 1

Inside one file, a constant MAX_RETRIES is used eleven times and is being renamed to MAX_ATTEMPTS everywhere in that file. Which Edit approach fits?

  1. AOne Edit call with replace_all set to true
  2. BA Write call with the whole file retyped from memory
  3. CA Grep call with the new name as the pattern
  4. DA Glob call that renames matching text
Show the answer and why
  • AOne Edit call with replace_all set to true

    Correct

    replace_all replaces every occurrence, which is what this rename wants.

  • BA Write call with the whole file retyped from memory

    Incorrect

    Retyping the file risks changing other code by accident.

  • CA Grep call with the new name as the pattern

    Incorrect

    Grep searches; it does not change files.

  • DA Glob call that renames matching text

    Incorrect

    Glob only matches file paths.

Edit requires a unique match unless replace_all is set; use replace_all when every occurrence in the file should change.

Question 4 · choose 1

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?

  1. AThe symbol must be quoted differently in the pattern
  2. BGrep skips gitignored files; pass the file's path
  3. CGrep only searches files that have been read before
  4. 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.

Question 5 · choose 1

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?

  1. AGrep for the plain word interface and read every match to find the right ones
  2. BWrap the pattern in quotes so that Grep treats it as literal text
  3. CSet multiline to true so that the pattern can match across the braces
  4. 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.

Question 6 · choose 1

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?

  1. ASwitch to Grep with an empty pattern to list all files
  2. BRun the same pattern again to receive the next 100 paths
  3. CTreat the 100 paths as the complete list of TypeScript files
  4. 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.

Question 7 · choose 1

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?

  1. ABash is always preferred over built-in tools by design
  2. BThe repository is too large for Grep and Glob
  3. CGrep and Glob are off by default there unless named in the options
  4. 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.

Practise domain 2 →Practise all domains →