[Feature Request] Resolve hooks from nearest .claude/settings.json relative to edited file
Problem
When Claude Code is launched from a parent repository that contains git submodules, only the root project's .claude/settings.json hooks are applied. Hooks defined in submodule .claude/settings.json files are ignored, even when editing files within those submodules.
Example
parent-repo/ # Claude Code launched here
├── .claude/settings.json # ← Hooks from here are applied
└── packages/
└── my-app/ # Git submodule with its own project config
└── .claude/
└── settings.json # ← PostToolUse hooks defined here are ignored
If packages/my-app/.claude/settings.json defines a PostToolUse hook (e.g., running a formatter after file edits), it does not execute when Claude Code edits files under packages/my-app/.
Why this matters
- A parent repository may aggregate shared context (CLAUDE.md, project metadata) that benefits all subprojects
- Launching Claude Code from each submodule directory works for hooks but loses this shared context
- Workarounds like duplicating hooks in the parent or adding path-matching logic in shell commands are fragile and don't scale
Proposed solution
When a hook event fires for a specific file (e.g., PostToolUse after Edit/Write), resolve hooks by walking up from the edited file's directory to find the nearest .claude/settings.json, and apply its hooks in addition to the root project's hooks.
This would be consistent with how CLAUDE.md files are already resolved from nested directories.
Environment
- Claude Code version: 2.1.47
- Platform: macOS Darwin 24.5.0
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗