[BUG] Project settings.json not found in bare repo + worktree setup
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?
In a bare repo + worktree setup, Claude Code does not find .claude/settings.json in the worktree directory. On session start, hooks defined in the project-level settings produce an error that "hooks were meant to have an array but were undefined".
The worktree's .git file contains:
gitdir: /path/to/repo/.bare/worktrees/my-worktree
Claude Code appears to resolve the project root by following the gitdir pointer back to the bare repo parent directory, rather than using the worktree directory itself. Since .claude/settings.json lives in the worktree (checked into git), it is never found.
What Should Happen?
Claude Code should resolve the project root to the worktree directory (equivalent to git rev-parse --show-toplevel), so that .claude/settings.json checked into the repo is found and hooks are loaded.
Steps to Reproduce
- Set up a bare repo with worktrees:
``bash``
git clone --bare git@github.com:user/repo.git repo/.bare
echo "gitdir: .bare" > repo/.git
git worktree add repo/my-worktree my-branch
- Ensure
.claude/settings.jsonexists in the repo with aSessionStarthook:
``json``
{
"hooks": {
"SessionStart": [
{
"type": "command",
"command": "echo hello"
}
]
}
}
cd repo/my-worktree && claude- Observe error about hooks being undefined
Prior Issues
This was previously reported as #27994, which was auto-closed as a duplicate of #27343. #27343 was then auto-closed on 2026-03-21 without a fix.
Environment
- Claude Code version: 2.1.79
- OS: Fedora Linux (6.17.7)
- Shell: bash
This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗