Skip to content

Hookify fails to load rules if current working directory is not HOME #20749

@santiagolgzz

Description

@santiagolgzz

Summary

The Hookify plugin fails to discover and load rule files (.claude/hookify.*.local.md) if Claude Code is executed from a directory other than the user's home directory (or wherever the .claude folder is located).

Root Cause

In plugins/hookify/core/config_loader.py, the load_rules function uses a relative path to search for rule files:

# Find all hookify.*.local.md files
pattern = os.path.join('.claude', 'hookify.*.local.md')
files = glob.glob(pattern)

Since glob.glob with a relative path starts from the current working directory, it will only find the rules if the user is currently in their home directory.

Proposed Fix

The path should be absolute, typically pointing to the user's home directory:

# Find all hookify.*.local.md files
# Use absolute path to ~/.claude/ so it works from any working directory
claude_dir = os.path.join(os.path.expanduser('~'), '.claude')
pattern = os.path.join(claude_dir, 'hookify.*.local.md')
files = glob.glob(pattern)

Impact

Hooks configured via Hookify silently stop working as soon as the user cds into a project subdirectory or any other location outside of where the .claude folder was initially found. This leads to inconsistent enforcement of rules.

Tested

I confirmed this by running a Hookify hook while in a subdirectory; the hook failed to fire. After applying the absolute path fix, the hook fires correctly regardless of the current working directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsstaleIssue is inactive

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions