/resume loses sessions in containers due to PID-keyed session index
Description
When running Claude Code inside a devcontainer (or any container) with ~/.claude bind-mounted from the host, the /resume command fails to show most previous sessions after container restarts.
Root Cause
Session metadata files in ~/.claude/sessions/ are named by PID (e.g., 8743.json). When a container restarts, the PID namespace resets. New processes can be assigned the same PIDs, causing their session metadata files to overwrite the old ones. This destroys the mapping from PID → session UUID, making those sessions invisible to /resume.
The actual session conversation data (JSONL files in ~/.claude/projects/) is intact and unaffected — only the index is lost.
Steps to Reproduce
- Run Claude Code inside a devcontainer with
~/.claudebind-mounted from the host - Have a conversation, exit
- Rebuild/restart the container
- Run Claude Code again, use
/resume - The session from step 2 is missing from the list
Expected Behavior
All previous sessions for the current project should appear in /resume, regardless of container restarts.
Suggested Fix
Consider using session UUID as the filename for session metadata instead of PID, or maintain a separate index that isn't tied to ephemeral PIDs. The PID can still be stored inside the file for detecting active sessions.
Environment
- Claude Code in VS Code devcontainer
~/.claudebind-mounted:source=${localEnv:HOME}/.claude,target=/home/vscode/.claude,type=bind,consistency=cached- Linux (WSL2)
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗