Tools · Files and code
edit_file
Changes thingsApply an exact string replacement patch to an existing file.
When to use: Use this for surgical edits after reading the file. Prefer exact replacements over full rewrites.
Example
Run for real by scripts/tool-examples.py in a small demo project, with Haiku 5.5 where the tool calls a model. The output is exactly what the tool returned.
The call
{
"tool": "edit_file",
"arguments": {
"path": "src/pricing.py",
"old_text": "\"team\": 29.0}",
"new_text": "\"team\": 29.0, \"enterprise\": 79.0}"
}
}Real output
File patched: <project>/src/pricing.py (1 occurrence replaced)
--- a/pricing.py
+++ b/pricing.py
@@ -1,5 +1,5 @@
"""Seat pricing for the demo app."""
-PLANS = {"starter": 12.0, "team": 29.0}
+PLANS = {"starter": 12.0, "team": 29.0, "enterprise": 79.0}Parameters
| Name | Type | Description |
|---|---|---|
| path* | string | Relative file path |
| old_text* | string | Exact existing text to replace |
| new_text* | string | Replacement text |
| replace_all | boolean | Replace all matches instead of exactly one |
* required
More in Files and code
Read, search and edit the project; run commands, code and git.