How to recover a deleted Claude Code session
four reasons a session is missing from claude --resume, three of which are not deletion
claude --resume builds its list from the files on disk, so a session missing from it means the file is missing from where Claude Code looked. That is not the same as gone, and it is worth ruling out the three cheap explanations before accepting the expensive one.
Was it deleted, or is it somewhere else
Four causes, in the order they actually happen:
- The 30-day sweep.
cleanupPeriodDaysin~/.claude/settings.jsondefaults to 30 days and removes older transcripts, with nothing announcing it. If that is what happened, the file is gone — see what the sweep does. - The project moved or was renamed. A directory under
~/.claude/projectsencodes the project's absolute path, with separators and literal hyphens both turned into-. Rename the repository and the old sessions stay under the old encoded name;--resumein the new path has nothing to list. - A different config directory.
CLAUDE_CONFIG_DIRset in one shell and not in another splits your history into two trees. - A headless or SDK session. Those write under
<config>/transcripts/rather thanprojects/, and Xcode-hosted Claude writes under~/Library/Developer/Xcode/CodingAssistant/ClaudeAgentConfig.
Finding the file
# every transcript tree, by newest file find ~/.claude -name '*.jsonl' -type f -print0 | xargs -0 ls -t | head # the project directories, to spot the encoded old path ls ~/.claude/projects | grep -i <repo-name> # by session id, if you have it from a log or a screenshot grep -rl '<session-id>' ~/.claude 2>/dev/null
If the file turns up under an old encoded directory, moving it into the current one puts the session back in --resume: the list is the directory, not a database.
What is genuinely recoverable
If the file is gone, the honest list is short. A filesystem snapshot or backup taken while it existed. The Trash, if it was deleted from a file manager rather than with rm. And anything that read the transcript before it went.
That last one is the only reliable answer, and it has to be in place beforehand. deja indexes the transcripts every agent on this machine writes, so a session it has already read stays searchable after the original is swept or deleted — deja "what the session was about", then deja show <id> for the transcript it kept. Only deja forget drops one on purpose. There is no version of this that recovers a session nothing ever read.
curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh deja install --auto
The first index reads the history already on disk, so it covers the sessions you have now rather than starting from today.
Deleting sessions, and what it costs · Where every agent stores history · Resuming yesterday's session
Found this useful? Star deja-vu on GitHub.