RFE: Allow session cwd relocation when remote machine is no longer available

Status Fixed / completed
Maintainer reply None cached
Activity 3 comments · opened May 22, 2026 · closed May 22, 2026

Problem

When a Claude Code session was started over SSH and the remote machine is permanently decommissioned, the session becomes non-re-entrant on the host machine. The cwd (e.g. /home/duncan/Projects/02-crash-forensics) is embedded in every record of the session JSONL. Claude Code validates the cwd on open, so even though the full transcript is stored locally the session cannot be resumed.

There is currently no built-in path to recover from this. The manual workaround requires finding the JSONL in ~/.claude/projects/ssh-{id}/, creating a new local project directory, and doing a raw string replacement across ~229 records — error-prone and undocumented.

Proposed solution

When Claude Code detects that a session's cwd does not exist at open time, offer one of:

  1. Prompt to relocate — ask the user for a new local working directory, update the session metadata going forward (without rewriting history)
  2. Read-only fallback — open the session in transcript-view mode so the history is accessible even if the cwd is unreachable
  3. Session export/migrate command — a first-class CLI option (claude session migrate <id> --cwd <new-path>) that handles the JSONL rewrite safely

Context

  • Session file: ~/.claude/projects/ssh-{sessionId}/{sessionId}.jsonl
  • The cwd field appears in user, assistant, and queue-operation record types
  • Only the structural cwd fields need updating; cwd mentions in message content are benign

Related: #61111 (local processes spawned with remote cwd), #58701 (SSH session showing "No messages" after restart)

View original on GitHub ↗

3 Comments

github-actions[bot] · 4 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/58591
  2. https://github.com/anthropics/claude-code/issues/61349
  3. https://github.com/anthropics/claude-code/issues/54791

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

eamondowling · 4 months ago

Duplicate of #58591 which covers the core --cwd fix. Closing in favour of that issue.

One angle not covered there: the cross-platform case — session started on a Linux SSH remote, machine decommissioned, resuming locally on Windows. The JSONL copy workaround requires not just a path copy but a content transformation (Linux forward-slash paths -> JSON-escaped Windows backslash paths). Flagging this on #58591.

github-actions[bot] · 3 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.