claude-code - 💡(How to fix) Fix Agent worktree isolation fails on Windows due to case-insensitive path mismatch [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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#45121Fetched 2026-04-09 08:12:46
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×4commented ×1

Error Message

  1. Observe the error despite being in a valid git repo

Root Cause

Case mismatch between shell working directory and git's reported toplevel:

$ pwd
/x/dev/growgeneration

$ git rev-parse --show-toplevel
X:/Dev/GrowGeneration

The Agent tool's git repository detection appears to do a case-sensitive path check, which fails on Windows (case-insensitive filesystem).

Fix Action

Workaround

Set workflow.use_worktrees to false and run agents sequentially.

Code Example

Cannot create agent worktree: not in a git repository and no WorktreeCreate hooks are configured.

---

$ pwd
/x/dev/growgeneration

$ git rev-parse --show-toplevel
X:/Dev/GrowGeneration
RAW_BUFFERClick to expand / collapse

Bug Description

isolation: "worktree" in the Agent tool fails on Windows with:

Cannot create agent worktree: not in a git repository and no WorktreeCreate hooks are configured.

The repository is valid — git status, git worktree list, and git push all work correctly.

Root Cause

Case mismatch between shell working directory and git's reported toplevel:

$ pwd
/x/dev/growgeneration

$ git rev-parse --show-toplevel
X:/Dev/GrowGeneration

The Agent tool's git repository detection appears to do a case-sensitive path check, which fails on Windows (case-insensitive filesystem).

Environment

  • OS: Windows 11 Home 10.0.26200
  • Shell: Git Bash (MSYS2)
  • Drive: X:\ (mapped/external drive)
  • Claude Code version: Latest (auto-updates enabled)
  • Model: claude-opus-4-6

Steps to Reproduce

  1. Open Claude Code on Windows in a git repository on a non-C: drive
  2. Use the Agent tool with isolation: "worktree"
  3. Observe the error despite being in a valid git repo

Expected Behavior

Git repository detection should use case-insensitive path comparison on Windows, or normalize paths before comparing.

Workaround

Set workflow.use_worktrees to false and run agents sequentially.

extent analysis

TL;DR

To fix the issue with the Agent tool's isolation: "worktree" on Windows, consider modifying the path comparison to be case-insensitive or normalizing paths before comparison.

Guidance

  • Verify that the issue is indeed caused by a case mismatch between the shell working directory and git's reported top-level directory by checking the output of pwd and git rev-parse --show-toplevel.
  • Check if setting workflow.use_worktrees to false and running agents sequentially is a viable workaround for your specific use case.
  • Consider modifying the Agent tool's git repository detection to use case-insensitive path comparison on Windows.
  • Test the workaround or fix in a controlled environment before applying it to production.

Example

No explicit code example is provided as the issue does not specify the programming language or implementation details of the Agent tool.

Notes

The provided workaround may have performance implications or limitations, such as reduced parallelism, and should be evaluated carefully.

Recommendation

Apply the workaround by setting workflow.use_worktrees to false and running agents sequentially, as this is a relatively simple and safe change that can mitigate the issue until a more permanent fix is implemented.

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