[BUG] ! prefix ignores configured primary shell on Windows, always routes to bash
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?
On Windows, the ! command prefix always dispatches to /usr/bin/bash (Git Bash), ignoring the configured primary shell. When PowerShell is set as the primary shell, .cmd and .bat files invoked via ! fail with command not found.
Environment
- OS: Windows 11 Pro 10.0.26200
- Shell (configured): PowerShell (primary)
Steps to Reproduce
- Configure PowerShell as primary shell on Windows
- Type ! some-script.cmd in the Claude Code prompt
- Observe: /usr/bin/bash: line 1: some-script: command not found
Expected Behavior
! dispatches through the configured primary shell (PowerShell), so .cmd and .bat files resolve correctly.
Actual Behavior
! hardcodes /usr/bin/bash regardless of primary shell setting. Windows-native scripts are unreachable via ! on any system where Git Bash is installed alongside PowerShell.
Impact
No user-side workaround exists — the only fix is to have the AI invoke the script via the PowerShell tool, which defeats the purpose of !.
What Should Happen?
The ! prefix should dispatch through the configured primary shell (PowerShell on Windows), so .cmd and .bat files are found and executed correctly.
Error Messages/Logs
!
Steps to Reproduce
Steps to Reproduce — replace the placeholder with:
- Install Git Bash and PowerShell on Windows 11
- Open Claude Code — primary shell is configured as PowerShell
- Type: ! LLM_test-close.cmd (or any .cmd file in PATH)
- Observe: /usr/bin/bash: line 1: LLM_test-close: command not found
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.183 (Claude Code)
Platform
Other
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
Workaround: invoke the script via the PowerShell tool directly. The ! shortcut is effectively broken for Windows-native scripts on any Windows system with Git Bash installed.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗