Skip to content

File Tools

Reads a file and returns its contents with line numbers.

{"tool": "Read", "input": {"file_path": "src/main.py"}}
{"tool": "Read", "input": {"file_path": "src/main.py", "offset": 100, "limit": 50}}
ParameterTypeDescription
file_pathstringAbsolute or relative path
offsetint?Line to start reading from (1-based)
limitint?Max lines to return

Output is formatted as cat -n style with line numbers.


Creates or overwrites a file. Requires a prior Read if the file already exists.

{"tool": "Write", "input": {"file_path": "output.txt", "content": "Hello, world!"}}

Replaces an exact string in a file. The old_string must come verbatim from a prior Read result — never constructed from memory.

{
"tool": "Edit",
"input": {
"file_path": "src/app.py",
"old_string": "def foo():\n pass",
"new_string": "def foo():\n return 42"
}
}

Edit uses diff-match-patch for fuzzy matching when exact string match fails. It also checks file mtime to detect if the file was modified externally since the last Read (staleness guard).


Applies multiple edits to a single file in one call. Edits are applied sequentially.

{
"tool": "MultiEdit",
"input": {
"file_path": "src/app.py",
"edits": [
{"old_string": "foo", "new_string": "bar"},
{"old_string": "baz", "new_string": "qux"}
]
}
}

Finds files matching a glob pattern, sorted by modification time.

{"tool": "Glob", "input": {"pattern": "src/**/*.tsx"}}
{"tool": "Glob", "input": {"pattern": "**/*.py", "path": "agent/"}}

Searches file contents with a regex pattern using ripgrep.

{"tool": "Grep", "input": {"pattern": "def handle_input", "path": "agent/"}}
{"tool": "Grep", "input": {"pattern": "TODO", "glob": "*.py", "output_mode": "files_with_matches"}}
ParameterTypeDescription
patternstringRegex pattern
pathstring?Directory to search
globstring?File filter (e.g. *.ts)
output_modestring?content / files_with_matches / count
-ibool?Case-insensitive

Lists files and directories at a path.

{"tool": "ListDir", "input": {"path": "src/components"}}

Moves or renames a file or directory.

{"tool": "Move", "input": {"source": "old_name.py", "destination": "new_name.py"}}

Deletes a file. Irreversible — use with care.

{"tool": "DeleteFile", "input": {"file_path": "temp/scratch.txt"}}