← ClaudeAtlas

worktree-cwdlisted

Use when ExitWorktree refuses with a cwd-override error and the branch still needs merging. Merge by ref with git -C from inside the worktree; a merge needs no navigation.
MrBinnacle/skills · ★ 0 · Code & Development · score 65
Install: claude install-skill MrBinnacle/skills
# ExitWorktree cwd-override: merge from inside the worktree with `git -C` ## Problem You called `EnterWorktree(name="my-feature")` to set up an isolated branch. The harness moved your session's working directory into `.claude/worktrees/my-feature` on branch `worktree-my-feature`. You dispatched a subagent, the work landed, you ran reviews, and now you want to ExitWorktree(action="keep") to return to main so you can fast-forward main to the new commits. `ExitWorktree` refuses: ``` ExitWorktree cannot be called from a subagent with a cwd override (isolation: "worktree" or explicit cwd) — it would mutate the parent session's process-wide working directory. ``` You're stuck: you can't exit; you can't change directory from inside the tool calls; the merge command appears to require being on the target branch. ## Root cause `ExitWorktree`'s job is to revert the session's working directory. In some harness configurations (notably when the session itself was launched with a cwd override, or after EnterWorktree has nested-overridden the cwd), the tool can't safely mutate the process-wide cwd back. It refuses rather than corrupt parent state. But the BLOCKER assumed by the error message — "I need to be on main to merge into main" — is wrong for `git merge`. Git operates on branch REFS, not on working directory state. You can merge into main from anywhere as long as you tell git which repo to operate on. ## Fix Use `git -C "<path-to-main-repo>"` to invoke git as if you were in