[BUG] Edit Tool Calls Periodically Fail on Windows Due to Path Issues
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
I've been noticing for weeks that, often times, Claude will fail to edit a file (on Windows in the Claude Code VSCode extension). It doesn't happen always, but when it does happen, it usually happens for the rest of the chat session. Claude will try several different things and eventually resort to using sed and awk commands to edit the file or even create complex python, powershell, or nodejs scripts to write to the file which ends up taking a lot longer and eating up a bunch of tokens.
After digging around the internet and troubleshooting it quite a bit, I _think_ I finally found the root cause. Best I can tell, it was using the wrong path style for its tool calls to the Edit tool and other tools. I think it was using Linux-style file paths (with / separator) instead of Windows style file paths (with \ separator). I was able to fix it and get the behavior to stop by adding the following prompt snippet to my CLAUDE.md:
## Claude Code Tool Path Conventions (CRITICAL)
Most users of this repository are on **Windows with Git Bash**. There are **two different path conventions** you must use depending on context:
### Tool Calls (Read, Edit, Write, Glob, Grep, etc.)
When calling Claude Code tools that accept file paths, you MUST use **Windows-style paths**:
- ✅ Use backslashes: `c:\Projects\REDACTED\app\src\main.ts`
- ✅ Use the full absolute path with drive letter
- ❌ Do NOT use forward slashes: `c:/Projects/REDACTED/app/src/main.ts`
- ❌ Do NOT use Unix-style paths: `/c/Projects/REDACTED/app/src/main.ts`
### Bash Commands
When running commands via the Bash tool, you MUST use **Unix-style paths** (Git Bash convention):
- ✅ Use forward slashes: `/c/Projects/REDACTED/app/src/main.ts`
- ❌ Do NOT use backslashes in bash commands
### Detecting the Environment
Check the environment context provided at the start of the session:
- Look for `Platform:` (e.g., `win32`) and `Working directory:` (e.g., `c:\Projects\...`)
- Windows paths in the working directory indicate Windows environment
### If File Edits Are Failing Repeatedly
1. Check the error message - path-related errors often indicate wrong path syntax
2. Verify you're using **Windows-style paths** (`\`) for tool calls
3. Ensure you're using absolute paths, not relative paths
4. Do NOT fall back to `sed`, `awk`, or other bash text manipulation tools to edit files - fix the path issue instead
What Should Happen?
The prompt I pasted above works around the issue for now, but I that something like this either should probably be baked directly into Claude's system prompt or the tools should be a bit more forgiving about the paths they get passed and do the proper conversion to the underlying operating system even if Claude uses the wrong path syntax. If this issue is fixed, it should also NOT interfere with Claude's ability to run bash commands on Windows using Git For Windows Bash.
Error Messages/Logs
No error messages other than "Edit Failed" in the Claude Code VSCode extension.
Steps to Reproduce
Note: Not consistently reproducible. Not sure what gets Claude into this state, but I've seen this happen more after auto-compact.
- Begin a chat session on Windows in the Claude Code VSCode extension
- Create a plan that requires editing many files
- Approve the plan and let Claude start working on the file edits
Expected:
- Claude is able to edit any files that it has permissions to edit using the Edit Tool
- Claude is able to read any files that it has permissions to read using the Read Tool
- Claude is able to create new files using the Create Tool
Actual:
- In some circumstances, Claude loses its ability to edit files using its built-in tools
- When this happens, the Edit tool fails and Claude eventually falls back to using bash commands like
sedandawkor scripts - When that happens, token usage starts to churn
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.3
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗