Skip to content

Conversation

@MarcinDudekDev
Copy link

Summary

  • Fix hookify plugin import errors that occurred when CLAUDE_PLUGIN_ROOT environment variable was not set
  • Add fallback path resolution using __file__ when env var is missing
  • Change imports from hookify.core.* to core.* for cache directory compatibility

Problem

The hookify hooks displayed "Hookify import error: No module named 'hookify'" on every tool use (PreToolUse, PostToolUse, Stop, UserPromptSubmit). This happened because:

  1. The hooks assumed CLAUDE_PLUGIN_ROOT env var would always be set
  2. The import paths (from hookify.core.*) didn't work with the cache directory structure (hookify/0.1.0/ instead of hookify/)

Solution

  1. Added fallback to derive PLUGIN_ROOT from script location when env var is missing
  2. Changed to from core.* imports which work when PLUGIN_ROOT is in sys.path
  3. Made path setup unconditional (always runs, not just when env var exists)

Test plan

  • Tested all 4 hook scripts manually with echo '{}' | python3 <script>
  • Verified no import errors in new Claude Code session
  • Confirmed hooks return {} (empty JSON) when no rules match

🤖 Generated with Claude Code

The hookify hooks relied on CLAUDE_PLUGIN_ROOT environment variable being
set by Claude Code, but this wasn't always the case. This caused import
errors like "No module named 'hookify'" on every tool use.

Changes:
- Add fallback to derive PLUGIN_ROOT from __file__ when env var is missing
- Change imports from `hookify.core.*` to `core.*` for compatibility with
  the cache directory structure (hookify/0.1.0/ vs hookify/)
- Always add PLUGIN_ROOT to sys.path (not conditional on env var existing)

This fixes the "Hookify import error: No module named 'hookify'" that
appeared in PostToolUse, PreToolUse, Stop, and UserPromptSubmit hooks.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants