Bug
On Windows, the code-analysis plugin's handleAutoReindex in hooks/handler.ts spawns a visible cmd.exe console window every time a code file is written or edited. The window flashes in the foreground showing "Indexing C:\Users...\project..." and steals focus.
Root cause
claudemem is installed globally via npm, which creates a .cmd batch file wrapper (%APPDATA%\Roaming\npm\claudemem.cmd). On Windows, .cmd/.bat files always open a visible cmd.exe console window — Node's windowsHide: true flag is ignored because it only applies to .exe binaries.
This affects two call sites in hooks/handler.ts:
-
handleAutoReindex (background spawn) — the most visible, fires on every Write/Edit of a code file:
const child = spawn("claudemem", ["index", "--quiet"], {
cwd: input.cwd,
detached: true,
stdio: "ignore",
windowsHide: true, // ← has no effect on .cmd files
});
-
runCommand (sync calls) — used for claudemem status and claudemem --version on SessionStart:
const result = spawnSync(cmd, args, {
cwd,
encoding: "utf-8",
timeout: 10000,
windowsHide: true, // ← same issue
});
Suggested fix
On Windows, resolve claudemem to bun.exe + the actual JS entry point directly, bypassing the .cmd wrapper. The .cmd file itself reveals the path:
"%_prog%" "%dp0%\node_modules\mnemex\dist\index.js" %*
For the background spawn:
const claudememJs = join(
process.env.APPDATA || "",
"npm", "node_modules", "mnemex", "dist", "index.js"
);
const bunExe = existsSync(join(process.env.USERPROFILE || "", ".bun", "bin", "bun.exe"))
? join(process.env.USERPROFILE || "", ".bun", "bin", "bun.exe")
: "bun";
const cmd = existsSync(claudememJs) ? bunExe : "claudemem";
const args = existsSync(claudememJs)
? [claudememJs, "index", "--quiet"]
: ["index", "--quiet"];
const child = spawn(cmd, args, {
cwd: input.cwd,
detached: true,
stdio: "ignore",
windowsHide: true, // now works because bun.exe is a real .exe
});
Same pattern for runCommand — detect Windows + claudemem command and redirect to bun + JS entry point.
Environment
- Windows 11, Claude Code CLI
- code-analysis plugin v3.2.2
- mnemex installed globally via
npm install -g mnemex
- bun available at
C:\Users\<user>\.bun\bin\bun.exe
Notes
This is a general Windows gotcha for any npm-installed CLI tool invoked via spawn/spawnSync — the .cmd wrapper will always flash a window. The same pattern applies to any future tools the plugin might spawn.
Bug
On Windows, the
code-analysisplugin'shandleAutoReindexinhooks/handler.tsspawns a visiblecmd.execonsole window every time a code file is written or edited. The window flashes in the foreground showing "Indexing C:\Users...\project..." and steals focus.Root cause
claudememis installed globally via npm, which creates a.cmdbatch file wrapper (%APPDATA%\Roaming\npm\claudemem.cmd). On Windows,.cmd/.batfiles always open a visiblecmd.execonsole window — Node'swindowsHide: trueflag is ignored because it only applies to.exebinaries.This affects two call sites in
hooks/handler.ts:handleAutoReindex(background spawn) — the most visible, fires on everyWrite/Editof a code file:runCommand(sync calls) — used forclaudemem statusandclaudemem --versionon SessionStart:Suggested fix
On Windows, resolve
claudememtobun.exe+ the actual JS entry point directly, bypassing the.cmdwrapper. The.cmdfile itself reveals the path:For the background spawn:
Same pattern for
runCommand— detect Windows +claudememcommand and redirect tobun+ JS entry point.Environment
npm install -g mnemexC:\Users\<user>\.bun\bin\bun.exeNotes
This is a general Windows gotcha for any npm-installed CLI tool invoked via
spawn/spawnSync— the.cmdwrapper will always flash a window. The same pattern applies to any future tools the plugin might spawn.