Skip to content

Conversation

@clowerweb
Copy link

Summary

Two fixes for the hookify plugin in config_loader.py:

  • Python 3.8 compatibility: Add from __future__ import annotations to fix TypeError: 'type' object is not subscriptable on Python 3.8 (Ubuntu 20.04 default). The tuple[Dict, str] return type syntax requires Python 3.9+; the future import enables it on 3.7+.
  • cwd-independent rule loading: Use CLAUDE_PROJECT_DIR env var instead of relative path for .claude/hookify.*.local.md discovery. Previously, rules were only found when the cwd happened to be the project root; now they're found from any working directory.

Test plan

  • Verify hookify loads on Python 3.8 without TypeError
  • Verify hookify rules are discovered when cwd is a subdirectory of the project
  • Verify hookify rules still work normally when CLAUDE_PROJECT_DIR is set (standard Claude Code behavior)
  • Verify fallback to os.getcwd() when CLAUDE_PROJECT_DIR is unset

Fixes #14588
Fixes #20749

🤖 Generated with Claude Code

Two fixes for the hookify plugin:

1. Add `from __future__ import annotations` to config_loader.py.
   The `tuple[Dict, str]` return type annotation on line 87 uses
   Python 3.9+ syntax, causing TypeError on Python 3.8 (e.g.
   Ubuntu 20.04 default). The future import enables modern type
   hint syntax on Python 3.7+.

2. Use CLAUDE_PROJECT_DIR env var for rule file discovery instead
   of a relative path. The previous `os.path.join('.claude', ...)`
   only found rules when cwd happened to be the project root.
   Now uses the CLAUDE_PROJECT_DIR environment variable set by
   Claude Code, falling back to cwd if unset.

Fixes anthropics#14588
Fixes anthropics#20749

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant