Skip to content

[Windows] Hook execution flashes black console window on every tool use #2869

@susan-jse

Description

@susan-jse

Environment

  • OS: Windows 11
  • Claude Code: VS Code Extension
  • claude-mem: v13.5.0

Problem

Every hook execution causes a black console window to briefly flash on screen.
The window appears and disappears instantly, but is very disruptive during
active use since hooks fire constantly throughout a session.

Root Cause (Confirmed via Testing)

All hooks use "shell": "bash". On Windows, spawning a bash process from a
GUI application (VS Code) causes the OS to momentarily display a console window.
This is standard Windows behavior — it requires CREATE_NO_WINDOW to suppress.

Reproduction Steps

  1. Install claude-mem on Windows 11 with VS Code extension
  2. Open any project and ask Claude any question that involves file reads
  3. Observe repeated black console window flashes throughout processing

Impact by Hook (Confirmed)

Hook Matcher Frequency Impact
PostToolUse * Every single tool call Primary cause — most disruptive
PreToolUse Read Every file read Secondary cause
UserPromptSubmit Once per prompt Minor
SessionStart Once per session Minor

Disabling PostToolUse(*) alone caused a dramatic reduction in flashes.
Disabling PreToolUse(Read) alone had minimal visible effect.

Suggested Fix

On Windows, suppress console window creation when spawning bash processes.

Option A — Use CREATE_NO_WINDOW process flag in the Node.js hook runner:

// In bun-runner.js / worker-service.cjs
spawn(cmd, { windowsHide: true })  // Node.js child_process option

Option B — Detect platform and use PowerShell with hidden window:

{
  "shell": "powershell",
  "command": "Start-Process bash -ArgumentList '-c','<cmd>' -WindowStyle Hidden -Wait"
}

Option C — Use the args exec form (no shell spawn = no window):

{
  "command": "node",
  "args": ["path/to/bun-runner.js", "path/to/worker-service.cjs", "hook", "claude-code", "observation"]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions