Read for reading content, Edit for precise in-place edits, and Write for creating or fully rewriting files.
Read
Reads a file from the local filesystem and returns its contents with line numbers.Parameters
Absolute path to the file. Relative paths are not accepted.
Line number to start reading from (1-indexed). Use this with
limit to read a specific section of a large file.Maximum number of lines to return. Defaults to 2,000 lines. For files longer than this, call
Read again with a higher offset to page through the content.Output format
Results usecat -n style formatting: each line is prefixed with its 1-indexed line number.
Edit calls.
Supported file types
| Type | Behavior |
|---|---|
| Text files | Returns raw text with line numbers |
| Images (PNG, JPG, etc.) | Displayed visually — Claude is multimodal |
| PDF files | Returned as document content. For PDFs over 10 pages, use the pages parameter (e.g., "1-5"). Maximum 20 pages per request. |
Jupyter notebooks (.ipynb) | All cells and outputs are returned, combining code, text, and visualizations |
Read cannot list directories. To inspect a directory’s contents, use ls via the Bash tool.Caching
If a file has not changed since the lastRead call in the same conversation, Claude receives a cached stub instead of re-reading the file. This avoids redundant reads on unchanged files.
Edit
Performs exact string replacement within a file.Parameters
Absolute path to the file to modify.
The exact string to find and replace. Must match the file content character-for-character, including whitespace and indentation.
The replacement string. Use an empty string to delete
old_string.When
true, replaces every occurrence of old_string in the file instead of only the first. Useful for renaming variables or symbols that appear multiple times.How Edit works
Edit finds the literal text in old_string inside the file and substitutes it with new_string. No regex interpretation occurs — the match is a plain string comparison.
Pre-read requirement
Claude must callRead on a file at least once in the conversation before calling Edit on it. The tool enforces this to prevent edits based on stale or assumed content.
Indentation matching
When Claude derivesold_string from Read output, it uses the content that appears after the line-number prefix. For example, given:
old_string is const x = 1 (six leading spaces), not 12 const x = 1.
Write
Creates a new file or fully overwrites an existing one.Parameters
Absolute path to the file to create or overwrite.
The complete content to write to the file. If the file already exists, it is replaced entirely.
When to use Write vs Edit
- Use Edit
- Use Write
- Modifying one or more sections of an existing file
- Renaming a variable or symbol across the file
- Adding or removing a block of code
Pre-read requirement
When overwriting an existing file, Claude must callRead first. Write enforces this to prevent unintentional data loss.