Built-in Claude Code Tools

Core

Select and apply built-in tools (Read, Write, Edit, Bash, Grep, Glob) effectively · Difficulty 2/5

0%
builtin-toolsgrepglobreadwriteeditbash

Claude Code provides built-in tools for file operations and codebase exploration. Selecting the right tool for each task is essential for efficiency.

Tool Selection Guide

TaskToolExample

|------|------|---------|

Search file contents**Grep**Find all callers of `processPayment`, locate error messages
Find files by name/patternGlobFind **/*.test.tsx, locate config files
Read entire fileReadLoad a file to understand its structure
Create new fileWriteCreate a new component or config file
Targeted editEditChange a specific function using unique text matching
Run commandsBashInstall dependencies, run tests, git operations

Edit vs Read + Write

  • Edit: Uses unique text matching to make targeted modifications. Fast and precise when the anchor text is unique in the file.
  • Read + Write fallback: When Edit fails because the anchor text appears multiple times, use Read to load the full file, then Write to replace it with modifications. This is more reliable but replaces the entire file.
  • Incremental Codebase Understanding

    Don't read all files upfront. Build understanding incrementally:

  • Grep to find entry points (function definitions, error messages, import patterns)
  • Read to follow imports and trace flows from those entry points
  • Grep again to find related code based on what you learned
  • Tracing Function Usage Across Wrappers

    When functions are re-exported through wrapper modules:

  • Identify all exported names from the wrapper module
  • Search for each exported name across the codebase
  • This captures both direct imports and re-exported usage
  • Key Takeaways

    • Grep searches file contents; Glob finds files by name pattern -- don't confuse them
    • Use Edit for targeted changes with unique anchor text; fall back to Read + Write when anchor text is not unique
    • Build codebase understanding incrementally with Grep then Read, not by reading everything upfront
    • Trace function usage across wrappers by first finding exported names, then searching for each