Description
Sessions created on the same day are being deleted during startup cleanup, even though they should be retained based on the cleanupPeriodDays setting (default 30 days).
Environment
- Claude Code version: 2.1.12
- OS: macOS (Darwin 25.1.0)
- Platform: darwin
Steps to Reproduce
- Start Claude Code and have several conversations throughout the day
- Close terminal and reopen
- Start a new Claude Code session
- Run
/resume - previous sessions are missing
Expected Behavior
Sessions created within the cleanupPeriodDays period (default 30 days) should be preserved and available via /resume.
Actual Behavior
All 5 sessions created the same day were deleted during startup. Debug logs show:
2026-01-17T18:16:05.137Z [DEBUG] Session index: added 1, updated 2, removed 0 (total: 5)
2026-01-17T20:19:27.848Z [DEBUG] Session index: added 0, updated 0, removed 5 (total: 0)
The cleanup at 20:19:27 removed all 5 sessions, despite them being created earlier the same day.
Additional Context
cleanupPeriodDays was set to 36500 at 20:29:30 (after the cleanup had already run)
- However, even with the default 30-day retention, same-day sessions should not be deleted
- The
history.jsonl file shows 8+ session IDs were used, but only 2 session files remained after the cleanup
- Sessions index file (
sessions-index.json) went from 5 entries to 0 in a single startup
Debug Log Excerpt
From session 9d6e8a4a-cee8-41ae-be27-1a848fe3c74b.txt (the session that triggered the cleanup):
2026-01-17T20:19:27.843Z [DEBUG] [STARTUP] Running setup()...
2026-01-17T20:19:27.846Z [DEBUG] Stats cache is up to date
2026-01-17T20:19:27.846Z [DEBUG] Plugin autoupdate: skipped (auto-updater disabled)
2026-01-17T20:19:27.848Z [DEBUG] Session index: added 0, updated 0, removed 5 (total: 0)
The cleanup happened immediately during startup with no indication of why sessions were marked for removal.
Workaround
Setting cleanupPeriodDays to a high value (e.g., 36500) in ~/.claude/settings.json before any sessions are created may prevent this, but this does not explain why same-day sessions were deleted.
Description
Sessions created on the same day are being deleted during startup cleanup, even though they should be retained based on the
cleanupPeriodDayssetting (default 30 days).Environment
Steps to Reproduce
/resume- previous sessions are missingExpected Behavior
Sessions created within the
cleanupPeriodDaysperiod (default 30 days) should be preserved and available via/resume.Actual Behavior
All 5 sessions created the same day were deleted during startup. Debug logs show:
The cleanup at 20:19:27 removed all 5 sessions, despite them being created earlier the same day.
Additional Context
cleanupPeriodDayswas set to 36500 at 20:29:30 (after the cleanup had already run)history.jsonlfile shows 8+ session IDs were used, but only 2 session files remained after the cleanupsessions-index.json) went from 5 entries to 0 in a single startupDebug Log Excerpt
From session
9d6e8a4a-cee8-41ae-be27-1a848fe3c74b.txt(the session that triggered the cleanup):The cleanup happened immediately during startup with no indication of why sessions were marked for removal.
Workaround
Setting
cleanupPeriodDaysto a high value (e.g., 36500) in~/.claude/settings.jsonbefore any sessions are created may prevent this, but this does not explain why same-day sessions were deleted.