Anthropic’s Claude Code CLI is quietly deleting session transcripts after 30 days by default, a behavior that catches developers off guard when they attempt to retrieve older context. The setting, cleanupPeriodDays in ~/.claude/settings.json, defaults to 30 and triggers a background sweep that removes per-session .jsonl files under ~/.claude/projects/. Once these files are purged, they are unrecoverable, creating a permanent gap in development history for anyone who hasn’t explicitly configured retention.

The Silent Sweep and Its Scope

The deletion mechanism runs as a background sweep after a session starts, meaning users often don’t notice logs disappearing until they try to use the /resume command and find old sessions missing. The scope of this cleanup has expanded with version 2.1.117 to include tasks/, shell-snapshots/, and backups/, in addition to the core session transcripts. Bryce Watson, who documented this behavior, found that while his project folders survived from January 2026, the actual transcript files vanished after May 5, leaving only the empty directory structures behind.

Exceptions for Desktop and Cowork Sessions

Not all sessions are treated equally. Since version 2.1.248, transcripts initiated or continued in Claude Desktop and Cowork are exempt from the standard 30-day purge, regardless of age. This exception was implemented to fix issues where these sessions were previously disappearing. However, a new setting, desktopSessionCleanupPeriodDays, can reintroduce an age limit for these specific sessions, though it cannot be set lower than the global cleanupPeriodDays. For terminal and IDE-based sessions, the standard 30-day rule remains absolute.

Irreversible Data Loss and Configuration

The critical flaw in this default behavior is its irreversibility. Raising cleanupPeriodDays to a higher value, such as 3650 for effectively infinite retention, only prevents future deletions; it does not restore files already swept. Watson’s investigation revealed that his own history had a hard floor in early May, proving that the default purge had already erased months of work before he adjusted his settings. Developers must explicitly set this value in their configuration file to prevent ongoing loss, as an absent key defaults to the aggressive 30-day cycle.

Key Takeaways

  • The default cleanupPeriodDays is 30, with a minimum of 1; setting it to 0 fails validation.
  • Deletion is permanent; increasing the retention period does not recover previously purged logs.
  • Claude Desktop and Cowork sessions are currently exempt from the standard sweep as of v2.1.248.
  • Organization-managed settings can override user preferences for retention periods.
  • The sweep now includes tasks/, shell-snapshots/, backups/, file-history/, and plans/.

The Bottom Line

Silent data deletion is a hostile default for a developer tool that relies on context. If you aren't explicitly managing your retention settings, you are actively destroying your own development history every month.