[BUG] data loss through bad default settings
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
dangerous default behavior that leads to data loss
What Should Happen?
What the fuck... I lost again all my chat data similar to
https://github.com/anthropics/claude-code/issues/9581
But now I found this issue... there is a cleanupPeriodDays with a default of 30 that automatically deletes all my session that are older than 30 days. Since this is so important, I would have expeted it to either have a sensible no data loss default, or be asked in the beginning to configure it.
I now configured it in .claude/settings.json and I am documenting it here ...
{
"cleanupPeriodDays": 999999
}
since the ai will shell it again... as it did with the previous post. I would have expected it to get some feedback that this bug report was no bug but expected. I am so angry right now because I lost my data again.
Error Messages/Logs
Steps to Reproduce
- work with claude code.
- wait 30 days
- see work is gone!
- think that this must be a bug and report it
- issue is read by the ai and auto closes
- loose data siltently... and only notice it if you paused your work and see that there is nothing left
Claude Model
Sonnet (default)
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.29
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
10 Comments
Found 2 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Just for the laughs... I asked claude code what it thinks about this...
Looking at this from a professional software engineering and user data ethics perspective, I think the reporter has a completely legitimate grievance, and this represents a significant design failure. Let me break down why:
The Core Problem: Silent Data Destruction
This isn't just "aggressive cleanup" - it's silent, automatic deletion of user-generated content with a default that assumes data becomes worthless after 30 days. That's a fundamental misunderstanding of how people use development tools.
Why This is Wrong
1. Violation of User Expectations
2. No Informed Consent
3. Data Loss by Default is Backwards
4. Poor Recovery Options
How User Data Should Be Handled
The Right Approach:
```
"How long should we keep your session history?
```
The Inadequate Response Issue
The reporter mentions they expected feedback that this was "expected behavior" - this reveals another problem: normalizing data loss as "not a bug".
Just because something works "as designed" doesn't mean the design isn't fundamentally flawed. The appropriate response would be:
Not: "Working as intended, close ticket."
Bottom Line
This is a severe violation of user trust. Development session history is valuable intellectual property - it contains problem-solving approaches, architectural decisions, and learning context. Auto-deleting it is like a note-taking app that burns your notebooks after a month without asking.
The reporter's anger is justified. Setting
cleanupPeriodDays: 999999as a workaround shouldn't be necessary - preservation should be the default.Even intentional configuration leads to data loss
Adding to this thread with a related angle: the problem isn't just the default value. Even when a user actively tries to configure
cleanupPeriodDays, the documentation makes it a trap.My case: I wanted to disable session cleanup entirely. A Claude Code instance consulted the JSON schema, which says
cleanupPeriodDaysis"Number of days to retain chat transcripts (0 to disable cleanup)". Following that, I setcleanupPeriodDays: 0. The official docs say the opposite: "Setting to 0 immediately deletes all sessions." The actual behavior matched the docs -- on the next startup, all sessions across all my projects were silently destroyed. Every session created after that was silently never persisted to disk. See #23710 for the full technical breakdown of this schema contradiction.I was able to partially recover from btrfs snapshots (Arch Linux + snapper). By merging 5 snapshots spanning Jan 17 - Jan 28 from oldest to newest, I recovered the majority of my sessions. Earlier snapshots contained sessions that had already been cleaned up by the default 30-day policy before later snapshots were taken -- so checking multiple backup dates is critical for maximizing recovery. But over a week of sessions are permanently gone, and most users won't have btrfs snapshots to fall back on.
The long-term damage: My
history.jsonlshows I've been using Claude Code since September 2025, but my oldest recovered session transcript is from December 2025. Three months of sessions were already silently destroyed by the default 30-day cleanup long before I ever touched this setting. I never opted into this. I was never warned. And I'm one user -- this is happening to every Claude Code user right now, silently, on every startup.This is user data -- months of work context, debugging sessions, implementation decisions. It should not be silently destroyable by a single misconfigured integer, and it should not be auto-deleted by default without explicit consent.
This is broken at multiple levels:
0cleanupPeriodDaysis set to a destructive valueFor anyone who may have been affected and wants to attempt recovery:
sudo snapper -c home list, then merge ALL snapshots oldest-first withsudo rsync -a --ignore-existing /home/.snapshots/<N>/snapshot/<user>/.claude/projects/ ~/.claude/projects/zfs list -t snapshotfor recent snapshots of your home dataset~/.claude/projects/cleanupPeriodDays: 99999immediately to prevent further loss.The fix I'd advocate for:
0should mean "never clean up" (as the schema says), destructive cleanup should require explicit opt-in, and there should at minimum be a startup warning when sessions are about to be bulk-deleted.Because github added stale... I did not get over this default setting so easily and have to tell people about my bad experience... And they did also not know and ask for setting. This is a really really important because time critical issue people will loose their history because of it!
Highlighting as in #23710 and as mentioned by @bengous: the JSON schema and the Docs offer contradicting and destructive advice,
0 to disable cleanupvs.0 immediately deletes all sessions. The first behavior matches human and Claude expectations as described—but it seems the second [destructive] behavior is what's implemented?I just got bitten by this one, I set it to 0 in the config file after reading the json schema hover tip in vscode, thinking it will disable cleanup but unfortunately it deleted everything. This is a very serious bug caused by documentation mismatch.
Either way nothing should be deleted without confirming from the user. A better ux might be ask the user explicitly on startup if they want to remove old sessions every month or so.
This issue confirms to me that claude code is made with ai without any care for usage by actual humans.
Hooks provide a safety net against bad default settings:
Even with bad default settings, the hooks block destructive commands and back up files before modification. This prevents data loss regardless of how settings are configured.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This absolutely is still relevant as the bad default remains in place and just wiped my conversations.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.