-
Notifications
You must be signed in to change notification settings - Fork 586
Open
Description
Bug Description
The hookify plugin's config_loader.py uses a relative path to find rule files, which fails because hooks execute from the plugin's cache directory, not the project directory.
Current Behavior
In core/config_loader.py line 210-211:
pattern = os.path.join('.claude', 'hookify.*.local.md')
files = glob.glob(pattern)This glob searches relative to the current working directory. When hooks run, the CWD is not the user's project directory, so no rule files are found.
Expected Behavior
The plugin should use CLAUDE_PROJECT_DIR environment variable (which is available to hook subprocesses) to construct an absolute path:
project_dir = os.environ.get('CLAUDE_PROJECT_DIR', '.')
pattern = os.path.join(project_dir, '.claude', 'hookify.*.local.md')
files = glob.glob(pattern)Steps to Reproduce
- Create a hookify rule file:
.claude/hookify.test-rule.local.md - Run
/hookify:list- the rule appears correctly - Trigger the rule (e.g., run a git commit that matches the pattern)
- The rule doesn't fire because
load_rules()finds no files
Environment
- Claude Code version: Latest
- Hookify plugin version: 0.1.0
- OS: macOS
Suggested Fix
Update load_rules() in core/config_loader.py:
def load_rules(event: Optional[str] = None) -> List[Rule]:
"""Load all hookify rules from .claude directory."""
rules = []
# Use CLAUDE_PROJECT_DIR when available (hook execution context)
project_dir = os.environ.get('CLAUDE_PROJECT_DIR', '.')
pattern = os.path.join(project_dir, '.claude', 'hookify.*.local.md')
files = glob.glob(pattern)
# ... rest of functionThis change ensures rules are found whether the code runs from the project directory or from a hook subprocess.
Metadata
Metadata
Assignees
Labels
No labels