[FEATURE] Allow /branch and --resume to target a different working directory or worktree

Resolved 💬 2 comments Opened May 22, 2026 by Shaik-Sirajuddin Closed May 25, 2026

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

The /branch and --resume commands do not accept a target directory. Both always inherit or resume into the same working directory the session was started in. There is no way to branch or resume a session into a different directory or git worktree.

Proposed Solution

Add an optional --dir (or positional) argument to both commands:

  • /branch --dir ../other-worktree → forks the session context into a new session rooted at that path
  • claude --resume <id> --dir ../other-worktree → resumes the session but operates from the target directory

Use Case

A common agent workflow:

  1. Agent builds up significant context working on a feature in the current directory
  2. User wants to continue related work in a new git worktree (different branch, isolated environment)
  3. Currently impossible — must start a cold session in the new worktree, losing all accumulated context
  4. With --dir support: branch the session, point it at the new worktree, agent continues with full context intact

Alternative Solutions

Currently the only workaround is to open a new terminal in the target directory and start a fresh cold session, losing all agent context.

Priority

Medium - impacts agent-heavy and worktree-heavy workflows

Feature Category

CLI commands and flags

Additional Context

Distinction from #60272: Issue #60272 is about fixing working-directory drift in the agents TUI when worktrees are cleaned up. This request is specifically about /branch and --resume CLI commands not supporting a target directory at all — a gap that affects any user doing parallel feature development with git worktrees.

View original on GitHub ↗

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