CLAUDE_PLUGIN_ROOT not passed to UserPromptSubmit hooks in plugin system

Resolved 💬 3 comments Opened Mar 20, 2026 by NTTAKR Closed Mar 24, 2026

Bug Description

The CLAUDE_PLUGIN_ROOT environment variable is not being passed (or not exported) to UserPromptSubmit hook scripts run by plugins. This causes every user prompt to display a "hook error" message.

Reproduction

  1. Enable the hookify plugin (from claude-plugins-official)
  2. Start a Claude Code session
  3. Submit any prompt
  4. Observe UserPromptSubmit hook error displayed below the prompt

This happens on every single prompt submission.

Root Cause

The hookify plugin's UserPromptSubmit hook (hooks/userpromptsubmit.py) relies on CLAUDE_PLUGIN_ROOT to add the plugin directory to sys.path so it can import its core module:

PLUGIN_ROOT = os.environ.get('CLAUDE_PLUGIN_ROOT')
if PLUGIN_ROOT and PLUGIN_ROOT not in sys.path:
    sys.path.insert(0, PLUGIN_ROOT)

from core.config_loader import load_rules
from core.rule_engine import RuleEngine

When CLAUDE_PLUGIN_ROOT is not set, the import fails with No module named 'core'.

Verification

Running the hook without CLAUDE_PLUGIN_ROOT:

python3 .../hookify/.../hooks/userpromptsubmit.py
# Output: {"systemMessage": "Hookify import error: No module named 'core'"}

Running with CLAUDE_PLUGIN_ROOT exported:

export CLAUDE_PLUGIN_ROOT=.../hookify/b664e152af57
echo '{"userPrompt":"test"}' | python3 .../hooks/userpromptsubmit.py
# Output: {}  (success)

Notes

  • SessionStart hooks from the same plugin system do receive CLAUDE_PLUGIN_ROOT correctly — the superpowers plugin's SessionStart hook uses it successfully.
  • This suggests the env var injection works for SessionStart but is missing for UserPromptSubmit (and possibly PreToolUse, PostToolUse, Stop hooks as well).
  • The hookify plugin also registers PreToolUse, PostToolUse, and Stop hooks that use python3 and likely have the same issue.

Environment

  • Claude Code v2.1.80
  • Linux (Fedora 43, kernel 6.19.8)
  • hookify plugin version: b664e152af57

🤖 Generated with Claude Code

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗