Read
Reads a file from the local filesystem. The file path must be an absolute path.Read supports text files, images (PNG, JPG, and other common formats), PDFs, and Jupyter notebooks (.ipynb). Images are returned visually. Notebooks return all cells with their outputs.
Inputs
Absolute path to the file to read.
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 read. Defaults to 2,000. Combine with
offset to page through large files.For PDF files only. Specifies which pages to read (for example,
"1-5" or "3"). Required for PDFs longer than 10 pages. Maximum 20 pages per request.Output
Returns file contents with line numbers incat -n format (lines prefixed with their line numbers). If the file has not changed since the last Read call in the conversation, Claude receives a stub indicating the content is unchanged rather than re-reading the full file.
Notes
- The tool reads files only — it cannot list directory contents. Use
Bashwithlsto list directories. - If the file does not exist, an error is returned (this is expected behavior).
- If the file is empty, a system reminder note is returned in place of content.
Example
Write
Creates or overwrites a file on the local filesystem.Inputs
Absolute path to the file to write. Intermediate directories are not created automatically — use
Bash with mkdir -p first if needed.The full content to write to the file.
Output
Returns a confirmation that the file was written, along with a diff showing what changed from the previous contents (if the file already existed).Notes
- If the file already exists, Claude must read it with
Readbefore callingWrite. The tool will fail if the file was not previously read in the conversation. - Use
Writewhen creating new files or performing a complete rewrite. For incremental changes, preferEdit.
Example
Edit
Performs an exact string replacement in an existing file. Only the changed portion is sent, making edits easier to review than full file rewrites.Inputs
Absolute path to the file to edit.
The exact text to replace. Must appear in the file and must be unique unless
replace_all is set to true. Include enough surrounding context (typically 2–4 lines) to uniquely identify the target location.The text to replace
old_string with. Must be different from old_string.When
true, replaces all occurrences of old_string in the file. Defaults to false. Use this when renaming a variable or making the same change in multiple places.Output
Returns the file path, the old and new strings, and a structured diff patch showing the changes.Notes
- Claude must read the file with
Readbefore callingEdit. The tool fails if no priorReadoccurred in the conversation. - The edit fails if
old_stringis not found in the file, or if it appears more than once andreplace_allisfalse. - Indentation must match exactly as it appears in the file — do not include line number prefixes from
Readoutput inold_stringornew_string.
Example
Glob
Finds files matching a glob pattern. Returns results sorted by modification time (most recently modified first).Inputs
The glob pattern to match files against. Supports standard glob syntax including
** for recursive matching.Directory to search in. Defaults to the current working directory. Must be a valid directory path if provided — do not pass
"undefined" or "null".Output
Array of file paths matching the pattern, relative to the search directory.
Total number of files found.
true if results were truncated to 100 files.Time taken to execute the search in milliseconds.
Notes
- Results are capped at 100 files. If results are truncated, narrow the pattern.
- For open-ended searches that may require multiple rounds of globbing and grepping, use the
Agenttool instead.
Example
Grep
Searches file contents using ripgrep with full regex support. Returns file paths with matches, matching lines, or match counts depending on the output mode.Inputs
The regular expression pattern to search for. Uses ripgrep regex syntax. Literal braces must be escaped (for example, use
interface\{\} to find interface{} in Go code).File or directory to search. Defaults to the current working directory.
Glob pattern to filter which files are searched (for example,
"*.ts" or "*.{ts,tsx}"). Maps to rg --glob.Controls what is returned. Options:
"files_with_matches"(default) — returns only the paths of files containing matches"content"— returns matching lines with optional context lines"count"— returns match counts per file
Lines of context before each match. Only applies when
output_mode is "content".Lines of context after each match. Only applies when
output_mode is "content".Lines of context before and after each match. Only applies when
output_mode is "content".When
true, allows patterns to match across multiple lines. Required for patterns like struct \{[\s\S]*?field. Defaults to false.Output
Depends onoutput_mode:
files_with_matches— list of file pathscontent— matching lines with file path, line number, and optional contextcount— number of matches per file
Notes
- Always use
Grepfor content searches instead of invokinggreporrgthroughBash. TheGreptool handles permissions and access correctly. - For open-ended searches requiring multiple rounds, use the
Agenttool.