Claude Code deletes your sessions after 30 days. Here's how to keep them, and find any old one
Every conversation you have with Claude Code is saved on your disk: the reasoning, the dead ends, the exact command that finally worked. Most people never look at those files. Then one day they need a fix from a month ag
Every conversation you have with Claude Code is saved on your disk: the reasoning, the dead ends, the exact command that finally worked. Most people never look at those files. Then one day they need a fix from a month ago, and it is gone.
TL;DR
- Claude Code deletes transcripts after 30 days of inactivity by default. One line in
settings.jsonstops that. - Your sessions live in
~/.claude/projects/, one JSON Lines file per session. - Three small shell functions below let you find a session by any word said in it, and resume it from anywhere.
First, check that your old sessions still exist
Claude Code deletes transcripts after 30 days of inactivity by default. If you want to be able to go back to a session from three months ago, raise the limit in ~/.claude/settings.json:
{
"cleanupPeriodDays": 3650
}
That keeps about ten years. Do it now: the cleanup runs every time Claude Code starts, and a deleted session can't be resumed. It takes ten seconds and it is the most useful thing in this article.
Where the files are
~/.claude/projects/<project folder>/<session id>.jsonl
-
~/.claudeis the default. If you setCLAUDE_CONFIG_DIR(for example to keep a work and a personal account apart), each account has its ownprojects/folder under that directory, and its own history. -
<project folder>is the path where you startedclaude, with slashes turned into dashes:/home/me/code/apibecomes-home-me-code-api. -
<session id>is the UUID thatclaude --resumeexpects.
Subagents get their own files next to the session:
~/.claude/projects/<project folder>/<session id>/subagents/agent-<id>.jsonl
That is why their work never shows up when you scroll back through the main conversation.
What is inside
Each file is JSON Lines: one JSON object per line, with a type. The ones you care about:
-
userandassistant: the messages, withcwd(the folder),timestampandgitBranch; -
ai-title: the short title Claude Code generated for the session.
The format is not documented and changes between versions, so treat everything below as handy recipes, not an API.
Find a session by what was said in it
The resume picker lists sessions by title and date. When all you remember is a word from the conversation, grep is faster:
# Sessions that mention a word, newest first
cc-find() {
grep -l -i -- "$1" ~/.claude/projects/*/*.jsonl 2>/dev/null | xargs -r ls -t | head -20
}
cc-find "refresh token"
You get file paths; the file name is the session id.
To see the title of each match:
cc-titles() {
for f in $(cc-find "$1"); do
printf '%s %s\n' "$(basename "$f" .jsonl)" \
"$(grep -o '"aiTitle":"[^"]*"' "$f" | tail -1 | cut -d'"' -f4)"
done
}
Resume it from anywhere
A session belongs to the folder it was started in, and claude --resume <id> looks for it from the current folder. So go there first. The folder is in the file:
# cc-resume <path/to/session.jsonl>
cc-resume() {
local f=$1 id cwd
id=$(basename "$f" .jsonl)
cwd=$(grep -m1 -o '"cwd":"[^"]*"' "$f" | cut -d'"' -f4)
(cd "$cwd" && claude --resume "$id")
}
Two more built-ins worth knowing:
-
claude --continueresumes the most recent session of the current folder. -
/resumeinside Claude Code opens the picker, which is great when you remember roughly when and where.
Where this stops being enough
The recipes above work, until they don't:
- they print raw JSON, so you still can't read the conversation before resuming it;
- they look at one account at a time, unless you loop over every
CLAUDE_CONFIG_DIR; - subagents stay invisible, even when they did half the work.
I hit all three every week, so I built Jumpback: the same idea, with a window.
- Type a word, see the conversation. Full-text search across every account takes 7 ms on my whole history, on a 2014 laptop.
- Read before you resume. Tool calls are folded away, and each subagent appears on its own lane, right where it was called.
-
Enterand you are back in, in your terminal, in the right folder, with the account that owns the session. - It can't break anything. It never writes to these files, opens no network port, and sends nothing anywhere.
It is free and open source, and installs on Debian, Ubuntu, Mint or Pop!_OS with one command. Get it here, and if it saves you a session, a star on GitHub helps other Claude Code users find it.
But even if you never install it: set cleanupPeriodDays today. Future you will thank you.
How do you find old sessions today? Drop your trick in the comments: I'll add the best ones to this article.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.