Claude Code quietly wipes session logs after 30 days

If ~/.claude/settings.json has no cleanupPeriodDays key, Claude Code deletes session transcripts older than 30 days. A Brycewatson write-up, revised on September 30, shows the hole this leaves on a real machine. Setting a larger value, such as 3650 days, stops the next purge, but anything already swept stays gone. A history is only safe from the day the key was set.
The sweep runs in the background after a session starts and prints nothing. An old session just stops showing up in /resume. The settings reference sets the default at 30 days and the minimum at 1, and a value of 0 fails validation. You can make retention very long, but you can’t turn it off.
Check the key, then raise it
cleanupPeriodDays is a top-level key. If a number is there, that is your retention in days. If the key is missing, you are on the 30-day default, and the author says this is the case people misread: “I don’t have that setting” reads as “I’m fine,” but it actually means “I’m being purged every 30 days.”
The fix is one line: { "cleanupPeriodDays": 3650 }, which is about ten years. If you don’t want a decade of transcripts piling up, the author suggests picking a deliberate ceiling like 365. Your organization can overrule all of this. If managed settings (the configuration an organization deploys to its machines) set cleanupPeriodDays, that value beats yours, and it covers Desktop sessions too.
What the sweep takes, and what it keeps
The sweep mainly targets the per-session .jsonl transcripts under ~/.claude/projects/: one file per session, plus a file under subagents/ for each subagent run. According to the changelog, tasks/, shell-snapshots/ and backups/ were added to the sweep in v2.1.117. The .claude directory docs also list file-history/, plans/, debug logs, the paste cache and orphaned worktrees. The auto memory folder, projects/<project>/memory/, is kept. Before v2.1.228, though, the sweep treated folders inside it as session data and could delete old files there.
Since v2.1.248, transcripts of sessions you started or last continued in Claude Desktop or Cowork are kept at any age. The changelog calls this a fix for those sessions “disappearing after 30 days”. A new setting, desktopSessionCleanupPeriodDays, can put an age limit back on them, but never a shorter one than cleanupPeriodDays. Terminal and IDE sessions still follow the 30-day default. That is more than eight months after a327ex described the silent deletion on January 14 and suggested 99999 as the fix.
Which timestamp the sweep checks is the author’s observation, not documented behaviour. On the author’s machine, deletion goes by each file’s last-modified time. The oldest surviving transcript there has a first internal message about two days earlier than the file’s modified date.
What one machine shows
The author had raised the value to 3650 months earlier. On June 25, the machine still held 1,324 transcript files older than 31 days, 647 of them top-level sessions. The default would have deleted every one of them. The oldest was last modified on May 7. Across all ages, the author counted about 7,000 transcript files taking up 1.58 GB.
Nothing older than roughly May 5 to 7 survives anywhere under projects/. Yet eight project folders there were created between January and April 2026, and none holds a transcript older than May 5. The folders outlived their contents. shell-snapshots/, which is swept on the same clock, runs out at about the same point. By June 11 the author’s setting was already 3650, which is after that floor. The change blocked the next purge and recovered nothing from before May.
The revision also corrects a mistake worth knowing if you audit your own disk. The first version cited 150 file-history/ files dated March and April as proof of earlier work. Those dates had been copied from the edited files, and the earliest of them was actually written to disk on April 12.
The cost of keeping everything
If you keep everything, disk use grows without limit. The author’s rough estimate is that a busy setup produces hundreds to low thousands of transcript files a week. What’s in those files matters too. Classmethod says the official documentation describes a transcript as the full conversation, tool calls and results included, stored as unencrypted plain text. If a tool reads a .env file, or credentials show up in command output, they end up in the file. Its suggested mitigations are a shorter cleanupPeriodDays, or the CLAUDE_CODE_SKIP_PROMPT_HISTORY environment variable to stop writing transcripts at all. One ten-person team’s 30 days of telemetry, published in September, recorded Claude printing credentials outright 66 times. With 3650-day retention, any such value written to a transcript stays on disk for a decade.
In the same January post, a327ex reported that Claude, when first asked, said local session files in ~/.claude/projects/ are not deleted automatically. It had confused them with server-side retention.
Up next
Claude’s constitution rules out even white lies
Anthropic’s constitution for Claude ruled out even the white lie about loving a gift you dislike, though Claude can still keep its own opinions to itself and stay honest.
Related stories
- Tokendoctor cut its author’s Claude Code cost 38%
- Claude Code on desktop folds an iPhone Duo to test layouts
- memsaga gives Claude Code’s memory files a git history
- Claude Code 2.1.318: login expiry warning, runner log change
- Intent-lens spells out Claude Code calls before they run
- Codedict cuts Claude Code tokens 63%, but cost only 26%
Comments
No comments yet. Be the first.
Join the conversation
Sign in to leave a comment. It appears after moderation.

