Windows: Hook .sh scripts open in editor instead of being executed
Bug Description
On Windows, when a plugin hook uses a .sh script (e.g., session-start.sh from the superpowers plugin), Claude Code does not properly execute the script with bash. Instead, Windows falls back to the file association handler, which opens the .sh file in the default editor (e.g., VSCode) as a new tab.
Impact
- Focus stealing: The opened
.shfile tab steals keyboard focus from the active editor, interrupting the user's workflow. - Accidental modification: The user may accidentally edit the hook script since focus jumps into it.
- Hook doesn't execute: The intended hook behavior (context injection) does not run.
Steps to Reproduce
- Install the
superpowersplugin on Windows - Open Claude Code in VSCode terminal (PowerShell or CMD)
- Start a new session or resume a session
- Observe that
session-start.shopens as a VSCode editor tab instead of being silently executed
Expected Behavior
Claude Code should detect the .sh extension and invoke the script using an available bash interpreter (e.g., Git Bash at C:\Program Files\Git\bin\bash.exe or D:\Git\bin\bash.exe) rather than delegating to the Windows shell, which treats .sh files as "open with" targets.
Environment
- OS: Windows 10/11
- Terminal: PowerShell (VSCode integrated terminal)
- Claude Code version: Latest
- Plugin: superpowers v4.1.1
Hook Configuration
The hook is defined in hooks.json:
{
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh"
}
]
}
]
}
}
Workaround
Manually clean Windows registry to remove VSCode from .sh file association:
- Remove
VSCode.shfromHKCU:\Software\Classes\.sh\OpenWithProgids - Remove
Code.exefromHKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.sh\OpenWithList
This prevents VSCode from opening the file, but the hook still doesn't execute properly.
Related
- #9758 (similar report about hook execution on Windows)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗