Claude Code deletes your sessions after 30 days

Updated 8 October 2026 · for the Claude Code command line (version 2.1.294) on macOS

Claude Code removes old sessions on its own. By default, once a session is older than 30 days, its transcript, its scratchpad and the images you pasted into it are deleted together. You can raise the limit, or copy out what you want to keep.

The short answer

  1. What does it delete?
  2. How do I keep sessions longer?
  3. How do I save one session?
  4. Which sessions are close to the limit?
  5. Does macOS delete them too?
  6. How current is this guide?
  7. Collecting images automatically

What does Claude Code delete after 30 days?

Anthropic's documentation calls it the retention sweep. For each session older than the limit it removes three things:

~/.claude/projects/<project>/<session-id>.jsonl                      # the transcript
/private/tmp/claude-<your user id>/<project>/<session-id>/scratchpad/   # files Claude wrote
/private/tmp/claude-<your user id>/<project>/<session-id>/images/       # images you pasted

The transcript is also where screenshots and images returned to the conversation are kept, so deleting it takes those with it. The guide to where Claude Code saves images explains each location.

How do I keep sessions longer?

Set cleanupPeriodDays, a number of days, in your user settings file, ~/.claude/settings.json. To keep sessions for 90 days:

{
  "cleanupPeriodDays": 90
}

If the file already has settings, add the line alongside them and keep the commas right, because the file has to stay valid JSON. The minimum is 1 and Claude Code rejects 0. A higher number only helps sessions that still exist: anything already deleted is gone.

How do I save one session before it goes?

Copy the transcript, and the scratchpad if Claude wrote files you want:

mkdir -p ~/Documents/claude-sessions
cp ~/.claude/projects/<project>/<session-id>.jsonl ~/Documents/claude-sessions/
cp -R /private/tmp/claude-$(id -u)/<project>/<session-id>/scratchpad ~/Documents/claude-sessions/<session-id>-scratchpad

For a single file, you can also ask Claude to move it into your project. To pull an image out of a saved transcript later, see how to recover an image from a session transcript.

Which sessions are close to the limit?

This lists transcripts last changed more than 20 days ago, which are the ones to look at first:

find ~/.claude/projects -name '*.jsonl' -mtime +20

We haven't confirmed whether Claude Code counts a session's age from its last change or from when it started, so leave a margin.

Does macOS delete them too?

The scratchpad and pasted images sit in /private/tmp, which macOS treats as temporary. On the Mac we checked, a daily job deletes files there that haven't been touched for about three days, although older files survived in our test and Apple doesn't document the timing as a promise. So a scratchpad can disappear well before 30 days. The transcript lives in ~/.claude and isn't affected by that. The images guide has the details.

How current is this guide?

Checked against Claude Code 2.1.294 on macOS on 8 October 2026. Anthropic can change this in any release. If something here doesn't match what you see, run claude --version, compare it with 2.1.294, check Anthropic's documentation at code.claude.com/docs, or write to [email protected] and we'll update this page.

Collecting images automatically

Copying files by hand works once, and is easy to forget. Detego is a Mac app that copies each image Claude Code makes into its own store as it arrives and keeps them in one shelf under your notch, grouped by session and prompt. It never takes focus from the terminal.

Detego is paid, with a 14-day free trial and no account to create. Download the free trial for macOS 14 or later. Detego works with Claude Code and isn't affiliated with Anthropic.