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
.sh file 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
superpowers plugin on Windows
- Open Claude Code in VSCode terminal (PowerShell or CMD)
- Start a new session or resume a session
- Observe that
session-start.sh opens 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.sh from HKCU:\Software\Classes\.sh\OpenWithProgids
- Remove
Code.exe from HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.sh\OpenWithList
This prevents VSCode from opening the file, but the hook still doesn't execute properly.
Related
Bug Description
On Windows, when a plugin hook uses a
.shscript (e.g.,session-start.shfrom 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.shfile in the default editor (e.g., VSCode) as a new tab.Impact
.shfile tab steals keyboard focus from the active editor, interrupting the user's workflow.Steps to Reproduce
superpowersplugin on Windowssession-start.shopens as a VSCode editor tab instead of being silently executedExpected Behavior
Claude Code should detect the
.shextension and invoke the script using an available bash interpreter (e.g., Git Bash atC:\Program Files\Git\bin\bash.exeorD:\Git\bin\bash.exe) rather than delegating to the Windows shell, which treats.shfiles as "open with" targets.Environment
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
.shfile association:VSCode.shfromHKCU:\Software\Classes\.sh\OpenWithProgidsCode.exefromHKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.sh\OpenWithListThis prevents VSCode from opening the file, but the hook still doesn't execute properly.
Related