[BUG] Project settings hooks not loaded when working directory is a subdirectory of the repo

Resolved 💬 4 comments Opened Mar 20, 2026 by KCErb Closed May 30, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Hooks defined in .claude/settings.json (project settings) are not loaded when Claude Code is started from a subdirectory of the git repository. They only load when cwd is the repo root.

/hooks shows 0 hooks when started from a subdirectory, but shows the correct hooks when started from the repo root. The hooks simply don't exist in the subdirectory session — they never fire.

What Should Happen?

Claude Code should resolve project settings by walking up to the git root, finding .claude/settings.json, and loading hooks regardless of which subdirectory within the repo is the working directory. This is consistent with how CLAUDE.md files are resolved.

Error Messages/Logs

Steps to Reproduce

# 1. Create a minimal repo
mkdir hook-repro && cd hook-repro && git init
mkdir subdir
echo "hello" > file.txt
echo "hello" > subdir/file.txt

# 2. Add a trivial blocking hook
mkdir .claude
cat > .claude/settings.json << 'EOF'
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "echo 'HOOK FIRED' >&2; exit 2"
          }
        ]
      }
    ]
  }
}
EOF

git add -A && git commit -m "init with hook"

# 3. Test from repo root — WORKS
cd ~/hook-repro
claude --dangerously-skip-permissions -p \
  "Run /hooks and report PreToolUse hook count. Then read file.txt and try to edit it to say 'modified'. Report what happened."
# Result: /hooks shows 1 hook. Edit is BLOCKED. ✅

# 4. Test from subdirectory — FAILS
cd ~/hook-repro/subdir
claude --dangerously-skip-permissions -p \
  "Run /hooks and report PreToolUse hook count. Then read file.txt and try to edit it to say 'modified'. Report what happened."
# Result: /hooks shows 0 hooks. Edit SUCCEEDS. ❌

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

confirmed working ~March 6, 2026

Claude Code Version

2.1.80

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

This affects any workflow where users start Claude Code sessions in domain-specific subdirectories (e.g. cd scheduler && claude). Project-level hooks intended to enforce policies (like requiring worktrees before editing on main) silently stop working, with no indication that hooks failed to load.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗