Edit tool silently writes to main repo instead of worktree when path contains brackets

Resolved 💬 3 comments Opened Mar 20, 2026 by brewerfansoftball Closed Mar 23, 2026

Bug

When working in a git worktree, the Edit tool silently writes to files in the main repo instead of the worktree when the file path contains SvelteKit bracket segments (e.g. [code], [department]).

The tool reports success, but the worktree file is unchanged. The edit lands in the main repository's working tree instead.

Reproduction

  1. Create a git worktree (e.g. via the Agent tool with isolation: "worktree", or manually)
  2. Use the Edit tool to modify a file whose path contains brackets, e.g.:

``
N:\OneDrive\project\.claude\worktrees\some-worktree\src\routes\join\[code]\+page.server.ts
``

  1. Edit tool reports: "The file has been updated successfully."
  2. Run git diff in the worktree — no changes
  3. Run git diff in the main repo — the edit landed there instead

Expected behavior

The Edit tool should modify the file at the exact path provided (in the worktree), or fail with an error if it cannot.

Actual behavior

The Edit tool silently resolves the path to the main repo copy and edits that instead. No error or warning is emitted.

Environment

  • Platform: Windows 11 Pro (win32)
  • Shell: bash
  • Model: claude-opus-4-6
  • Worktree path: N:\OneDrive\...\skipper\.claude\worktrees\bridge-cse_012quDiG8pwf99XJrFgcUdJy
  • Affected file path segment: src\routes\join\[code]\+page.server.ts

Impact

This can cause silent data loss or incorrect commits if the worktree is on a different branch than the main repo. In my case the worktree happened to be on the same commit as master, so the edits coincidentally landed in the right place — but this was luck, not correctness.

View original on GitHub ↗

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