Where Claude Code stores your session history, and when it deletes it
Claude Code saves each session as a plain-text JSONL file in ~/.claude/projects/. By default it deletes those files after 30 days, without showing a message. You can change that with the cleanupPeriodDays setting, but only for sessions that still exist.
Where are Claude Code sessions stored?
Each project gets a folder under ~/.claude/projects/, named after the project's path with its separators replaced by dashes. Each session is one file in that folder:
~/.claude/projects/-Users-alex-code-checkout-api/
8f3c1e2a-….jsonl the conversation
8f3c1e2a-…/subagents/ transcripts of agents it started
8f3c1e2a-…/tool-results/ large tool output, saved separately Every line of a transcript is one JSON record: your message, Claude's reply, a tool call or its result. Anthropic's directory reference lists these files and notes that they're plaintext, so anything that passed through a tool is in there, including file contents and command output.
Does Claude Code delete old sessions?
Yes. The cleanupPeriodDays setting defaults to 30. Claude Code runs the deletion as a background sweep after a session starts, and the docs say it doesn't show a message when it does.
This is easy to miss. On the Mac this app is built on, which has never changed the setting, no transcript in ~/.claude/projects is older than 31 days, even after months of daily use.
Subagent transcripts are removed along with their parent session. Anthropic has defended the default on security grounds, since transcripts can contain source code and credentials. That is a real tradeoff to weigh before keeping everything forever.
How do I keep Claude Code sessions for longer?
Set a higher number of days in ~/.claude/settings.json. It has to be a whole number of at least 1:
{
"cleanupPeriodDays": 365
} This only protects sessions that haven't been deleted yet, and it keeps everything rather than the sessions you care about. Your options, side by side:
| Approach | Keeps | Good for | Watch out for |
|---|---|---|---|
Raise cleanupPeriodDays | Everything, for as long as you set | Never losing a session | More secrets sitting in plain text |
| Copy the files yourself | Whatever you copy | A one-off backup | Easy to miss subagents and images |
| Save in Evertusk | The sessions you choose, with subagents and images | Keeping only what matters | Mac only, and you have to save before the cleanup |
How do I read an old Claude Code session?
- In Claude Code:
claude --resumeopens a picker of past sessions, in the folder you run it from. It's built for continuing a session rather than searching your history. - As raw files: open the JSONL directly, or use
grepacross~/.claude/projects. This works, but a long session runs to many megabytes of JSON, and the format isn't documented, so it can change between versions. - In a viewer: Evertusk lists every session across projects, searches every message, and shows thinking, tool calls, subagents, pasted images and every file changed.
Can I get a deleted Claude Code session back?
Usually not. Once the sweep removes a transcript, Claude Code has no copy of it. Your only chance is a backup, such as Time Machine, taken while the file existed. To check, look in the same project folder in your backup.