Skip to content

Windows Claude Code: repeated hook loader failures when plugin uses  #378

@Asureu

Description

@Asureu

Summary

On native Windows Claude Code, context-mode has repeatedly hit startup/runtime hook failures after upgrade or reinstall when plugin-managed files use ${CLAUDE_PLUGIN_ROOT} in hook commands and MCP startup args.

Observed failures include:

  • Failed with non-blocking status code: node:internal/modules/cjs/loader:1479
  • SessionStart:startup hook error
  • PostToolUse:Edit hook error
  • PostToolUse:TaskUpdate hook error
  • UserPromptSubmit hook error

This has now been observed across multiple versions, including 1.0.98 and 1.0.103.

What keeps reproducing

After upgrade/reinstall, these plugin-managed files revert to placeholder-based paths again:

  • .claude-plugin/plugin.json
  • hooks/hooks.json

Examples from fresh plugin state:

"args": ["${CLAUDE_PLUGIN_ROOT}/start.mjs"]
"command": "node \"${CLAUDE_PLUGIN_ROOT}/hooks/sessionstart.mjs\""

In this Windows environment, that placeholder family repeatedly correlates with runtime loader failures.

Important observations

  • ctx-doctor can still pass.
  • Direct node --check on hook scripts can still pass.
  • Direct manual node <absolute-path> execution of hook scripts can still pass.
  • Failures show up during real Claude runtime hook execution.
  • Upgrades overwrite the local workaround and the problem returns.

Working local workaround

Replacing ${CLAUDE_PLUGIN_ROOT} with absolute Windows-safe paths in both places restores stability locally:

  1. hooks/hooks.json
    • posttooluse.mjs
    • precompact.mjs
    • pretooluse.mjs
    • userpromptsubmit.mjs
    • sessionstart.mjs
  2. .claude-plugin/plugin.json
    • replace ${CLAUDE_PLUGIN_ROOT}/start.mjs with absolute path

After that:

  • startup hook errors stop
  • slash commands return
  • MCP tools return
  • ctx-doctor passes

Why I think this is upstream-worthy

  • It has reproduced across multiple versions.
  • It is not durable: upgrade restores placeholder-based registration and the issue comes back.
  • The current working fix is stable locally.
  • This suggests either:
    1. context-mode should not rely on ${CLAUDE_PLUGIN_ROOT} on native Windows Claude Code, or
    2. Claude Code on Windows is expanding/invoking ${CLAUDE_PLUGIN_ROOT} incorrectly during plugin hook execution.

Request

Could you please evaluate one of these directions?

  1. Add a Windows-safe registration strategy that avoids ${CLAUDE_PLUGIN_ROOT} for Claude Code hooks / MCP startup on native Windows.
  2. Detect broken Windows runtime expansion and self-heal during install/upgrade.
  3. Document whether ${CLAUDE_PLUGIN_ROOT} is known to be unreliable on native Windows Claude Code.

I can provide sanitized follow-up details if useful, but I am intentionally omitting machine-specific personal paths from this report.

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