Domain 3 · Claude Code Configuration

Grep vs Glob & the built-in tools

Claude Code ships with a small toolbox — Read, Write, Edit, Bash, Grep, Glob — and the exam loves the Grep-vs-Glob distinction because it's the one everyone fumbles. One searches file contents; the other searches file names. Pick the wrong one and the agent wastes turns and tokens hunting in the dark.

Grep = inside filesGlob = file names Read / Write / EditBash tool selection
Explain like I'm 10
Imagine a giant library. Glob is finding books by their title pattern — "give me every book whose name ends in -ology." Grep is finding books by a word printed inside them — "give me every book that mentions dinosaurs on any page." Same library, totally different searches. Ask for a title when you mean a word inside, and you'll grab all the wrong books.

Run both searches on the same repo

Below is a tiny codebase. Type a query and run it as a Glob (matches the file path) and as a Grep (matches text inside files). Watch how the same string finds completely different things:

Glob — match file names/paths
Grep — match contents

Try: auth, *.test.js, password, TODO

The whole toolbox, and when to reach for each

ToolUse it to…Don't use it to…
Globfind files by name/path pattern (**/*.test.ts).search what's in the files.
Grepsearch file contents for a string/regex (functio​n login).find files whose name matches — that's slower & noisier.
Readopen a specific file you already located."explore" — locate first with Glob/Grep, then Read precisely.
Editchange exact text in a file you've Read.create brand-new files (use Write).
Writecreate a new file or fully replace one.make a small change (use Edit — Write overwrites).
Bashrun commands, tests, git, builds.search/read files — the dedicated tools are faster & safer than cat/find.
Exam trap: "search the codebase for where login() is defined" → that's Grep (content), not Glob. "Find all the test files" → that's Glob (names). And using Bash with grep/find/cat when the dedicated tools exist is the wrong answer — the built-ins are faster, safer, and don't dump huge output into the context window.
Takeaways: Glob = match file names/paths; Grep = match text inside files. Locate with Glob/Grep, then Read the specific file; Edit to change existing text, Write to create/replace, Bash for commands. Don't reimplement Grep/Glob/Read with Bash find/grep/cat — the dedicated tools keep context lean.

Curated companion: Claude Code docs — built-in tools.