Edit tool silently writes to main repo instead of worktree when path contains brackets
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
- Create a git worktree (e.g. via the Agent tool with
isolation: "worktree", or manually) - 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
- Edit tool reports: "The file has been updated successfully."
- Run
git diffin the worktree — no changes - Run
git diffin 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗