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- Create file: provide file_path + new_string, leave old_string empty
17- Delete content: provide file_path + old_string, leave new_string empty
18</special_cases>
19
20<critical_requirements>
21UNIQUENESS (when replace_all=false): old_string MUST uniquely identify target instance
22
23- Include 3-5 lines context BEFORE and AFTER change point
24- Include exact whitespace, indentation, surrounding code
25
26SINGLE INSTANCE: Tool changes ONE instance when replace_all=false
27
28- For multiple instances: set replace_all=true OR make separate calls with unique context
29- Plan calls carefully to avoid conflicts
30
31VERIFICATION: Before using
32
33- Check how many instances of target text exist
34- Gather sufficient context for unique identification
35- Plan separate calls or use replace_all
36</critical_requirements>
37
38<warnings>
39Tool fails if:
40- old_string matches multiple locations and replace_all=false
41- old_string doesn't match exactly (including whitespace)
42- Insufficient context causes wrong instance change
43</warnings>
44
45<best_practices>
46- Ensure edits result in correct, idiomatic code
47- Don't leave code in broken state
48- Use absolute file paths (starting with /)
49- Use forward slashes (/) for cross-platform compatibility
50- Multiple edits to same file: send all in single message with multiple tool calls
51</best_practices>
52
53<windows_notes>
54- Forward slashes work throughout (C:/path/file)
55- File permissions handled automatically
56- Line endings converted automatically (\n ↔ \r\n)
57</windows_notes>