Skip to content

[BUG] :Hooks always executed via /usr/bin/bash on Windows, ignoring shell setting #32930

Closed as duplicate

Description

@ksharma-adeptia

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Environment

  • OS: Windows 11
  • Claude Code Version: Latest
  • Shell: PowerShell
  • Git Bash: Installed (required for Git, not preferred for Claude Code hooks)

Describe the Bug

On Windows, every hook command defined in settings.json is executed via:

/usr/bin/bash --login -i -c <command>

This causes a Git Bash terminal window to visibly pop up on screen every time a hook fires (SessionStart, PostToolUse, statusLine). With multiple hooks configured, multiple bash windows appear simultaneously, stealing focus and disrupting workflow.

This happens regardless of the shell setting in settings.json.

What Should Happen?


Expected Behavior

  • Hooks should respect the shell setting in settings.json
  • When "shell": "powershell.exe" is configured, hooks should run via PowerShell
  • No unexpected terminal windows should appear during hook execution
  • At minimum, hooks should run with windowsHide: true to suppress the window

Actual Behavior

Every hook is wrapped in /usr/bin/bash --login -i -c <command>, causing:

  • Multiple Git Bash windows popping up simultaneously
  • Windows stealing focus during active work
  • Poor experience on Windows with PowerShell as preferred shell

Error Messages/Logs

Steps to Reproduce


Steps to Reproduce

  1. Install Claude Code on Windows with Git Bash installed
  2. Configure hooks in settings.json:
{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node \"C:/Users/username/.claude/hooks/my-hook.js\""
          }
        ]
      }
    ]
  },
  "shell": "powershell.exe",
  "shellArgs": ["-NoProfile", "-Command"]
}
  1. Start Claude Code
  2. Observe Git Bash window(s) popping up on every hook execution

Possible Fix

When spawning hook processes on Windows, use the configured shell from settings.json, or at minimum pass windowsHide: true to the Node.js spawn/exec call so the window is suppressed:

spawn(command, args, {
  windowsHide: true,  // Prevents window popup on Windows
  shell: configuredShell || false
})

Claude Model

Sonnet (default)

Is this a regression?

Last Working Version

No response

Claude Code Version

2.1.72 (Claude Code)

Platform

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

Additional Context

  • Using get-shit-done-cc GSD plugin with 3 hooks (SessionStart, PostToolUse, statusLine)
  • All hooks are simple Node.js scripts
  • Full node.exe path in commands does not resolve the issue — bash wrapping happens at Claude Code level, before the command is executed
  • The "shell": "powershell.exe" setting works for the terminal but is completely ignored for hook execution

Activity

  1. added
    bug
    on Mar 10, 2026
  2. added
    platform:windows
    has repro
    on Mar 10, 2026
  3. github-actions commented on Mar 10, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Windows: bash popup window appears at startup due to -i flag in cygpath call #26440
    2. [Windows] Hooks create flashing console windows on every tool execution #32140
    3. Windows: Hook commands cause brief console window flash #19012

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  4. ksharma-adeptia commented on Mar 11, 2026

    @ksharma-adeptia
    Author

    Workaround for Windows users (reduces popup visibility)

    While this issue is open, here's a workaround using AutoHotkey that auto-hides the bash popups. The window still briefly appears but is hidden quickly enough to be avoidable.

    Steps

    1. Install AutoHotkey
    Download and install from https://www.autohotkey.com

    2. Create a hide script

    ; Auto-hide any bash window spawned by Claude Code hooks
    SetTitleMatchMode, 2
    Loop {
        WinHide, /usr/bin/bash --login -i -c
        Sleep, 100
    }

    Save it as hide-bash.ahk in your user profile folder.

    3. Run the script
    Double-click hide-bash.ahk — it runs in the background and auto-hides every bash popup triggered by Claude Code hooks.

    4. Make it run on startup (optional)

    copy "$env:USERPROFILE\hide-bash.ahk" "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\"

    Result

    The popup still technically appears for a brief moment but is hidden fast enough that it does not steal focus or disrupt workflow. Not a perfect fix but usable until this is resolved at the Claude Code level.

    Environment: Windows 11, PowerShell, Git Bash installed, using get-shit-done-cc hooks (SessionStart, PostToolUse, statusLine)

  5. github-actions commented on Mar 19, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  6. locked as resolved and limited conversation to collaborators on Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:hooksbughas reproplatform:windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions