Windows: Hook .sh scripts open in editor instead of being executed

Resolved 💬 3 comments Opened Jan 30, 2026 by Burppp Closed Feb 2, 2026

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

  1. Install the superpowers plugin on Windows
  2. Open Claude Code in VSCode terminal (PowerShell or CMD)
  3. Start a new session or resume a session
  4. 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

  • #9758 (similar report about hook execution on Windows)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗