DEV Community

Aditya Ghadge
Aditya Ghadge

Posted on

Claude Code sessions disappeared? It deletes them after 30 days

if an old claude code session is missing from /resume, there are two possible reasons. it was deleted, or it's still there and the picker just can't find it

1. claude code deletes old sessions after 30 days

claude code saves every session as a .jsonl file under ~/.claude/projects/, one folder per project

there's a setting called cleanupPeriodDays. by default it's 30. claude code regularly deletes session files that haven't been touched in that many days, without any message. no warning, no recycle bin. (sessions you started in the claude desktop app are exempt since v2.1.248, the cli ones aren't)

this is about the files on your machine, not claude.ai chats

i checked my own machine. my prompt history goes back to march, but every session older than 30 days is just gone. 86 of them

to stop it, open ~/.claude/settings.json and set a big number:

{
  "cleanupPeriodDays": 3650
}
Enter fullscreen mode Exit fullscreen mode

that's about 10 years. 0 doesn't mean "keep forever", it fails validation (older versions used to stop saving sessions entirely with 0). so just use a big number

sessions that were already deleted are gone. nothing on your machine has them anymore

2. it's still there, the picker just doesn't show it

if the session is under 30 days old (or you already raised the setting), it's probably still on disk. /resume misses it for two reasons:

  • it only shows sessions from the project you're in. press ctrl+a in the picker to see every project
  • typing in the picker only matches session titles, not what you actually said. titles are usually your first message, like "fix this" or "look at the error"

so if you remember the topic but not the folder or the first message, the picker won't help much

3. search inside the sessions

manual way. grep the files:

grep -ril "payload size" ~/.claude/projects/
Enter fullscreen mode Exit fullscreen mode

it works, but you get raw json, you have to work out which session the file is, and then cd to the right folder and run claude --resume <id> yourself

what i use. i got tired of that and built ccback, a free open-source cli:

npm install -g ccback
ccback payload size
Enter fullscreen mode Exit fullscreen mode

it searches everything you and claude wrote in every session across all your projects (by words and by meaning), shows the matching message, and enter reopens that session in its original folder

ccback demo

one honest note: ccback reads the same files, so it can't bring back sessions claude code already deleted. raise cleanupPeriodDays first

tldr

  • sessions older than 30 days get deleted on startup. set "cleanupPeriodDays": 3650 in ~/.claude/settings.json
  • /resume shows one project and matches titles only. ctrl+a shows all projects
  • to search what was actually said: grep -r in ~/.claude/projects/, or ccback

Top comments (0)