How do I keep Claude Code conversations longer than 30 days?
Claude Code deletes local transcripts after 30 days. Set cleanupPeriodDays (e.g. 3650) in settings.json; 0 is rejected. Desktop and Cowork rules explained.
Add "cleanupPeriodDays": 3650 (any whole number of 1 or more) to ~/.claude/settings.json. The default is 30. After a session starts, Claude Code runs a background sweep that deletes older transcripts without showing a message, so they vanish from the /resume picker. Setting 0 fails validation. Sessions started or last continued in Claude Desktop or Cowork are kept at any age by default (v2.1.248+); cap them with desktopSessionCleanupPeriodDays. Checked against the code.claude.com docs on 2026-10-12.
Set cleanupPeriodDays
{
"cleanupPeriodDays": 3650
}
| Property | Value |
|---|---|
| Type | Number of days, a whole number, minimum 1 |
| Default | 30 |
| Scope | Any settings file: user (~/.claude/settings.json), project, local or managed |
Put it in your user settings if you want it on every project. A project file works too, but only for that project. The docs suggest "a large value such as 3650 for long retention". A maximum value is not published as of 2026-10-12.
Pitfall: 0 doesn't mean "never". Since Claude Code 2.1.89, cleanupPeriodDays: 0 is "rejected with a validation error — it previously silently disabled transcript persistence" (CHANGELOG). There is no "keep forever" value; use a large number.
What the sweep deletes, and what it keeps
Claude Code transcripts live at ~/.claude/projects/<project>/<session-id>.jsonl, where <project> is your working directory path with non-alphanumeric characters replaced by -. Each file is the full conversation: every message, tool call and tool result.
Once they are older than cleanupPeriodDays, the sweep also removes, among others:
Path under ~/.claude/ | Contents |
|---|---|
projects/<project>/<session>/subagents/ | Subagent transcripts |
projects/<project>/<session>/tool-results/ | Large tool outputs |
file-history/<session>/ | Checkpoint snapshots |
plans/, debug/, paste-cache/ | Plan files, debug logs, large pastes |
tasks/, shell-snapshots/, backups/ | Task lists, shell state, ~/.claude.json backups |
The same cutoff applies to orphaned worktrees.
What it keeps: your auto memory files in projects/<project>/memory/ are not deleted by the sweep (see Claude Code memory), and the small per-session files in sessions/ follow their own rule.
The Claude moves worth stealing, by email
Workflows tested on real jobs, sent only when they are worth it. Free.
Claude Desktop and Cowork sessions
Since 2.1.248, Claude Code keeps the transcript of a session you started or most recently continued in Claude Desktop or Cowork at any age. Earlier versions delete them after cleanupPeriodDays.
To give them an age limit, set desktopSessionCleanupPeriodDays:
- Scope: user or managed settings (or a file passed with
--settings). Ignored in project and local settings. - Type: whole days, minimum
0. Default0, which sets no age limit. - A transcript is deleted only once it's older than both this value and
cleanupPeriodDays. With the default 30, a value of7still keeps them 30 days.
For the app itself, see how to use Claude Code Desktop.
When your setting is overridden
- Managed settings that set
cleanupPeriodDayswin, and they also switch off the Desktop and Cowork exemption. See managed settings. - HIPAA configuration also makes Desktop and Cowork transcripts follow
cleanupPeriodDays. - Bare mode (
claude -p --bare) doesn't run the sweep in that session. - Paused sweep: if Claude Code can't safely determine the retention period, it pauses the sweep. When the cause is a settings error,
/statusshows a warning until you fix it.
Find and back up kept sessions
Kept sessions show up in the /resume picker. You can also open one directly with claude --resume <transcript-path>, using the absolute path to the .jsonl file.
For a backup, copy the .jsonl files somewhere safe, or use a SessionEnd hook: hooks receive a transcript_path field, and the docs note a SessionEnd hook "can archive the transcript when a session ends". /export saves a readable plain-text copy of the current conversation.
Pitfall: transcripts are plaintext. Anything that passes through a tool (file contents, command output, pasted text, credentials a tool reads) is written to disk. Keeping them ten years means keeping that too.
Going the other way? claude purge deletes one project's local state, and CLAUDE_CODE_SKIP_PROMPT_HISTORY stops transcripts being written.
Local retention vs Anthropic's server retention
cleanupPeriodDays only controls files on your machine. Anthropic's own retention of Claude Code data (for example 30 days or 5 years for consumer accounts, depending on your model-improvement choice) is a separate policy, and this setting doesn't change it. See Anthropic's data usage page.
FAQ
Can I set cleanupPeriodDays to 0 to never delete?
No. Since 2.1.89 it fails validation. Use a large value such as 3650.
Where are Claude Code conversations stored?
In ~/.claude/projects/<project>/<session-id>.jsonl, one JSONL file per session.
Does the sweep delete my CLAUDE.md or auto memory? No. Auto memory files aren't swept; the memory folder is removed only if it has been empty for the whole retention period.
Why do my Desktop and Cowork sessions stay longer?
Since 2.1.248 they're exempt by default unless you set desktopSessionCleanupPeriodDays or managed settings set cleanupPeriodDays.
Can I get back a session that was already deleted? A recovery method is not published as of 2026-10-12. Back up before the sweep runs.
Sources (checked 2026-10-12 08:10 CEST)
- Settings reference,
cleanupPeriodDaysanddesktopSessionCleanupPeriodDays: https://code.claude.com/docs/en/settings-reference#cleanupperioddays - Application data, "Cleaned up automatically": https://code.claude.com/docs/en/claude-directory#cleaned-up-automatically
- Sessions, "Where transcripts are stored": https://code.claude.com/docs/en/sessions#where-transcripts-are-stored
- Data usage, "Data retention": https://code.claude.com/docs/en/data-usage#data-retention
- Claude Code CHANGELOG (0.2.117, 2.1.89, 2.1.101, 2.1.117, 2.1.248): https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md
Related: Set up Claude Code memory · Context engineering
