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
- Enable the
hookifyplugin (fromclaude-plugins-official) - Start a Claude Code session
- Submit any prompt
- Observe
UserPromptSubmit hook errordisplayed 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
SessionStarthooks from the same plugin system do receiveCLAUDE_PLUGIN_ROOTcorrectly — the superpowers plugin'sSessionStarthook uses it successfully.- This suggests the env var injection works for
SessionStartbut is missing forUserPromptSubmit(and possiblyPreToolUse,PostToolUse,Stophooks as well). - The hookify plugin also registers
PreToolUse,PostToolUse, andStophooks that usepython3and 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
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗