# Claude Code chat history deleted? Set cleanupPeriodDays

> Claude Code deletes session transcripts after 30 days by default. Raise cleanupPeriodDays in settings.json to keep them, and back up what you can't lose.

Source: https://shuriken.sh/guides/claude-code-history-deleted-after-30-days

Claude Code deletes session transcripts older than cleanupPeriodDays, 30 days by default, in a silent sweep after a session starts, so old chats drop out of /resume. Set a larger value, such as 3650, in ~/.claude/settings.json; it can't bring back what is already gone.

By Shuriken Updated 27 October 2026 5 min read

**Contents**

Old Claude Code chats that vanish from /resume after a month were deleted by Claude Code itself. It removes session transcripts older than cleanupPeriodDays, which is 30 by default, in a background sweep after a session starts, and it shows no message when it does. To keep sessions longer, put a bigger number in ~/.claude/settings.json. Nothing brings back a transcript the sweep already removed, unless you have a backup.

We checked the Claude Code details below against Anthropic's [settings reference](https://code.claude.com/docs/en/settings-reference#cleanupperioddays), its page on the [.claude directory](https://code.claude.com/docs/en/claude-directory#cleaned-up-automatically) and the Claude Code changelog on 24 October 2026, when the newest Claude Code was 2.1.310.

## Why Claude Code deleted your chat history #

Every session is a file: ~/.claude/projects/<project>/<session-id>.jsonl, holding every message, tool call and tool result. Once one is older than the retention period, the sweep deletes it, along with the session's subagent transcripts, its saved tool output and its file-history snapshots. That is why, in the settings reference's words, "a session you haven't used for longer than the retention period no longer appears in the /resume picker."

Your side of an old chat is often still on disk. ~/.claude/history.jsonl holds the prompts you typed, for up-arrow recall and Ctrl+R, and the sweep leaves it alone unless your organisation's HIPAA configuration applies. Claude's replies are gone with the transcript. The sweep also skips the auto memory files in projects/<project>/memory/, so what Claude saved there outlasts the session it came from ([does Claude Code remember between sessions](https://shuriken.sh/guides/claude-code-memory-between-sessions) explains the difference). And from Claude Code 2.1.248, sessions you started or last continued in Claude Desktop or Cowork are kept at any age, unless you set desktopSessionCleanupPeriodDays, your organisation's managed settings set cleanupPeriodDays, or the HIPAA configuration applies.

claude purge deletes a project's transcripts on purpose, but it prints its plan and asks first, so it's rarely the surprise. Logging out doesn't delete chats: the transcripts stay in ~/.claude/projects ([does logging out of Claude Code delete your chats](https://shuriken.sh/guides/claude-code-logout-chat-history) covers the cases where history only looks lost). If chats from last week are missing too, the sweep didn't take them. By default the picker shows sessions from the folder you're in, and Ctrl+A widens it to every project on the machine.

## How to keep Claude Code history: set cleanupPeriodDays #

- Open ~/.claude/settings.json (on Windows, %USERPROFILE%\.claude\settings.json). Create it if it's missing.
- Add the key, keeping whatever else is in the file:

json
{
"cleanupPeriodDays": 3650
}

- Save, then start a new session and run /status. If a settings file can't be read or parsed, or has errors while cleanupPeriodDays is set, Claude Code pauses the sweep and shows a warning there until you fix it.

The value is a whole number of days, minimum 1. Here is what each choice does:

| Value | What Claude Code does |
| --- | --- |
| Not set | Deletes transcripts older than 30 days |
| 1 or more | Deletes transcripts older than that many days |
| 0 | Fails validation (since 2.1.89). Before that, it silently stopped transcripts being saved at all |
| 3650 or another large number | Keeps them about ten years. The docs suggest this for long retention |

Two version notes. Before 2.1.310, a very large value could make the cleanup delete some recent files, such as pasted images. Before 2.1.101, starting Claude Code with --setting-sources that left out user made the cleanup ignore your setting and delete history older than 30 days. If either fits, update Claude Code first.

### Set it and still losing chats? #

A value in a higher settings level wins. The order is managed settings, then --settings, then .claude/settings.local.json, then the project's .claude/settings.json, then your user file. A key your organisation sets in managed settings can't be overridden at all. The key also belongs in settings.json: ~/.claude.json is a different file that Claude Code writes for itself.

## One setting per CLAUDE_CONFIG_DIR #

CLAUDE_CONFIG_DIR moves Claude Code's folder. Anthropic's environment variable list says: "All settings, session history, and plugins are stored under this path." So each config folder has its own settings.json, its own projects/ and its own 30-day default. If you run a work profile at ~/.claude-work (the setup in [two Claude Code profiles on one machine](https://shuriken.sh/guides/claude-config-dir-profiles)), raising the value in ~/.claude/settings.json does nothing for it. Set it in ~/.claude-work/settings.json too, or link one file into both (merge the work file into the main one and remove it first, or ln refuses):

bash
ln -s ~/.claude/settings.json ~/.claude-work/settings.json

If you have linked projects/ between profiles to share chats, link settings.json as well. A profile left on the 30-day default can delete from the shared folder at 30 days, whatever the other profile says.

Shuriken runs your coding agents on your own computers and keeps them going when an account hits its limit.

[Download](https://shuriken.sh/download)

## Back up Claude Code conversations #

A bigger number protects you from the timer, not from a lost disk or a wiped folder.

### Copy the transcripts #

projects/ is plain files. On a Mac or Linux, rsync -a ~/.claude/projects/ ~/claude-history-backup/ copies them, adds new and changed ones each time you run it, and never removes the ones the sweep has deleted. To use one again, copy the file back under projects/ and resume it with claude --resume /path/to/<session-id>.jsonl, as in [resuming a Claude Code session](https://shuriken.sh/guides/resume-claude-code-session). Raise cleanupPeriodDays before you copy old files back, or the next sweep can delete them again. The same files are what you carry when you [move Claude Code history to a new computer](https://shuriken.sh/guides/move-claude-code-history-to-new-computer).

A SessionEnd hook can do the copying for you: Claude Code hands it the session's transcript_path when a session ends.

### Export a readable copy #

/export copies the current conversation to the clipboard or saves it as a plain-text file, with messages and tool output rendered as text. /export auth-refactor.txt writes straight to that file. It is for reading later; it can't be resumed. Anthropic points people who want session data for a script to /export or claude -p --resume <id> --output-format json, because the JSONL format is internal and changes between versions.

## How Shuriken keeps chat history #

Shuriken is a harness that runs Claude Code and other coding agents on your own computers. Each Claude account you add gets its own config folder, and Shuriken links your global ~/.claude/settings.json and ~/.claude/projects into every one of them. One cleanupPeriodDays in that file covers every account, and one backup of projects/ holds every account's sessions. (If the file link can't be made, which can happen on Windows, that account keeps a settings file of its own.) Only add accounts you own and are entitled to use; providers' terms may not allow sharing a subscription sign-in.

Shuriken also keeps its own copy of each chat's messages, yours and the agent's replies (not tool output), on the computer that ran the chat, until you delete the chat. When Claude Code's transcript for a chat is gone, the chat still shows those messages. Your next message starts a new Claude session that is handed that history as text, and the chat tells you: "Claude couldn't pick up where this chat left off; it goes on with the chat's history".

Raising cleanupPeriodDays is still worth doing, because the new session gets the conversation as text, without the tool calls and file reads behind it. If you want both, [download Shuriken](https://shuriken.sh/download).

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-history-deleted-after-30-days&text=Claude%20Code%20chat%20history%20deleted%3F%20Set%20cleanupPeriodDays)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-history-deleted-after-30-days)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-history-deleted-after-30-days&t=Claude%20Code%20chat%20history%20deleted%3F%20Set%20cleanupPeriodDays)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-history-deleted-after-30-days&title=Claude%20Code%20chat%20history%20deleted%3F%20Set%20cleanupPeriodDays)[E-mail](mailto:?subject=Claude%20Code%20chat%20history%20deleted%3F%20Set%20cleanupPeriodDays&body=https%3A%2F%2Fshuriken.sh%2Fguides%2Fclaude-code-history-deleted-after-30-days)

## Sources

- [Claude Code docs: Settings reference (cleanupPeriodDays)](https://code.claude.com/docs/en/settings-reference#cleanupperioddays) (accessed 24 October 2026)
- [Claude Code docs: Explore the .claude directory (cleaned up automatically)](https://code.claude.com/docs/en/claude-directory#cleaned-up-automatically) (accessed 24 October 2026)
- [Claude Code docs: Manage sessions (export and locate session data)](https://code.claude.com/docs/en/sessions#export-and-locate-session-data) (accessed 24 October 2026)
- [Claude Code docs: Settings (settings precedence)](https://code.claude.com/docs/en/settings#settings-precedence) (accessed 24 October 2026)
- [Claude Code docs: Environment variables (CLAUDE_CONFIG_DIR)](https://code.claude.com/docs/en/env-vars) (accessed 24 October 2026)
- [Claude Code changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md) (accessed 24 October 2026)

## Frequently asked questions

**Can I recover Claude Code chats that were already deleted?**

Not from Claude Code. The sweep removes the transcript files, so only a backup you made, such as a Time Machine copy of ~/.claude/projects, brings one back. The prompts you typed are still in ~/.claude/history.jsonl, which the sweep leaves alone, but Claude's replies are not.

**Can I turn off Claude Code's 30-day cleanup?**

Not with 0. Since Claude Code 2.1.89, cleanupPeriodDays set to 0 fails validation; before that it silently stopped transcripts being saved at all. Anthropic's settings reference suggests a large value such as 3650 for long retention.

**Where do I put cleanupPeriodDays?**

In your user settings file, ~/.claude/settings.json, or settings.json inside the folder CLAUDE_CONFIG_DIR points at. Not in ~/.claude.json, which is a different file that Claude Code writes for itself.

**Does /clear delete my Claude Code history?**

No. Sessions are saved as you work, and the old conversation stays in /resume after /clear. Transcripts go when the age sweep or claude purge deletes them, or when you delete the files yourself.

**How do I export a Claude Code conversation?**

Run /export inside the session. It copies the conversation to your clipboard or saves it as a plain-text file, with messages and tool output rendered as readable text. /export notes.txt writes straight to that file.

Shuriken

The harness for your coding agents.

Run Claude Code, Codex and Gemini CLI on your own computers, move chats to your next account at a limit, and follow every chat from any device.

[Download](https://shuriken.sh/download)

[Other platforms](https://shuriken.sh/download#main)

## Keep reading

- [Keep the same chat when you switch Claude accounts: Guide 27 Oct 2026 6 min read Claude Code saves each chat in its config folder. How to continue a session on another Claude account by hand, what breaks, and how Shuriken does it.](https://shuriken.sh/guides/keep-the-same-chat-across-claude-accounts)
- [How to change the model in Claude Code: Guide 27 Oct 2026 3 min read Change the model in Claude Code with /model, claude --model, an environment variable or settings.json. /model wins; Enter in its picker sets your default.](https://shuriken.sh/guides/change-model-in-claude-code)
- [Claude Code API Error 400 on tool_use: what to do: Guide 27 Oct 2026 4 min read A Claude Code API Error 400 about tool use means the saved history has a tool call out of step with its result. Update, then rewind past the broken turn.](https://shuriken.sh/guides/claude-code-api-error-400-tool-use)
- [Claude Code custom slash commands: make your own: Guide 27 Oct 2026 3 min read Make your own Claude Code slash commands: one Markdown file in .claude/commands or a skill, with arguments, shell output and allowed tools. With examples.](https://shuriken.sh/guides/claude-code-custom-slash-commands)
- [Claude Code thinking and effort levels, explained: Guide 27 Oct 2026 4 min read Claude Code's effort levels, low to max, set how much Claude thinks before it acts. What each level is for, the defaults, ultrathink, and how to set it.](https://shuriken.sh/guides/claude-code-effort-levels)
- [Claude Code hooks not working? Why they don't fire: Guide 27 Oct 2026 6 min read A Claude Code hook that never fires is either not loaded (missing from /hooks) or loaded with a matcher that matches nothing. The causes and their fixes.](https://shuriken.sh/guides/claude-code-hooks-not-working)
- [Claude Code keyboard shortcuts and commands cheat sheet: Guide 27 Oct 2026 5 min read Every Claude Code keyboard shortcut worth knowing, for Mac and Windows, plus the slash commands that matter. One page, checked against Anthropic's docs.](https://shuriken.sh/guides/claude-code-keyboard-shortcuts)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
