Windows: UserPromptSubmit hook written as "codegraph prompt-hook" fails in Git Bash (missing .cmd extension)
Summary
On Windows, codegraph install writes a UserPromptSubmit hook with the command codegraph prompt-hook. This fails to resolve (command not found, exit 127) when Claude Code executes hooks through Git Bash — or any shell that requires the .cmd extension to resolve the shim.
Environment
- OS: Windows 11
- codegraph:
@colbymchenry/codegraphv1.5.0 (standalone installer with bundled node) - Install path:
C:\Users\<user>\AppData\Local\codegraph\current\ - Agent: Claude Code
- Shell: Git Bash
Reproduction
codegraph install, accept the prompt-hook prompt (default: yes).- Written
~/.claude/settings.json:
"UserPromptSubmit": [
{ "hooks": [ { "type": "command", "command": "codegraph prompt-hook" } ] }
]
- Under Git Bash the bare
codegraphcan't resolve:
$ echo '{"prompt":"..."}' | codegraph prompt-hook
bash: codegraph: command not found # exit 127
Only codegraph.cmd prompt-hook resolves (exit 0).
Root cause
In dist/installer/targets/claude.js:
const PROMPT_HOOK_COMMAND = 'codegraph prompt-hook';— hard-coded, no platform variantwritePromptHookEntry()pushes this intoUserPromptSubmitunconditionally- No
process.platform === 'win32'/.cmdhandling anywhere inclaude.jsorinstaller/targets/shared.js
For contrast, Serena's installer writes a fully-qualified serena-hooks.exe, which resolves correctly under Git Bash on Windows.
Suggested fix
On Windows, write codegraph.cmd prompt-hook (platform-aware command) so the hook resolves under shells that require the file extension.
Related observation (possibly separate)
Even when invoked correctly as codegraph.cmd prompt-hook, the hook emits empty stdout (exit 0) in a project that is already indexed with the MCP server available. The doc comment on writePromptHookEntry says it should "inject codegraph_explore context for structural prompts so the agent reliably uses the graph", so empty output on what appear to be structural prompts may mean the injection isn't firing. Flagging in case it's related — happy to split into a separate issue.
I got this error on Claude Code CachyOS too althought other commands work normally, maybe the command has been deprecated or deleted?
Fixed in #1489 (merged to main, will ship in the next release). Thanks for the precise report — your root-cause analysis was exactly right.
What the fix does:
- On Windows the installer now writes the hook as
codegraph.cmd prompt-hook. Verified on a Windows 11 VM under Git Bash with a standalone-bundle-only PATH: the bare form exits 127, the.cmdform exits 0 (npm installs never hit this because npm also ships an extensionless sh shim alongside the.cmd). - Existing broken installs self-heal: once you're on the fixed version, re-running
codegraph install(orcodegraph upgrade) rewrites the bare entry in place. Until then, your manualcodegraph.cmd prompt-hookedit is exactly what the installer will write, so you're set.
On the empty-stdout observation: that's largely by design — the hook gates aggressively and exits 0 silently for any prompt it can't confidently match against the index, so most prompts (even code-related ones) produce no injection. Whether the gate is too conservative on genuinely structural prompts is a fair question though — please do split that into its own issue with a couple of example prompts that you'd expect to fire, and we can look at gate recall specifically.
@ayclqt yours is a different mechanism — .cmd doesn't exist on Linux, and the prompt-hook subcommand is current (it's hidden from --help, not removed). Your failure is almost certainly that the environment Claude Code was launched from doesn't have codegraph's install dir on PATH, so the hook subprocess can't resolve it even though your interactive shell can. Could you open a separate issue with the output of which codegraph from your shell and how you launch Claude Code (terminal vs. desktop launcher)?