claude-code - ๐Ÿ’ก(How to fix) Fix [Bug] Settings discovery doesn't walk to git root, causing WorktreeCreate hooks to be silently skipped from subdirectories [1 comments, 2 participants]

Official PRs (โ€ฆ)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful ยท Quick feedback

Loadingโ€ฆ
GitHub stats
anthropics/claude-code#55973โ€ขFetched 2026-05-05 06:01:29
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ร—4closed ร—1commented ร—1

Error Message

Impact: Custom worktree setups (DB, infra, etc.) get silently bypassed. No warning, no error โ€” the user

Code Example

[]
RAW_BUFFERClick to expand / collapse

Bug Description Bug: claude --worktree silently skips project-level WorktreeCreate hook when launched from a subdirectory

Claude Code's .claude/settings.json discovery is CWD-only โ€” it does not walk up to the git root. This produces an inconsistency with worktree creation, which does resolve the git root for the default worktree path.

Repro:

  1. Project at ~/repo with ~/repo/.claude/settings.json defining a WorktreeCreate hook.
  2. A subdirectory ~/repo/sub/.claude/settings.local.json exists (no hooks โ€” e.g., just MCP enables).
  3. cd ~/repo/sub && claude --worktree

Expected: WorktreeCreate hook from ~/repo/.claude/settings.json fires. Actual: Hook is silently skipped. Claude falls back to creating a worktree at ~/repo/.claude/worktrees/<random-name> (uses git root for path, but never loaded git-root settings).

Evidence (from --debug-file):

  • Launched from ~/repo: Watching for changes in setting files โ€ฆ, ~/repo/.claude/settings.json, ~/repo/.claude/settings.local.json
  • Launched from ~/repo/sub: Watching for changes in setting files โ€ฆ, ~/repo/sub/.claude/settings.json, ~/repo/sub/.claude/settings.local.json (project-root settings never loaded โ†’ Hooks: Found 0 total hooks in registry)

Impact: Custom worktree setups (DB, infra, etc.) get silently bypassed. No warning, no error โ€” the user just discovers later that their environment isn't provisioned.

Suggested fix: Settings discovery should walk up to the git root (or $CLAUDE_PROJECT_DIR), matching the resolution Claude already performs for the default worktree path. At minimum, log a warning when launching --worktree and a project-root .claude/settings.json exists above CWD but isn't loaded.

Version: 2.1.126 (native).

Environment Info

  • Platform: darwin
  • Terminal: iTerm.app
  • Version: 2.1.126
  • Feedback ID: 3ac85329-637e-4e3e-ab2a-9396887b85b6

Errors

[]

extent analysis

TL;DR

The issue can be fixed by modifying the settings discovery to walk up to the git root, ensuring that project-level WorktreeCreate hooks are loaded when launching claude --worktree from a subdirectory.

Guidance

  • The current implementation of settings discovery in Claude only checks the current working directory (CWD), which causes the WorktreeCreate hook to be skipped when launched from a subdirectory.
  • To verify the issue, compare the behavior of launching claude --worktree from the project root versus a subdirectory, checking if the WorktreeCreate hook is fired as expected.
  • A potential workaround is to launch claude --worktree from the project root directory, ensuring that the project-level settings are loaded.
  • Consider adding a warning log when launching claude --worktree and a project-root .claude/settings.json exists above CWD but isn't loaded, to alert users of potential issues.

Example

No code snippet is provided as the issue is related to the internal implementation of Claude's settings discovery.

Notes

The suggested fix requires modifying the settings discovery mechanism in Claude to walk up to the git root, which may involve changes to the underlying codebase.

Recommendation

Apply workaround: launch claude --worktree from the project root directory to ensure that project-level settings are loaded, until a permanent fix is implemented to modify the settings discovery mechanism.

Vote matrix ยท Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loadingโ€ฆ

Still need to ship something?

ร—6

Another batch ranked right after the header list โ€” different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - ๐Ÿ’ก(How to fix) Fix [Bug] Settings discovery doesn't walk to git root, causing WorktreeCreate hooks to be silently skipped from subdirectories [1 comments, 2 participants]