How to delete old Claude Code sessions
age is a find away, and cleanupPeriodDays does it on a timer — but old sessions are rarely what fills the disk
Claude Code has no archive. Nothing is moved aside, nothing goes to a trash folder, and there is no retention view to prune: the list you see in claude --resume is built by reading ~/.claude/projects each time, so a session that has left that list is a file that has left the disk. “Delete my archived sessions” therefore means one of two things — delete the ones older than some date, or delete the ones that are large.
Delete by age
One command, and it is worth running once without -delete to see what it would take.
# what would go: every transcript last written more than 30 days ago
find ~/.claude/projects -name '*.jsonl' -mtime +30
# how much that is
find ~/.claude/projects -name '*.jsonl' -mtime +30 -exec du -ch {} + | tail -1
# do it
find ~/.claude/projects -name '*.jsonl' -mtime +30 -delete
-mtime reads the last write, not the start, so a session you resumed last week counts as last week's however old its first line is. If CLAUDE_CONFIG_DIR is set, the path moves with it.
To drop a whole project rather than its old sessions, claude project purge (Claude Code 2.1.126 and later) deletes every transcript of it along with its memory directory and file-edit history; --dry-run lists them first. Deleting Claude Code sessions has the one-session case.
Let Claude Code do it
The same sweep is a setting. cleanupPeriodDays in ~/.claude/settings.json is a retention in days, 30 unless you say otherwise, and transcripts older than that are removed for you.
{ "cleanupPeriodDays": 90 }
Raising it keeps history longer; lowering it is a sweep on a timer. The setting only covers ~/.claude/projects — your prompt history in ~/.claude/history.jsonl is a separate file and survives it.
Age is the wrong axis for disk space
Measured on one machine, 1,320 transcripts across 21 project directories:
all sessions 1,320 files 2.73 GB older than 30 days 368 files 0.11 GB (4% of the bytes) the ten largest files 10 files 2.36 GB (86% of the bytes) the single largest 1 file 1.01 GB
Twenty-eight percent of the files were older than a month and they held four percent of the space. Sessions grow with what a tool printed into them, not with how long ago they ran, so one long afternoon of a build loop outweighs a year of ordinary work. If the goal is free space, sort by size and delete the top few. If the goal is that old work stops sitting on the disk, age is the right axis and the find above is the whole job.
# the ten worst offenders, in MB, largest first
find ~/.claude/projects -name '*.jsonl' -exec du -m {} + | sort -rn | head
ls -S looks like the shorter way to write that and is wrong for the job: -exec … + hands the command a batch at a time, so each batch is sorted on its own and the first ten lines are the largest of the first batch. Sorting after the exec is what makes the order global.
What you lose
A deleted transcript leaves claude --resume immediately, and nothing in the agent breaks. What goes with it is the record: what you tried in that session, the command that finally worked, the reason a decision went the way it did. That is not recoverable from the repository, because most of it was never committed — and a backup snapshot taken before the sweep is the only copy left. Recovering a deleted session covers what is still reachable when it is already gone.
An index built while the files existed keeps answering after they are deleted, which is the one copy that survives a sweep by design. That is what deja is: it reads the transcripts once, keeps its own index under ~/.cache/deja, and answers from it — so you can run the find above without losing what those sessions knew. In the screen bare deja opens, swept sessions are listed under the Deleted tab, and R writes one back so claude --resume finds it again, with the conversation but not the tool calls.
Deleting Claude Code sessions, in full · Where every agent stores history · Recover a deleted session
Found this useful? Star deja-vu on GitHub.