Skip to content

CLAUDE_PLUGIN_ROOT environment variable not set for SessionStart hooks #27145

@AKhozya

Description

@AKhozya

Description

Plugin hooks that reference ${CLAUDE_PLUGIN_ROOT} in their command work correctly for PreToolUse, PostToolUse, and other lifecycle events, but fail for SessionStart hooks because the environment variable is not populated at that stage.

Reproduction

  1. Install any plugin that uses ${CLAUDE_PLUGIN_ROOT} in a SessionStart hook command
  2. Start a new Claude Code session
  3. Observe: MODULE_NOT_FOUND error because the path resolves to "/scripts/hooks/..." (empty prefix)

Example from hooks.json:

{
  "event": "SessionStart",
  "hooks": [{
    "type": "command",
    "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/hooks/session-start.js\""
  }]
}

Expected Behavior

CLAUDE_PLUGIN_ROOT should be set for ALL hook lifecycle events, including SessionStart.

Actual Behavior

CLAUDE_PLUGIN_ROOT is unset during SessionStart, causing the command to fail with exit code 1 (MODULE_NOT_FOUND).

Workaround

Replace ${CLAUDE_PLUGIN_ROOT} with the absolute path to the plugin cache directory in hooks.json. Must be reapplied after plugin updates.

Environment

  • Claude Code (CLI)
  • macOS
  • Plugin: everything-claude-code v1.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions