[BUG] Windows: Repeated command syntax errors wasting API credits
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?
Feedback for Claude Code Developers:
- Bash command confusion on Windows: I repeatedly tried Linux/PowerShell commands incorrectly (Copy-Item in bash,
syntax errors with redirects). The platform detection says win32 but I kept mixing command syntaxes.
- Unnecessary polling loops: I made repeated API calls to monitor a scan when I should have just waited for user
confirmation. Wasteful of user credits.
- Python script execution issues: User reports "screen full of red errors" when I write Python code to run.
Something is consistently breaking.
- Credit cost awareness: Each failed tool call costs the user money. I should be more careful and test commands
mentally before executing.
What Should Happen?
When Claude Code is running on a Windows platform (win32), it should:
- Use correct Windows/PowerShell syntax consistently - Not mix Linux bash commands with PowerShell cmdlets
- Recognize Copy-Item, Get-ChildItem are PowerShell - Not try to run them in bash directly
- Handle redirects correctly - 2>$null vs 2>/dev/null based on platform
- Minimize failed tool calls - Each failed call costs user API credits
- Not repeatedly poll/retry - When waiting for user input, just wait instead of making repeated calls
Actual Behavior:
- Tried Copy-Item in bash (Linux command not found)
- Tried copy in bash (Linux command not found)
- PowerShell redirect syntax errors (2> without proper escaping)
- Multiple retry attempts burning credits
- Mixed command syntaxes in same session despite knowing platform is Windows
Error Messages/Logs
Steps to Reproduce
Steps to Reproduce
Environment:
- Claude Code CLI on Windows 10/11
- Platform detected as win32
Steps:
- Start Claude Code on Windows
- Ask Claude to copy a file:
"Copy file A to file B as a backup"
- Observe: Claude attempts:
Copy-Item "path/to/file" "path/to/backup"
- Result: Exit code 127 - Copy-Item: command not found
- Claude retries with:
copy "path/to/file" "path/to/backup"
- Result: Exit code 127 - copy: command not found
- Claude finally tries:
powershell -Command "Copy-Item 'path/to/file' 'path/to/backup'"
- Result: Success (but 2 failed calls already burned)
- Ask Claude to list files with error suppression:
"Check if files exist in this folder"
- Observe: Claude attempts:
powershell -Command "dir 'C:\path\' 2>$null | Format-Table"
- Result: PowerShell parsing error - redirect syntax wrong
Expected: Claude should use powershell -Command "..." syntax from the start on Windows, with correct escaping.
Actual: 2-3 failed attempts before correct syntax, each costing API credits.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Opus 4.5 (model ID: claude-opus-4-5-20251101)
Claude Code Version
Opus 4.5 (model ID: claude-opus-4-5-20251101)
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 ↗