|
1 | | -@AGENTS.md |
2 | | - |
3 | | -## CRITICAL: File Editing on Windows |
4 | | - |
5 | | -### ⚠️ MANDATORY: Always Use Backslashes on Windows for File Paths |
6 | | - |
7 | | -When using Edit or MultiEdit tools on Windows, you MUST use backslashes (`\`) in file paths, NOT forward slashes (`/`). |
8 | | - |
9 | | -❌ WRONG - Will cause errors: |
10 | | -``` |
11 | | -Edit(file_path: "D:/repos/project/file.tsx", ...) |
12 | | -MultiEdit(file_path: "D:/repos/project/file.tsx", ...) |
13 | | -``` |
14 | | - |
15 | | -✅ CORRECT - Always works: |
16 | | -``` |
17 | | -Edit(file_path: "D:\repos\project\file.tsx", ...) |
18 | | -MultiEdit(file_path: "D:\repos\project\file.tsx", ...) |
19 | | -``` |
20 | | - |
21 | | -### ⚠️ "File has been unexpectedly modified" Error |
22 | | - |
23 | | -If you get this error: **"File has been unexpectedly modified. Read it again before attempting to write it"** |
24 | | - |
25 | | -**Root cause:** The file was modified after you last read it (by linter, formatter, git, or external process). |
26 | | - |
27 | | -**Solution: Re-read the file immediately before editing:** |
28 | | - |
29 | | -```bash |
30 | | -# 1. Read the file again |
31 | | -Read(file_path: "path\to\file.txt") |
32 | | - |
33 | | -# 2. Then immediately edit |
34 | | -Edit(file_path: "path\to\file.txt", old_string="...", new_string="...") |
35 | | -``` |
36 | | - |
37 | | -**Tool requirements:** |
38 | | - |
39 | | -| Tool | Rule | |
40 | | -|------|------| |
41 | | -| **Edit** | Must `Read` immediately before - `old_string` must match current content | |
42 | | -| **Write** | Must `Read` once per conversation before first write | |
43 | | - |
44 | | -**Common triggers:** |
45 | | -- Linters/formatters running on save |
46 | | -- Git operations (checkout, merge, rebase) |
47 | | -- File watchers or build processes |
48 | | - |
49 | | -**Tip:** If this happens repeatedly, consider disabling auto-formatting for files you're actively editing with Claude Code. |
50 | | - |
| 1 | +@AGENTS.md |
0 commit comments