RFE: Allow session cwd relocation when remote machine is no longer available
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:
- Prompt to relocate — ask the user for a new local working directory, update the session metadata going forward (without rewriting history)
- Read-only fallback — open the session in transcript-view mode so the history is accessible even if the cwd is unreachable
- 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
cwdfield appears inuser,assistant, andqueue-operationrecord types - Only the structural
cwdfields 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)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗