1Edits files by replacing text, creating new files, or deleting content. For moving or renaming files, use the Bash tool with the 'mv' command instead. For larger file edits, use the FileWrite tool to overwrite files.
 2
 3Before using this tool:
 4
 51. Use the FileRead tool to understand the file's contents and context
 6
 72. Verify the directory path is correct (only applicable when creating new files):
 8   - Use the LS tool to verify the parent directory exists and is the correct location
 9
10To make a file edit, provide the following:
11
121. file_path: The absolute path to the file to modify (must be absolute, not relative)
132. old_string: The text to replace (must be unique within the file, and must match the file contents exactly, including all whitespace and indentation)
143. new_string: The edited text to replace the old_string
154. replace_all: Replace all occurrences of old_string (default false)
16
17Special cases:
18
19- To create a new file: provide file_path and new_string, leave old_string empty
20- To delete content: provide file_path and old_string, leave new_string empty
21
22The tool will replace ONE occurrence of old_string with new_string in the specified file by default. Set replace_all to true to replace all occurrences.
23
24CRITICAL REQUIREMENTS FOR USING THIS TOOL:
25
261. UNIQUENESS: When replace_all is false (default), the old_string MUST uniquely identify the specific instance you want to change. This means:
27   - Include AT LEAST 3-5 lines of context BEFORE the change point
28   - Include AT LEAST 3-5 lines of context AFTER the change point
29   - Include all whitespace, indentation, and surrounding code exactly as it appears in the file
30
312. SINGLE INSTANCE: When replace_all is false, this tool can only change ONE instance at a time. If you need to change multiple instances:
32   - Set replace_all to true to replace all occurrences at once
33   - Or make separate calls to this tool for each instance
34   - Each call must uniquely identify its specific instance using extensive context
35
363. VERIFICATION: Before using this tool:
37   - Check how many instances of the target text exist in the file
38   - If multiple instances exist and replace_all is false, gather enough context to uniquely identify each one
39   - Plan separate tool calls for each instance or use replace_all
40
41WARNING: If you do not follow these requirements:
42
43- The tool will fail if old_string matches multiple locations and replace_all is false
44- The tool will fail if old_string doesn't match exactly (including whitespace)
45- You may change the wrong instance if you don't include enough context
46
47When making edits:
48
49- Ensure the edit results in idiomatic, correct code
50- Do not leave the code in a broken state
51- Always use absolute file paths (starting with /)
52
53WINDOWS NOTES:
54
55- File paths should use forward slashes (/) for cross-platform compatibility
56- On Windows, absolute paths start with drive letters (C:/) but forward slashes work throughout
57- File permissions are handled automatically by the Go runtime
58- Always assumes \n for line endings. The tool will handle \r\n conversion automatically if needed.
59
60Remember: when making multiple file edits in a row to the same file, you should prefer to send all edits in a single message with multiple calls to this tool, rather than multiple messages with a single call each.