Complete Windows file path troubleshooting knowledge for Claude Code on Git Bash and Windows environments...
MANDATORY: Always Use Backslashes on Windows for File Paths
When using Edit or Write tools on Windows, you MUST use backslashes (\) in file paths, NOT forward slashes (/).
Examples:
D:/repos/project/file.tsxD:\repos\project\file.tsxThis applies to:
NEVER create new documentation files unless explicitly requested by the user.
MANDATORY: When using Edit, Write, or Read tools on Windows, you MUST use backslashes (\) in file paths, NOT forward slashes (/).
Windows File Path Requirements:
D:\repos\project\file.tsxD:/repos/project/file.tsxThis applies to:
file_path parameterfile_path parameterfile_path parameterCommon error message when using forward slashes on Windows:
Error: ENOENT: no such file or directory
Root cause:
\) as path separators/) work in some Windows contexts but NOT in Claude Code file toolsSymptom:
Edit tool fails with "file not found" or "no such file or directory"
Cause: Using forward slashes copied from Git Bash output:
# Git Bash shows:
/s/repos/claude-plugin-marketplace/file.tsx
Incorrect usage:
Edit(file_path="/s/repos/myproject/file.tsx")
Correct usage:
Edit(file_path="S:\repos\myproject\file.tsx")
Solution steps:
/s/ → S:)Symptom:
Paths like /s/repos/ or /c/Users/ don't work in Edit/Write/Read tools
MINGW path format explained:
/c/, /d/, /s/, etc.Conversion table:
| Git Bash (MINGW) | Windows Native |
|---|---|
/c/Users/name/ |
C:\Users\name\ |
/d/repos/project/ |
D:\repos\project\ |
/s/work/code/ |
S:\work\code\ |
/mnt/c/Windows/ |
C:\Windows\ |
Conversion algorithm:
/s/ → S)S → S:)S: + \repos\project\file.tsxSymptom: Relative paths from Git Bash don't resolve correctly in Claude Code tools
Cause: Git Bash current working directory uses MINGW format, but Claude Code tools use Windows format
Example scenario:
# In Git Bash:
pwd
# Shows: /s/repos/my-project
# User provides relative path:
./src/components/Button.tsx
Problem:
Claude Code can't resolve ./src/ from MINGW /s/repos/my-project
Solution:
pwd -W
# Shows: S:/repos/my-project (Windows format with forward slashes)
S:\repos\my-projectS:\repos\my-project\src\components\Button.tsxSymptom:
Paths with environment variables like $HOME or %USERPROFILE% fail
Git Bash environment variables:
echo $HOME
# Shows: /c/Users/username (MINGW format)
Windows environment variables:
echo %USERPROFILE%
# Shows: C:\Users\username (Windows format)
Best practice:
$HOME, ask them to run echo $HOME and convert the resultSymptom: Paths with spaces break or cause "file not found" errors
Correct handling:
✅ CORRECT: Edit(file_path="C:\Program Files\My App\config.json")
✅ CORRECT: Edit(file_path="D:\My Documents\project\file.txt")
Notes:
Symptom:
Network paths like \\server\share\file.txt fail
Windows UNC format:
\\server\share\folder\file.txt
Git Bash representation:
//server/share/folder/file.txt
Correct usage in Claude Code:
Edit(file_path="\\\\server\\share\\folder\\file.txt")
Note: Backslashes must be doubled in some contexts due to escaping, but Claude Code tools handle this automatically.
When a user provides a file path, follow this decision tree:
MINGW Path (Git Bash):
/ followed by single letter and / (e.g., /c/, /s/)/s/repos/project/file.tsxWindows Path:
C:, D:)S:\repos\project\file.tsx or S:/repos/project/file.tsxRelative Path:
./ or ../ or just filename./src/components/Button.tsxUNC Path:
\\ or //\\server\share\file.txtFor MINGW paths (/x/...):
Input: /s/repos/myproject/src/components/Button.tsx
Process:
1. Extract drive letter: "s"
2. Uppercase: "S"
3. Add colon: "S:"
4. Replace remaining slashes: \repos\myproject\src\components\Button.tsx
5. Combine: S:\repos\myproject\src\components\Button.tsx
Output: S:\repos\myproject\src\components\Button.tsx
For Windows paths with forward slashes (X:/...):
Input: S:/repos/project/file.tsx
Process:
1. Detect drive letter already present: "S:"
2. Replace forward slashes with backslashes: \repos\project\file.tsx
3. Combine: S:\repos\project\file.tsx
Output: S:\repos\project\file.tsx
For relative paths:
Input: ./src/components/Button.tsx
Current directory (from user or detection): S:\repos\my-project
Process:
1. Remove ./ prefix
2. Replace forward slashes: src\components\Button.tsx
3. Combine with current directory: S:\repos\my-project\src\components\Button.tsx
Output: S:\repos\my-project\src\components\Button.tsx
When you encounter a file path error on Windows:
Error indicators:
Ask yourself:
If the path is ambiguous, ask:
I see you're working on Windows with Git Bash. To ensure I use the correct path format,
could you run this command and share the output?
pwd -W
This will give me the Windows-formatted path.
Conversion template:
I'll convert the path from Git Bash format to Windows format:
- Git Bash: /s/repos/project/file.tsx
- Windows: S:\repos\project\file.tsx
Retrying with the correct Windows path...
After conversion, verify the operation succeeded and explain what was fixed:
✅ Successfully edited the file using the Windows path format (S:\repos\...).
Note: On Windows with Git Bash, always use backslashes (\) in file paths for
Claude Code's Edit/Write/Read tools, even though Git Bash displays paths with
forward slashes (/).
When file operations fail on Windows:
\) used instead of forward slashes (/)?C: not /c/?/x/path to X:\path?$HOME or %USERPROFILE%?\\server\share format?| Context | Path Format | Claude Code Tool Format |
|---|---|---|
| Git Bash pwd | /s/repos/project |
S:\repos\project |
| Git Bash relative | ./src/file.tsx |
S:\repos\project\src\file.tsx |
| Windows Explorer | S:\repos\project\file.tsx |
S:\repos\project\file.tsx ✅ |
Windows with / |
S:/repos/project/file.tsx |
S:\repos\project\file.tsx |
| MINGW full path | /c/Users/name/file.txt |
C:\Users\name\file.txt |
| Network share (Git Bash) | //server/share/file.txt |
\\server\share\file.txt |
| WSL path | /mnt/c/repos/project |
C:\repos\project |
Don't wait for errors - If you see a path that looks like MINGW format, convert it immediately:
User provides: /s/repos/project/file.tsx
You think: "This is MINGW format, I need to convert it to S:\repos\project\file.tsx"
You do: Convert before calling Edit/Write/Read tool
When you need current directory on Windows:
# Instead of:
pwd # Shows: /s/repos/project (MINGW format)
# Use:
pwd -W # Shows: S:/repos/project (Windows format with /)
Then convert the forward slashes to backslashes.
Always explain when you convert paths:
I'll convert the Git Bash path to Windows format for the Edit tool:
- From: /s/repos/project/file.tsx
- To: S:\repos\project\file.tsx
This helps users understand the requirement and learn for future interactions.
Before calling Edit/Write/Read tools on Windows:
Pre-flight checklist:
✅ Path starts with drive letter and colon (e.g., C:, S:)
✅ Path uses backslashes (\) not forward slashes (/)
✅ Path is absolute, not relative
✅ No MINGW format (no /c/, /s/, etc.)
User might provide paths in various formats:
Always detect and convert as needed.
Detailed lookup tables for common Claude Code Windows path errors, platform-specific behavior (PowerShell, CMD, Git Bash, WSL, Node/Python), user-teaching scripts, and advanced path scenarios (UNC paths, long paths, spaces, special characters) live in references/error-platform-advanced.md. Load that reference when the quick conversion workflow does not explain a path failure.
You've successfully handled Windows paths when:
PROACTIVELY apply this knowledge when:
/c/, /s/, etc.This skill is CRITICAL for Windows users - Path format errors are the #1 cause of file operation failures on Windows with Git Bash.
