Evertusk

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:

ApproachKeepsGood forWatch out for
Raise cleanupPeriodDaysEverything, for as long as you setNever losing a sessionMore secrets sitting in plain text
Copy the files yourselfWhatever you copyA one-off backupEasy to miss subagents and images
Save in EvertuskThe sessions you choose, with subagents and imagesKeeping only what mattersMac only, and you have to save before the cleanup

How do I read an old Claude Code session?

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.