[BUG] Project settings.json not found in bare repo + worktree setup

Resolved 💬 8 comments Opened Mar 28, 2026 by rtibbles Closed Jun 1, 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?

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

  1. 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
``

  1. Ensure .claude/settings.json exists in the repo with a SessionStart hook:

``json
{
"hooks": {
"SessionStart": [
{
"type": "command",
"command": "echo hello"
}
]
}
}
``

  1. cd repo/my-worktree && claude
  2. 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

View original on GitHub ↗

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