Claude Certified Architect

Foundations · CCAR-F

Domain 2 — 18%

Task 2.5

Built-in Tools

Read, Write, Edit, Bash, Grep, and Glob — when to use each

📘What You Need to Know

The Six Built-in Tools

Claude Code and agent environments provide six purpose-built tools for common file and shell operations. Each has a specific role, and using Bash equivalents when a dedicated tool exists is an explicit anti-pattern tested on the exam.

The correct exam answer always uses the purpose-built tool instead of a Bash equivalent. Knowing the distinctions between Read, Write, Edit, Bash, Grep, and Glob is high-yield study material for Domain 2.

  • •Read: read file contents for understanding code, examining data, or reviewing configuration.
  • •Write: create NEW files from scratch only — replaces the entire file contents.
  • •Edit: modify EXISTING files with targeted search-and-replace changes.
  • •Bash: execute shell commands for builds, tests, installs, and system operations.
  • •Grep: search for text PATTERNS inside file contents across the codebase.
  • •Glob: find files matching NAME or path patterns (e.g., **/*.ts).

Read, Write, and Edit Distinctions

Read is for examining existing file contents. Use it whenever you need to understand what a file contains before making changes.

Write creates new files only. It replaces the entire file — using Write on an existing file overwrites everything, which is destructive and error-prone for modifications. If the file already exists, use Edit instead.

Edit performs targeted modifications to existing files via search-and-replace. It changes only the specified sections, preserving the rest of the file. This is the safe choice for bug fixes, refactors, and incremental updates.

🔑Key Concept

Write = new files only. Edit = modify existing files. Using Write to update an existing file is an anti-pattern that risks overwriting unrelated content.

Grep vs Glob

These two tools are frequently confused because both involve "searching," but they search different things.

Grep searches inside files for text content patterns. Use Grep when you need to find where a function is defined, locate a string literal, or search for regex patterns across file contents. Example: find all files containing "useState".

Glob finds files by name or path patterns without reading their contents. Use Glob when you need to list files matching a pattern. Example: find all TypeScript files with pattern **/*.ts.

💡Tip

Grep = search INSIDE files for content. Glob = search FOR files by name. "Find all .ts files" → Glob. "Find where authenticate() is called" → Grep.

Bash Anti-Patterns

Bash is for operations that genuinely require shell execution: running tests, building projects, installing packages, and git operations. It is not a substitute for purpose-built file tools.

Common anti-patterns the exam tests: using cat or head to read files (use Read), using echo or sed to create files (use Write), using sed -i to modify files (use Edit), using find to locate files (use Glob), and using grep in Bash when the Grep tool exists.

Bash equivalents are slower, less safe, and bypass the structured interfaces that built-in tools provide. The exam consistently penalizes Bash workarounds.

// ANTI-PATTERN → CORRECT TOOL

Bash: cat src/utils.ts          → Read: src/utils.ts
Bash: echo "code" > new.ts       → Write: new.ts (new file only)
Bash: sed -i 's/old/new/' f.ts   → Edit: targeted replacement in f.ts
Bash: find . -name "*.ts"        → Glob: pattern **/*.ts
Bash: grep -r "useState" .       → Grep: pattern "useState"
Bash: npm test                   → Bash: npm test (correct — shell execution)

Choosing the Right Tool: Decision Guide

Need to see what is in a file? → Read. Need to create a new file? → Write. Need to change part of an existing file? → Edit. Need to run a build, test, or install command? → Bash. Need to find text inside files? → Grep. Need to find files by name? → Glob.

When multiple tools seem applicable, prefer the most specific one. Read is more appropriate than Bash+cat for file contents. Edit is safer than Write for existing files. The built-in tools exist because they are faster, safer, and produce structured results the agent can reason about.

⚠️Watch out

If a purpose-built tool exists for the operation, using a Bash equivalent is always wrong on the exam — even if the Bash command would technically work.

⚠️Exam Traps

Trap: Using Bash with cat or head to read file contents

Why it's wrong: Read is the purpose-built tool for file contents — Bash equivalents are explicit anti-patterns.

Correct approach: Use Read for file contents; reserve Bash for shell execution (tests, builds, installs).

Trap: Using Write to modify an existing file

Why it's wrong: Write replaces the entire file — it is for creating new files only and risks destroying existing content.

Correct approach: Use Edit for targeted changes to existing files; Write only for new file creation.

Trap: Using Grep to find files by extension or name pattern

Why it's wrong: Grep searches inside file contents for text patterns, not file names.

Correct approach: Use Glob for file name/path patterns (e.g., **/*.ts); use Grep for content search.

Trap: Using Bash find or ls to locate files instead of Glob

Why it's wrong: Glob is the purpose-built tool for file discovery by name pattern.

Correct approach: Use Glob with patterns like **/*.test.ts; use Bash only for shell commands that require execution.

✓Concept Check

You need to find all TypeScript files in a project. Which tool should you use?

🔨Build Exercise

Beginner20 minutes

Choose the Right Built-in Tool

What you'll learn

  • •Match common tasks to the correct built-in tool
  • •Identify and replace Bash anti-patterns with purpose-built tools
  • •Apply Read/Write/Edit and Grep/Glob distinctions in practice