Skip to content

fix(hookify): search both project and home directories for rule files#29095

Open
4RH1T3CT0R7 wants to merge 1 commit intoanthropics:mainfrom
4RH1T3CT0R7:fix/hookify-load-home-rules
Open

fix(hookify): search both project and home directories for rule files#29095
4RH1T3CT0R7 wants to merge 1 commit intoanthropics:mainfrom
4RH1T3CT0R7:fix/hookify-load-home-rules

Conversation

@4RH1T3CT0R7
Copy link
Copy Markdown

Summary

  • load_rules() uses glob.glob('.claude/hookify.*.local.md') — a relative path from cwd
  • When Claude Code runs in a project directory (which is always), global rules in ~/.claude/ are silently ignored
  • Users creating rules in ~/.claude/hookify.*.local.md see them never loaded

Changes

  • plugins/hookify/core/config_loader.py lines 209-211: search both project-level (.claude/) and home-level (~/.claude/) directories
  • Deduplicate by os.path.abspath() to handle the edge case where cwd is the home directory

Test plan

  • Create ~/.claude/hookify.test-global.local.md with a valid rule
  • Run hookify from a project directory (cwd != home)
  • Verify the global rule is loaded and evaluated
  • Create same-named file in both ~/.claude/ and <project>/.claude/ — verify loaded only once
  • Run from home directory — verify no duplicate loading

Fixes #20749

glob.glob with a relative path only searched the current working
directory. Users with global rules in ~/.claude/hookify.*.local.md
would have them silently ignored when cwd was a project directory
(which is always the case in normal Claude Code usage).

Add a second search for ~/.claude/ and deduplicate by absolute path
to handle the edge case where cwd is the home directory.

Fixes anthropics#20749
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.

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

1 participant