2 genuinely different descriptions of this tool
Plain text · sha256 2eaaa8e08e0b
The description, line by line
5 lines Line numbers are v2.1.269 on the left and this capture on the right.
1
Performs exact string replacements in files.
1
Performs exact string replacement in a file.
2
2
3
Usage:
4
- You must use your `Read` tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file.
5
- When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: line number + tab. Everything after that is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.
6
- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
7
- Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.
8
- The edit will FAIL if `old_string` is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use `replace_all` to change every instance of `old_string`.
9
- Use `replace_all` for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.
3
- You must Read the file in this conversation before editing, or the call will fail.
4
- `old_string` must match the file exactly, including indentation, and be unique — the edit fails otherwise. Strip the Read line prefix (line number + tab) before matching.
5
- `replace_all: true` replaces every occurrence instead.
What it accepts
4 parameters The JSON parameter schema sent beside this description, 654 characters of it. Name, type, then whether the client marked it required.file_path
string
required
The absolute path to the file to modify
new_string
string
required
The text to replace it with (must be different from old_string)
old_string
string
required
The text to replace
replace_all
boolean
optional
Replace all occurrences of old_string (default false)
sha256 9748c75edc64 · the schema as the client sent it:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"file_path": {
"description": "The absolute path to the file to modify",
"type": "string"
},
"new_string": {
"description": "The text to replace it with (must be different from old_string)",
"type": "string"
},
"old_string": {
"description": "The text to replace",
"type": "string"
},
"replace_all": {
"default": false,
"description": "Replace all occurrences of old_string (default false)",
"type": "boolean"
}
},
"required": [
"file_path",
"old_string",
"new_string"
],
"type": "object"
}