claude-code - 💡(How to fix) Fix Hookify plugin: ImportError due to versioned cache directory structure [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47868Fetched 2026-04-15 06:40:02
View on GitHub
Comments
2
Participants
3
Timeline
8
Reactions
0
Author
Timeline (top)
labeled ×6commented ×2

Error Message

Hookify import error: No module named 'hookify'

Root Cause

The plugin cache stores hookify at:

~/.claude/plugins/cache/claude-code-plugins/hookify/0.1.0/

The hook scripts (e.g., hooks/pretooluse.py) set up sys.path like this:

PLUGIN_ROOT = os.environ.get('CLAUDE_PLUGIN_ROOT')  # .../hookify/0.1.0/
parent_dir = os.path.dirname(PLUGIN_ROOT)            # .../hookify/
sys.path.insert(0, parent_dir)
sys.path.insert(0, PLUGIN_ROOT)

from hookify.core.config_loader import load_rules  # fails

Python's from hookify.core.config_loader expects a directory named hookify/ containing core/config_loader.py on sys.path. But:

  • parent_dir (…/hookify/) contains only 0.1.0/, not a hookify/ subdirectory
  • PLUGIN_ROOT (…/hookify/0.1.0/) also doesn't contain a hookify/ subdirectory

The version number directory (0.1.0/) breaks Python's package resolution.

Fix Action

Workaround

Creating a symlink inside the cache directory resolves the issue:

ln -sf "0.1.0" ~/.claude/plugins/cache/claude-code-plugins/hookify/hookify

This lets Python find hookify/core/config_loader.py via the symlink.

Code Example

Hookify import error: No module named 'hookify'

---

~/.claude/plugins/cache/claude-code-plugins/hookify/0.1.0/

---

PLUGIN_ROOT = os.environ.get('CLAUDE_PLUGIN_ROOT')  # .../hookify/0.1.0/
parent_dir = os.path.dirname(PLUGIN_ROOT)            # .../hookify/
sys.path.insert(0, parent_dir)
sys.path.insert(0, PLUGIN_ROOT)

from hookify.core.config_loader import load_rules  # fails

---

ln -sf "0.1.0" ~/.claude/plugins/cache/claude-code-plugins/hookify/hookify
RAW_BUFFERClick to expand / collapse

Bug Description

The hookify plugin fails to import its own modules when loaded from the plugin cache, producing this error on every PreToolUse, PostToolUse, and other hook events:

Hookify import error: No module named 'hookify'

Root Cause

The plugin cache stores hookify at:

~/.claude/plugins/cache/claude-code-plugins/hookify/0.1.0/

The hook scripts (e.g., hooks/pretooluse.py) set up sys.path like this:

PLUGIN_ROOT = os.environ.get('CLAUDE_PLUGIN_ROOT')  # .../hookify/0.1.0/
parent_dir = os.path.dirname(PLUGIN_ROOT)            # .../hookify/
sys.path.insert(0, parent_dir)
sys.path.insert(0, PLUGIN_ROOT)

from hookify.core.config_loader import load_rules  # fails

Python's from hookify.core.config_loader expects a directory named hookify/ containing core/config_loader.py on sys.path. But:

  • parent_dir (…/hookify/) contains only 0.1.0/, not a hookify/ subdirectory
  • PLUGIN_ROOT (…/hookify/0.1.0/) also doesn't contain a hookify/ subdirectory

The version number directory (0.1.0/) breaks Python's package resolution.

Workaround

Creating a symlink inside the cache directory resolves the issue:

ln -sf "0.1.0" ~/.claude/plugins/cache/claude-code-plugins/hookify/hookify

This lets Python find hookify/core/config_loader.py via the symlink.

Suggested Fix

Either:

  1. Change imports to be relative — use from core.config_loader import load_rules instead of from hookify.core.config_loader
  2. Add grandparent to sys.path — add os.path.dirname(os.path.dirname(PLUGIN_ROOT)) (i.e., .../cache/claude-code-plugins/) which contains the hookify/ directory. Then create an __init__.py in the hookify/ cache directory, or adjust the versioned layout.
  3. Use PLUGIN_ROOT directly — since PLUGIN_ROOT/core/ exists, change the path setup to treat PLUGIN_ROOT as the package root.

Environment

  • macOS Darwin 25.4.0 (Apple Silicon)
  • Claude Code (latest)
  • Hookify plugin v0.1.0
  • Plugin author: Daisy Hollman ([email protected])

Impact

The error fires on every single tool call (PreToolUse + PostToolUse), meaning 2 error messages per tool invocation. While hookify gracefully degrades (exits 0), it clutters system-reminder messages and wastes context window tokens.

🤖 Generated with Claude Code

extent analysis

TL;DR

The most likely fix is to adjust the sys.path setup or import statements in the hook scripts to accommodate the versioned directory structure in the plugin cache.

Guidance

  • Verify that the sys.path modifications are correctly setting up the package root for the hookify plugin, ensuring that Python can find the hookify package.
  • Consider implementing one of the suggested fixes, such as changing imports to be relative, adding the grandparent directory to sys.path, or using PLUGIN_ROOT directly as the package root.
  • Test the chosen fix by invoking a tool and checking for the absence of the "Hookify import error" message.
  • If using the symlink workaround, ensure that the symlink is correctly created and that the hookify directory is properly linked to the versioned directory.

Example

# Relative import example
from core.config_loader import load_rules

Notes

The suggested fixes assume that the versioned directory structure in the plugin cache is a requirement. If this structure can be changed, alternative solutions may be available.

Recommendation

Apply the workaround of creating a symlink inside the cache directory, as it provides a simple and effective solution to the import issue, allowing Python to find the hookify package via the symlink.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING