Feature: switch working directory to existing worktree mid-session

Resolved 💬 3 comments Opened May 6, 2026 by sstraus Closed May 10, 2026

Summary

Claude Code supports --worktree at startup to create/use a git worktree, but there's no way to switch the working directory of an already-running session to an existing worktree.

Use Case

Terminal orchestrators (like TUICommander) create worktrees on behalf of the user via MCP while a Claude Code session is already running. The orchestrator can reassign the terminal in its UI, but Claude Code's internal CWD remains pinned to the original directory. The user must manually stop the session and start a new one in the worktree.

A mid-session worktree switch would allow seamless workflow:

  1. User (or orchestrator) creates a worktree for a new branch
  2. Running CC session receives a signal to switch its CWD to the worktree path
  3. CC continues working in the new directory without losing conversation context

Current Workaround

The orchestrator sends a text message to CC via PTY input telling it to stop and instruct the user to open a new session in the worktree. This loses conversation context.

Possible Approaches

  • A slash command: /cd /path/to/worktree or /worktree switch <path>
  • An MCP tool that CC exposes: switch_directory or enter_worktree
  • Reacting to an environment signal or IPC message from the terminal orchestrator

Environment

  • Claude Code v2.x
  • Worktree created externally (git CLI or orchestrator), not by CC's --worktree flag

View original on GitHub ↗

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