session created a worktree but agent later edited/committed in the repo's main checkout
Environment: Claude Code desktop app (macOS), Opus 4.8, session running in a .claude/worktrees/ worktree.
What happened
The session ran in a .claude/worktrees/ worktree for repo A (correctly). The task then required Terraform changes in a second repo configured as an additional working directory. The agent edited files and attempted to create a branch and commit directly in that second repo's primary checkout, on main, instead of creating a worktree there as well.
I had to intervene mid-turn ("You're making commits on main… and not the worktree, again"). This is a recurring pattern for me across sessions — the worktree convention gets applied to the session's primary repo but not to other repos the agent touches.
Expected behavior
When the harness establishes a worktree-based workflow for a session, the agent should extend that convention to any repo it commits to — especially additional working directories, since the primary checkout there is the user's live working copy (dirty state, stashes, the checked-out branch all belong to the user).
Notes
After the intervention, the agent recovered cleanly (moved the uncommitted diff into a new .claude/worktrees/<name> worktree, restored the main checkout, committed/pushed from the worktree), so the capability is there — it's the default behavior that's wrong.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗