claude-code - 💡(How to fix) Fix [FEATURE] Fork session in agents TUI to decouple new sessions from the working directory of prior sessions

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fix / Workaround

Workarounds today (manually cd-ing, re-launching from a specific directory) defeat the point of the TUI as a session manager, and the problem compounds the more worktrees you have in flight.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

Problem Statement

I use claude agents heavily alongside git worktrees, and the agents TUI has a working-directory drift problem that makes chaining work on the same project painful.

When I launch a session from the agents TUI, every subsequent session I start gets created in the same working directory as the previous one. That directory is often a worktree path. When the worktree is eventually cleaned up (git worktree remove), the pwd anchor disappears and the TUI's idea of "where new sessions go" resets, losing the project context I was working in.

A typical flow:

  1. From the agents TUI, I start a session in ~/code/myproject/.worktrees/feature-a.
  2. I start another session from the TUI — it inherits ~/code/myproject/.worktrees/feature-a.
  3. I finish feature-a, merge, and git worktree remove it.
  4. The next session I start from the TUI no longer has a coherent working directory tied to my project. I have to manually re-establish context, even though I'm still working on the same project.

The root issue: "where the new session starts" is implicitly chained to "where the previous session was running," with no user-facing control over that relationship — and the chain breaks silently when a worktree is cleaned up.

Proposed Solution

Add an explicit fork session action to the agents TUI. Forking a session would create a new session that:

  • Inherits the parent session's working directory at the moment of the fork, captured as an explicit value rather than a live reference to the parent.
  • Optionally inherits other parent context (env, model, agent config) — open to discussion on which of these make sense as defaults.
  • Is independent of the parent's lifecycle from that point forward. If the parent's working directory is later deleted, the forked session keeps its own captured path (or falls back cleanly to the project root) rather than drifting.

Surface this as a keybinding in the agents TUI (e.g. f on a selected session, or a menu entry like "Fork session here"). CLI parity would also be welcome — something like claude agents fork <session-id>.

Alternative Solutions

No response

Priority

Critical - Blocking my work

Feature Category

CLI commands and flags

Use Case Example

Beyond the worktree scenario that prompted this:

  • Worktree workflows — start parallel sessions per feature branch from a shared parent, without each new session re-anchoring to wherever the last one happened to run.
  • Branching exploration — fork at a known-good point to try a different approach without disturbing the original session.
  • Template sessions — set up a session with the right cwd and agent config, then fork it repeatedly as the starting point for similar tasks.
  • Long-running projects — keep a stable "home" session and fork short-lived task sessions from it, so cleanup of any one task session doesn't affect the others.

Additional Context

The mental-model shift is that sessions in the TUI should be independently anchored, not implicitly chained through whatever the last session set. Fork makes the inheritance explicit and opt-in rather than implicit and unavoidable.

Workarounds today (manually cd-ing, re-launching from a specific directory) defeat the point of the TUI as a session manager, and the problem compounds the more worktrees you have in flight.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [FEATURE] Fork session in agents TUI to decouple new sessions from the working directory of prior sessions