claude-code - 💡(How to fix) Fix /resume loses sessions in containers due to PID-keyed session index [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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…
GitHub stats
anthropics/claude-code#47128Fetched 2026-04-13 05:40:43
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
1
Author
Participants
Timeline (top)
labeled ×4

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.

RAW_BUFFERClick to expand / collapse

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

  1. Run Claude Code inside a devcontainer with ~/.claude bind-mounted from the host
  2. Have a conversation, exit
  3. Rebuild/restart the container
  4. Run Claude Code again, use /resume
  5. 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
  • ~/.claude bind-mounted: source=${localEnv:HOME}/.claude,target=/home/vscode/.claude,type=bind,consistency=cached
  • Linux (WSL2)

extent analysis

TL;DR

Use session UUID as the filename for session metadata instead of PID to prevent overwriting of session metadata files after container restarts.

Guidance

  • Identify the current session metadata file naming convention and consider modifying it to use a unique identifier, such as the session UUID, to prevent overwrites.
  • Review the session metadata file storage location (~/.claude/sessions/) and consider implementing a backup or versioning system to prevent data loss in case of overwrites.
  • Investigate the possibility of maintaining a separate index that maps session UUIDs to their corresponding metadata files, allowing for easy retrieval of previous sessions.
  • Verify that the actual session conversation data (JSONL files in ~/.claude/projects/) remains intact and unaffected by the container restarts.

Example

// Example session metadata file with UUID as filename
{
  "uuid": "session-123",
  "pid": 8743,
  "project": "example-project",
  "conversation": "example-conversation.jsonl"
}

Notes

The suggested fix requires modifications to the Claude Code application to use a unique identifier for session metadata files. This change may require updates to the application's logic for storing and retrieving session metadata.

Recommendation

Apply workaround by modifying the session metadata file naming convention to use the session UUID instead of PID, as this will prevent overwrites and ensure that previous sessions are retained after container restarts.

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