AcceptEdits or BypassPermissions mode.
Before Claude can edit or overwrite a file, it must have read that file in the same session. This read-before-write enforcement prevents clobbering concurrent changes.
Read
Read file contents. Returns text lines prefixed with line numbers, or a typed result for images, PDFs, and notebooks. Tool name:Read
Parameters
string
required
Absolute path to the file to read.
integer
1-based line number to start reading from. Omit to start at line 1.
integer
Maximum number of lines to return. The Rust implementation defaults to 2 000 lines.
string
PDF page range to extract (e.g.
"1-5", "3", "10-20"). PDF files only. Maximum 20 pages per call.Return value
The return type varies by file format:string
required
Discriminant:
"text", "image", "notebook", "pdf", "parts", or "file_unchanged".string
Line-numbered file content. Present when
type is "text".integer
Lines returned in this slice. Present when
type is "text".integer
First line number returned (1-based). Present when
type is "text".integer
Total lines in the file. Present when
type is "text".string
Base64-encoded binary data. Present when
type is "image" or "pdf".Notes
- Blocked device paths (
/dev/zero,/dev/random,/dev/urandom, etc.) are rejected to prevent infinite reads. - Binary files that are not images or PDFs return an error.
- Reading a file registers it in the session’s read-state cache, which enables
EditandWriteto operate on it.
Example
Write
Create a new file or completely overwrite an existing one. Tool name:WritePermission:
Write (prompts unless AcceptEdits or BypassPermissions mode)
Parameters
string
required
Absolute path to the file to create or overwrite.
string
required
Full content to write. The file is replaced atomically.
Return value
string
required
"create" for new files, "update" for overwrites.string
required
Absolute path that was written.
object
Diff of changes applied, useful for display.
string
Previous file content.
null for new files.Notes
- Parent directories are created automatically.
- For existing files, the file must have been read in this session first (read-before-write).
- If the file has been modified on disk since the last read, the write is rejected to avoid clobbering concurrent changes.
.ipynbfiles are automatically redirected toNotebookEdit.- Maximum file size: 1 GiB.
Example
Edit
Make an exact string replacement inside an existing file. PreferEdit over Write when you only need to change part of a file — it is faster and produces a cleaner diff.
Tool name: EditPermission:
Write (prompts unless AcceptEdits or BypassPermissions mode)
Parameters
string
required
Absolute path to the file to edit. The file must already exist.
string
required
The exact text to find and replace. Must be present in the file. Unless
replace_all is true, this string must appear exactly once — if it appears multiple times the call fails.string
required
The replacement text. Must differ from
old_string.boolean
default:"false"
When
true, replace every occurrence of old_string. When false (default), the call fails if old_string appears more than once.Return value
string
required
Path of the edited file.
object
required
Diff of the applied change.
boolean
required
Whether
replace_all was used.boolean
required
Whether you modified the proposed diff before it was applied.
Notes
- Read-before-write and mtime staleness checks apply (same as
Write). - The tool normalizes straight/curly quotes when matching
old_string, and preserves the original quote style in the output. .ipynbfiles are redirected toNotebookEdit.- A set of protected files (
.gitconfig,.bashrc,.zshrc,.mcp.json,.claude.json) resist automatic editing.
Example
Glob
Find files by name pattern. Results are sorted by modification time (most recent first). Tool name:Glob
Parameters
string
required
Glob pattern to match against file paths (e.g.
"**/*.rs", "src/**/*.ts", "*.toml").string
Directory to search in. Defaults to the current working directory.
Return value
string[]
required
Matching file paths, relative to the working directory.
integer
required
Number of files returned.
boolean
required
true if results were capped (the TypeScript implementation caps at 100; the Rust implementation at 250).number
required
Time taken to complete the search.
Example
Grep
Search file contents using a regular expression. Backed byripgrep in the TypeScript implementation and a Rust walkdir+regex traversal in the Claurst Rust codebase.
Tool name: Grep
Parameters
string
required
Regular expression to search for (e.g.
"fn\\s+\\w+", "TODO|FIXME").string
File or directory to search. Defaults to the current working directory.
string
Restrict search to files matching this glob (e.g.
"*.rs", "**/*.tsx").string
default:"files_with_matches"
Controls output format:
"files_with_matches"— list of matching file paths (default)"content"— matching lines with optional context"count"— match count per file
boolean
Case-insensitive matching.
boolean
Show line numbers in
content mode.integer
Lines of context after each match (
output_mode: "content" only).integer
Lines of context before each match (
output_mode: "content" only).integer
Lines of context before and after each match. Equivalent to setting both
-A and -B.integer
Alias for
-C.string
File type shortcut (e.g.
"rs", "ts", "py", "js", "go"). Expands to the relevant file extensions.integer
default:"250"
Limit output to the first N lines or entries.
integer
default:"0"
Skip the first N entries (for pagination).
boolean
default:"false"
Enable multiline matching (
. matches newlines).Return value
string
required
The
output_mode that was used.integer
required
Number of files that matched.
string[]
required
Matching file paths.
string
Matching lines. Present when
mode is "content".integer
Total match count. Present when
mode is "count".Notes
- VCS directories (
.git,.svn,.hg,.jj) and build directories (node_modules/,target/,__pycache__/) are excluded automatically. - The TypeScript implementation caps individual lines at 500 characters.
Example
NotebookEdit
Edit a cell in a Jupyter.ipynb notebook. Supports inserting, replacing, and deleting cells.
Tool name: NotebookEditPermission:
Write
Parameters
string
required
Absolute path to the
.ipynb file.string
required
New source content for the cell (for
replace and insert modes).string
default:"replace"
Operation to perform:
"replace", "insert", or "delete".string
Target cell ID. Required for
replace and delete. Omit when inserting a new cell.string
Cell type for new cells:
"code" or "markdown". Used with insert mode.Return value
string
required
Path of the modified notebook.
string
Cell ID that was affected.
string
required
The operation that was applied.
string
required
Full notebook JSON before the edit.
string
required
Full notebook JSON after the edit.
Notes
- Read-before-write and mtime staleness checks apply.
- On
replace,execution_countandoutputsare cleared to avoid stale output display. - In the Rust implementation, cells can also be targeted by a
cell-Nindex pattern (e.g."cell-0"for the first cell).