Tool Design & MCP Integration/MCP & Built-in Tools
Beginner10 min

Built-in Tools: Read, Write, Edit, Bash, Grep, Glob

Understanding Claude Code's six built-in tools and when to use each one. Grep for content search, Glob for file path matching, Read/Write for full file operations, Edit for targeted modifications, and Bash for shell commands. Includes the incremental codebase exploration pattern: Grep entry points, Read imports, trace flows.

Quick Reference

  • Grep: Search file CONTENTS for patterns (regex). Use to find function callers, string references, imports
  • Glob: Search file PATHS by pattern. Use to find files by name/extension (e.g., **/*.test.tsx)
  • Read: Read full file contents. Use after Grep/Glob to inspect specific files you identified
  • Write: Write entire file contents (overwrites). Use for new files or complete file rewrites
  • Edit: Targeted string replacement within a file. Use for precise changes without rewriting the whole file
  • Bash: Run shell commands. Use for git, npm, builds, tests -- anything the other 5 tools don't cover
  • When Edit fails on non-unique match, fall back to Read + Write (read the file, modify content, write back)
  • Incremental exploration: Grep to find entry points -> Read to inspect -> trace imports/calls -> repeat
  • Start with Grep, not Read -- searching first prevents reading irrelevant files
  • Use Glob when you need file paths, Grep when you need file contents

The Six Built-in Tools at a Glance

Claude Code ships with six built-in tools that handle all file system operations, code exploration, and shell interactions. Every task Claude performs in a codebase uses these tools. Understanding when to use each one -- and when NOT to -- is the difference between efficient exploration and wasted context window.

ToolPurposeWhen to useExample
GrepSearch file contents by regex patternFinding function callers, string references, error messages, importsGrep for 'handleSubmit' to find all components that call it
GlobFind files by path/name patternFinding files by extension, name pattern, or directory structureGlob '**/*.test.tsx' to find all React test files
ReadRead file contents (with line numbers)Inspecting a specific file you already identified via Grep/GlobRead src/api/handler.ts to see the full implementation
WriteWrite/overwrite entire fileCreating new files or complete rewritesWrite a new config file or completely rewrite a module
EditTargeted string replacementChanging specific lines without rewriting the whole fileReplace a function call, update an import, fix a typo
BashRun shell commandsGit, npm, builds, tests, any CLI operationRun npm test, git status, or curl an API
Why these six?

These tools cover all interactions with a codebase: finding files (Glob), searching contents (Grep), reading (Read), writing (Write), precisely editing (Edit), and running commands (Bash). Together they form a complete toolkit for code exploration, modification, and validation.