edit.md

 1Edits files by replacing text, creating new files, or deleting content. For moving/renaming use Bash 'mv'. For large edits use Write tool.
 2
 3<prerequisites>
 41. Use View tool to understand file contents and context
 52. For new files: Use LS tool to verify parent directory exists
 6</prerequisites>
 7
 8<parameters>
 91. file_path: Absolute path to file (required)
102. old_string: Text to replace (must match exactly including whitespace/indentation)
113. new_string: Replacement text
124. replace_all: Replace all occurrences (default false)
13</parameters>
14
15<special_cases>
16
17- Create file: provide file_path + new_string, leave old_string empty
18- Delete content: provide file_path + old_string, leave new_string empty
19  </special_cases>
20
21<critical_requirements>
22UNIQUENESS (when replace_all=false): old_string MUST uniquely identify target instance
23
24- Include 3-5 lines context BEFORE and AFTER change point
25- Include exact whitespace, indentation, surrounding code
26
27SINGLE INSTANCE: Tool changes ONE instance when replace_all=false
28
29- For multiple instances: set replace_all=true OR make separate calls with unique context
30- Plan calls carefully to avoid conflicts
31
32VERIFICATION: Before using
33
34- Check how many instances of target text exist
35- Gather sufficient context for unique identification
36- Plan separate calls or use replace_all
37  </critical_requirements>
38
39<warnings>
40Tool fails if:
41- old_string matches multiple locations and replace_all=false
42- old_string doesn't match exactly (including whitespace)
43- Insufficient context causes wrong instance change
44</warnings>
45
46<best_practices>
47
48- Ensure edits result in correct, idiomatic code
49- Don't leave code in broken state
50- Use absolute file paths (starting with /)
51- Use forward slashes (/) for cross-platform compatibility
52- Multiple edits to same file: send all in single message with multiple tool calls
53  </best_practices>
54
55<windows_notes>
56
57- Forward slashes work throughout (C:/path/file)
58- File permissions handled automatically
59- Line endings converted automatically (\n ↔ \r\n)
60  </windows_notes>