claude-code - 💡(How to fix) Fix Feature request: automatic retention/cleanup policy for old session files (~/.claude/projects/) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#47038Fetched 2026-04-13 05:43:07
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1

Discovered this while manually cleaning up on macOS. Had to write a find command to safely remove old sessions while preserving the active one. Not ideal.

Error Message

The only way to reclaim space today is to manually identify and delete old .jsonl files, being careful not to accidentally delete the current session or important subdirectories (like memory/). This is error-prone and not obvious to most users.

Root Cause

Discovered this while manually cleaning up on macOS. Had to write a find command to safely remove old sessions while preserving the active one. Not ideal.

RAW_BUFFERClick to expand / collapse

Problem

Session files (.jsonl) accumulate indefinitely under ~/.claude/projects/ with no automatic cleanup.

After a few weeks of normal use, this directory can easily reach 100–130 MB — dozens of past conversation files that Claude Code never cleans up on its own.

The only way to reclaim space today is to manually identify and delete old .jsonl files, being careful not to accidentally delete the current session or important subdirectories (like memory/). This is error-prone and not obvious to most users.

Suggested fix

A simple retention policy would solve this:

  • Auto-delete session files older than N days (e.g. 30), configurable in .claude/settings.json
  • Or a claude --cleanup-sessions [--older-than 30d] CLI command
  • At minimum: surface total session storage size somewhere in the UI/CLI so users are aware

Context

Discovered this while manually cleaning up on macOS. Had to write a find command to safely remove old sessions while preserving the active one. Not ideal.

Environment

  • macOS (Apple Silicon)
  • Claude Code CLI + Desktop
  • ~/.claude/projects/ had 50 session files across 4 project directories

extent analysis

TL;DR

Implement a retention policy to auto-delete old session files, such as deleting files older than a configurable number of days.

Guidance

  • Consider adding a configuration option in .claude/settings.json to set the retention period for session files.
  • Introduce a claude --cleanup-sessions CLI command with an optional --older-than flag to allow users to manually clean up old sessions.
  • Display the total session storage size in the UI or CLI to raise user awareness about storage usage.
  • Evaluate the feasibility of automatically running the cleanup command at regular intervals, such as on startup or daily.

Example

No explicit code example is provided due to the lack of specific implementation details in the issue.

Notes

The ideal retention period and cleanup frequency may vary depending on user behavior and system requirements. It is essential to consider these factors when implementing the retention policy.

Recommendation

Apply a workaround by introducing a claude --cleanup-sessions CLI command, as this provides an immediate solution for users to manage session file storage while a more comprehensive retention policy is developed.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature request: automatic retention/cleanup policy for old session files (~/.claude/projects/) [1 comments, 2 participants]