Skip to content

Windows: hook commands spawn visible conhost.exe window on every execution #35797

Closed as duplicate

Description

@nkabram

Summary

On Windows, every hook command in settings.json causes a brief conhost.exe console window to flash on screen. This happens because Claude Code spawns bash.exe (Git Bash) for each hook without the CREATE_NO_WINDOW flag, so Windows allocates a new visible console for each execution.

Environment

  • OS: Windows 11
  • Claude Code: latest
  • Shell: Git Bash (C:\Program Files\Git\bin\bash.exe)

Steps to Reproduce

  1. Configure any hook in ~/.claude/settings.json, e.g.:
    "Stop": [{ "matcher": "", "hooks": [{ "type": "command", "command": "echo done" }] }]
  2. Start a Claude Code session and send any message.
  3. Observe a conhost.exe console window flash briefly on screen after each response.

Root Cause

Claude Code calls CreateProcess for bash.exe without passing CREATE_NO_WINDOW in dwCreationFlags. Windows therefore allocates a new visible console for each hook invocation.

In Node.js, this is a one-line fix:

// Current behavior (creates conhost.exe flash)
spawn(bashPath, ['-c', command])

// Fixed (no console window created)
spawn(bashPath, ['-c', command], { windowsHide: true })

The windowsHide option passes CREATE_NO_WINDOW to CreateProcess on Windows.

Impact

  • Hooks that fire frequently (e.g. Stop, UserPromptSubmit, PostToolUse) cause constant screen flashing that is jarring and disruptive during normal use.
  • Each hook entry in a matcher group is a separate bash.exe spawn, multiplying the effect.
  • Affects all Windows users who use hooks.

Workaround

A GUI-subsystem wrapper executable (hidden-bash.exe) can be built and pointed to via CLAUDE_CODE_GIT_BASH_PATH. Since it compiles as a Windows GUI app (no console subsystem), Node.js spawns it without creating a conhost.exe. It then spawns bash with CREATE_NO_WINDOW:

cmd.SysProcAttr = &syscall.SysProcAttr{
    HideWindow:    true,
    CreationFlags: 0x08000000, // CREATE_NO_WINDOW
}

Built with: go build -ldflags="-H windowsgui" -o hidden-bash.exe .

This workaround works but requires users to build and maintain a custom binary. The proper fix is { windowsHide: true } on the Node.js spawn call in Claude Code itself.

Requested Fix

Pass windowsHide: true when spawning hook processes on Windows. This is a well-known Node.js pattern for suppressing console windows for child processes on Windows.

Activity

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

    @github-actions

    Found 3 possible duplicate issues:

    1. [Windows] Hooks create flashing console windows on every tool execution #32140
    2. Windows: Hook commands cause brief console window flash #19012
    3. [BUG] :Hooks always executed via /usr/bin/bash on Windows, ignoring shell setting #32930

    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

  3. added
    duplicate
    and removed
    bug
    has repro
    platform:windows
    on Mar 22, 2026
  4. github-actions commented on Mar 22, 2026

    @github-actions

    This issue has been automatically closed as a duplicate of #32140.

    If this is incorrect, please re-open this issue or create a new one.

    🤖 Generated with Claude Code

  5. github-actions commented on Mar 29, 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 29, 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

    duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions