{"slug": "claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-a", "title": "Claude Code quietly deletes your session history after 30 days. I noticed three and a half months in", "summary": "A developer discovered that Claude Code silently deletes session transcripts after 30 days, having found that their oldest surviving transcript dated from September 11 while their first prompt dated from May 26. The retention window is documented but controlled by the cleanupPeriodDays setting, which defaults to 30 days and can be raised in ~/.claude/settings.json, though transcripts are stored as unencrypted plain text that can capture credentials. The developer recommends a 365-day retention period alongside permission rules denying reads of credential files.", "body_md": "*This article was created with the help of AI. The numbers come from my own server.*\n\nMy first prompt to Claude Code on my work server is dated May 26. The oldest session transcript still on disk is from September 11. Everything in between is gone, and I never saw a warning.\n\nIt isn't a bug. Claude Code keeps session transcripts for 30 days and then deletes them. The docs say so, on a page few people open. One line in the settings changes that, but only going forward.\n\nEvery Claude Code session is written to a file under `~/.claude/projects/`. It holds the whole conversation: your messages, the model's replies, every tool call and its result. `/resume` reads these files to take you back into an old session.\n\nAfter 30 days the file is deleted. Nothing tells you. The session simply stops showing up in `/resume`, and its subagent transcripts and any orphaned git worktrees from parallel tasks go with it.\n\nSome things survive:\n\n`history.jsonl` keeps what you typed, unless HIPAA settings apply to your account. So my May questions are still there. The answers are not.`desktopSessionCleanupPeriodDays`.\nOn October 11 I had 724 transcript files taking 861 MB. By age: 181 from the last week, 62 from the week before, 338 from the third week and 143 older than that. Not one older than 30 days.\n\nI can't check what was in the deleted ones. Probably bug hunts and notes on why something was built a certain way. Exactly what you open an old session for.\n\nThree commands:\n\n```\ngrep cleanupPeriodDays ~/.claude/settings.json\nfind ~/.claude/projects -name '*.jsonl' | wc -l\nfind ~/.claude/projects -name '*.jsonl' -mtime +30 | wc -l\n```\n\nThe first shows whether you set a retention period. If it prints nothing, you're on the 30-day default. The second counts all transcripts, the third only those older than 30 days. If the third prints zero and you've used Claude Code for more than a month, the sweep has already run.\n\nAdd the key to `~/.claude/settings.json`:\n\n```\n{\n  \"cleanupPeriodDays\": 3650\n}\n```\n\nThat's about ten years. Three things to watch:\n\n`0` fails validation, and the minimum is 1. To keep things long, pick a big number.\nTranscripts are plain text, unencrypted. The docs are blunt about it: if a tool reads a `.env` file or a command prints a credential, that value lands in the session file. That is why the default is short.\n\nThe longer you keep history, the more secrets pile up on disk. If you raise the limit, deny reads of credential files with permission rules, and keep `~/.claude/projects/` out of unencrypted backups.\n\nAnd if you'd rather keep nothing, `CLAUDE_CODE_SKIP_PROMPT_HISTORY` stops writing transcripts and prompt history, `--no-session-persistence` does the same for a single `-p` run, and `claude purge` wipes what is stored for one project.\n\n365 days. A year covers nearly every time I go back to an old decision, and the disk use and the secrets stay manageable.\n\nFunny that a tool which holds your whole project in its head forgets its own history after a month.\n\nThe details are in the [Claude Code docs](https://code.claude.com/docs/en/claude-directory#cleaned-up-automatically). I collect findings like this on [Promtime](https://promtime.net/c/en), the news site I edit.", "url": "https://wpnews.pro/news/claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-a", "canonical_source": "https://dev.to/alex_iolan/claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-and-a-half-months-in-334j", "published_at": "2026-10-22 14:07:28+00:00", "updated_at": "2026-10-22 14:14:28.458922+00:00", "lang": "en", "topics": ["ai-tools", "ai-products", "developer-tools", "ai-agents"], "entities": ["Claude Code", "Anthropic", "Promtime"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-a", "markdown": "https://wpnews.pro/news/claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-a.md", "text": "https://wpnews.pro/news/claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-a.txt", "jsonld": "https://wpnews.pro/news/claude-code-quietly-deletes-your-session-history-after-30-days-i-noticed-three-a.jsonld"}}