Skip to content

Windows: Bash commands spawn visible black console windows #28138

Closed as not planned

Description

@liorcheckpoint

Problem

On Windows, every time Claude Code executes a Bash command, a black console window briefly appears on screen. This is disruptive, especially during multi-step tasks that run many commands in sequence.

Root Cause

When Claude Code spawns bash.exe (Git for Windows) as a child process, it does not set the CREATE_NO_WINDOW process creation flag. Windows therefore creates a visible console window for each spawned process.

Expected Behavior

Bash commands should execute silently in the background with no visible console window, similar to how background processes behave in macOS/Linux.

Suggested Fix

Pass CREATE_NO_WINDOW (or windowsHide: true in Node.js child_process.spawn() options) when spawning shell processes on Windows.

Alternatively, expose a user-configurable setting in settings.json such as:

{
  "windowsHide": true
}

Environment

  • OS: Windows 11 Enterprise
  • Shell: Git Bash (C:\Users\...\AppData\Local\Programs\Git\usr\bin\bash.exe)
  • Claude Code: VSCode extension / Desktop app

Activity

  1. github-actions commented on Feb 24, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Windows: Console window flashing when executing tools #14828
    2. [Bug] Windows 10: Constant console window popups and zombie node.exe processes #20814
    3. [BUG] windows popup issue #19391

    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

  2. ilude commented on Feb 25, 2026

    @ilude

    Is this going to get addressed? I am stuck on 2.1.42 which seems to be the last working version before this bug was introduced!

    I dug into it and here is what I can tell based on the available info to the public:

    Windows: Console window flashing regression introduced in v2.1.45

    Since v2.1.45, every tool call, hook execution, and MCP server startup on Windows spawns a visible cmd.exe/conhost.exe window that flashes on screen and steals keyboard focus. v2.1.42 is the last version without this behavior.

    This has been reported independently by many users across 14+ issues over the past two months with no official response. Posting this as a consolidated comment with root cause analysis to hopefully get some traction.

    What happens

    When Claude Code executes any tool (Bash, Grep, Glob, Read, etc.), runs a hook, or starts an MCP server, a black console window briefly appears and steals keyboard focus. If you're typing in another application, keystrokes get swallowed. If you have hooks running on every prompt or tool call, the flashing is nearly continuous. It makes Claude Code effectively unusable on Windows without pinning to v2.1.42.

    Root cause analysis

    The regression aligns precisely with the introduction of the session environment / shell snapshotting mechanism in v2.1.45. Here's the evidence:

    1. v2.1.27 originally fixed console window flashing by adding windowsHide: true to child_process.spawn() calls
    2. v2.1.45 introduced shell snapshotting — a mechanism that captures and replays the user's shell environment. This created new spawn call sites that don't carry the windowsHide: true fix from v2.1.27
    3. The error message "Session environment not yet supported on Windows" (#26610) confirms the feature shipped without full Windows support
    4. The onecmd leak in $SHELLOPTS (#26481) shows the snapshotting mechanism uses bash -o onecmd to capture environment, and this flag leaks into user sessions
    5. Technical investigation in #27115 confirmed that windowsHide: true IS set in 12 places in the binary, but the ConPTY/SEA binary context causes conhost.exe allocation anyway — the new spawn paths introduced by shell snapshotting likely bypass or override these settings

    Additional changes in v2.1.45 that may contribute:

    • "Propagating API provider environment variables to tmux-spawned processes" — if env construction was refactored, spawn options may have been lost
    • "Improved memory usage for shell commands that produce large output" — likely touched spawn call sites

    v2.1.47 made things worse with "Fixed hooks silently failing on Windows by using Git Bash instead of cmd.exe" (#25981), which created yet another spawn path. That same version also introduced hook path mangling on Windows (#26746) where backslash separators get stripped.

    Related issues

    Primary reports:

    • #14828 — Console window flashing when executing tools (9 👍, 13 comments, open since Dec 2025)
    • #27115 — Plugin hooks spawn visible cmd.exe/conhost.exe despite windowsHide:true
    • #28138 — Bash commands spawn visible black console windows
    • #20814 — Constant console window popups and zombie node.exe processes
    • #19391 — Windows popup issue

    Duplicate/related reports:

    • #19012 — Hook commands cause brief console window flash (contains COMSPEC wrapper workaround)
    • #17230 — Feature request: add windowsHide option for hooks
    • #16880 — Console window flashes on every Bash tool execution (closed as dup)
    • #15572 — Console windows flash, missing windowsHide option (closed as dup)
    • #24708 — MCP stdio servers flash visible CMD windows (closed as dup)
    • #26440 — Bash popup at startup due to -i flag in cygpath call (closed as dup)
    • #21375 — Bun console window appears when starting Claude Code
    • #23229 — Persistent bun.exe terminal window with EPERM error

    Same-root-cause regressions from v2.1.45:

    • #26481 — Bash tool returns exit code 1 (onecmd in SHELLOPTS)
    • #26610 — "Session environment not yet supported on Windows"
    • #26746 — Hook paths broken (backslash stripping)

    Workarounds

    Workaround Effectiveness
    Pin to v2.1.42 + DISABLE_AUTOUPDATER=1 Fully works, but stuck on old version
    Custom COMSPEC wrapper (details in #19012) Fully works, requires compiling a C++ GUI-subsystem exe
    Set CLAUDE_CODE_GIT_BASH_PATH to C:\Program Files\Git\bin\bash.exe Works for some users
    Use WSL instead of native Windows Works but changes the whole workflow
    Disable plugin hooks (claude-mem, etc.) Reduces frequency but doesn't eliminate

    What a fix probably looks like

    Based on community investigation, the fix needs to ensure windowsHide: true (or the Win32 CREATE_NO_WINDOW flag) is set on all child_process.spawn() and child_process.exec() calls — including the ones introduced by the shell snapshotting mechanism in v2.1.45 and the hook execution path changed in v2.1.47. The MCP SDK also has a bug where windowsHide is conditional on "type" in process which only returns true in Electron, so it's effectively always false in Node.js (#24708).

    Environment

    • Windows 11 (also reported on Windows 10)
    • Claude Code v2.1.45+ (last working: v2.1.42)
    • Affects: CLI (VS Code extension and Claude Desktop also reported in some issues but unverified)
    • Terminals tested: Windows Terminal, VS Code integrated terminal, cmd.exe, PowerShell
  3. jphoenix-dev commented on Feb 25, 2026

    @jphoenix-dev

    @ilude Are you on the "native" windows installer version or the older npm version? I've just checked and my working (i.e. cannot repro flashing behaviour) v2.1.56 CLI is running the older npm version.

    Obviously both variants should be fixed and this bug has been around a long time with no substantive response, but if you need a workaround it might be worth trying the older npm install path. Alternatively hopefully flagging that possible differentiator might help Anthropic debug the issue.

  4. ilude commented on Feb 26, 2026

    @ilude

    @jphoenix-dev I am using the npm version. I will try the native installer in the morning and let you know here if the issue still exist there or not.

  5. ilude commented on Feb 26, 2026

    @ilude

    Update: Isolated hook flashing to uv.exe + missing windowsHide on hook spawn path (v2.1.59, npm)

    Did systematic testing on v2.1.59 (npm) to isolate exactly what causes the console window flashing. The root cause is a combination of two factors.

    Test methodology: Disabled all hooks, then re-enabled one at a time with different commands.

    Hook command Flashing?
    No hooks at all No
    echo hook-fired No
    python script.py No
    uv run script.py Yes
    uv run --no-sync script.py Yes
    uvw run script.py (uv 0.9.7) Yes
    uvw run script.py (uv 0.10.5) Yes

    Why echo/python don't flash but uv does: echo and python execute inside the bash process that Claude Code already spawned for the hook — no new console window is allocated. uv.exe is a separate Windows console-subsystem binary that allocates its own conhost.exe. On v2.1.42, this was invisible because Claude Code's hook runner passed windowsHide: true (or CREATE_NO_WINDOW) to the parent shell, which propagated to child processes. On v2.1.45+, that flag was lost on the hook execution path, so uv's console window becomes visible.

    This explains why pinning to v2.1.42 fixed the issue entirely — the hooks were calling uv run on both versions, but v2.1.42 suppressed the console window allocation that v2.1.45+ exposes.

    Even uvw.exe (Astral's official windowless wrapper, astral-sh/uv#6801) still flashes in this context, confirming that the missing windowsHide/CREATE_NO_WINDOW on Claude Code's hook spawn path is the primary issue.

    Workaround: Replace uv run with bare python in hook commands. Pre-install any PEP 723 dependencies into system Python (e.g., pip install pyyaml tree-sitter). Since python runs inside the existing bash process rather than allocating a new console, it avoids the flashing entirely regardless of Claude Code version.

    Note: Internal tool calls (Bash, Read, Grep, Glob, Edit) did not flash with hooks disabled on v2.1.59 npm. This suggests the windowsHide regression is specifically on the hook execution path, not the main tool spawn path. Others seeing flashing on non-hook tool calls may be hitting a different code path.

    @jphoenix-dev Haven't tested the native installer yet — this was all on the npm version. Will update when I do.

  6. github-actions commented on Mar 26, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  7. github-actions commented on Apr 3, 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.

  8. locked as resolved and limited conversation to collaborators on Apr 3, 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:bashbugSomething isn't workingduplicateThis issue or pull request already existsplatform:windowsIssue specifically occurs on WindowsstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions