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)
3 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Duplicate of #58591 which covers the core
--cwdfix. 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.
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.