Axiom Lift

Claude Code · session history

Claude Code deleted your chat history? How to stop the 30-day cleanup

Developers keep finding their Claude Code sessions gone after 30 days. Why the cleanup does it, the settings fix step by step, the trap that undoes it, and what to do if it's already gone.

30 September 2026

A timeline: a Claude Code session saved on day 0, untouched to day 30, deleted at the next start without a warning

The issue, as reported

Since July, the Claude Code issue tracker has collected the same report again and again: someone goes back to a session they need, and it is gone.

The most discussed of them says the default cleanup permanently deleted session transcripts at startup with no notice, taking months of working context across several large projects. Its point is the one most reports make: the conversation holds the reasoning and the decisions, and the files Claude produced (CLAUDE.md, plans, roadmaps) don't.

Others describe the scale. In one, a single sweep hard-deleted about 950 transcripts covering April to July, with no warning and no trash. Most came back only because Windows shadow copies happened to cover the sweep and there were hand-made backups from earlier in the summer. In another, the user's own settings said to keep transcripts for 36,500 days, but a 7-day value in a throwaway repo won, and the next sweep deleted about four months of other projects' history.

A request to ask about retention during first setup gathered the most reactions of the group and was closed as not planned in July; it was filed again in September. The newest reports are still arriving: on 17 September a developer opened Claude Code to resume a session from a few months back, and it was deleted at that moment. On Hacker News, a post titled "Claude Code Deletes Your Context History from Your Device After 30 Days" got one reply, and it was the setting.

Reported in

Why it happens

Claude Code saves every conversation as a JSONL file at ~/.claude/projects/<project>/<session-id>.jsonl (docs). A setting called cleanupPeriodDays decides how long those files live. According to the settings reference:

What the sweep deletes, and what survives it

Deletedthe session transcript, so it stops appearing in /resume
Deletedsubagent transcripts, large tool outputs, the file snapshots used for checkpoint restore, and plan files (full list)
No trasha hard delete, with no message; there is no trash folder to restore from
Partial~/.claude/history.jsonl is left alone: the prompts you typed survive, Claude's replies don't
Keptsessions started or last continued in Claude Desktop or Cowork, from v2.1.248: kept at any age unless you set desktopSessionCleanupPeriodDays. Before that version they were swept on the same 30 days

Anthropic's reason is a fair one. Transcripts are plain text and hold whatever passed through a tool: file contents, command output, sometimes credentials. The company told The Register that keeping them indefinitely "creates real security and privacy risks", and that the 30-day default balances resuming recent work against holding that data longer than needed.

One more detail explains the stranger reports. cleanupPeriodDays can be set in any settings file, and the highest level that sets it wins: a project's .claude/settings.json or .claude/settings.local.json beats your user file. That is how a 7-day value in one throwaway repo ran the sweep for every project on the machine.

Which cleanupPeriodDays wins: managed settings, then the project's .claude/settings.json, then your user file; a project's 7 beats a user's 36,500
The highest level that sets cleanupPeriodDays wins, and the sweep runs for every project on the machine.

How to fix it today

These steps are for Claude Code and come from Anthropic's own documentation.

  1. Set a long retention period in your user settings

    Open ~/.claude/settings.json (create it if it doesn't exist) and add the key. The docs suggest a large value such as 3650, ten years. If the file already has settings, add the line inside the existing braces, with a comma after the line before it. Don't use 0: it fails validation.

    {
      "cleanupPeriodDays": 3650
    }
  2. Check the file was read

    Start Claude Code and run /status. If a settings file can't be read or parsed while cleanupPeriodDays is set, Claude Code pauses the sweep and shows a warning there until you fix it (docs).

  3. Find lower values in your projects

    Any project file that sets a lower number overrides yours. Search the folder where your repos live (change ~/code to yours). Raise or delete any low value you find. Repeat after cloning a repo that ships its own .claude/settings.json.

    grep -rn --include='settings*.json' cleanupPeriodDays ~/code
  4. Check for managed settings

    If your organisation deploys Claude Code with managed settings that set cleanupPeriodDays, that value wins over everything you set. Ask whoever manages it.

  5. Update Claude Code if you use the desktop app

    Run claude --version. On v2.1.248 or later, Desktop and Cowork sessions are kept at any age by default. Earlier versions delete them after cleanupPeriodDays, which fits the desktop reports of sidebar entries that open to "Session not found on disk".

  6. Keep a copy of the sessions that matter

    Name them with /rename, so claude --resume <name> finds them. Save a readable copy with /export <filename>. Include ~/.claude/projects/ in your backups (Time Machine, File History): in the 950-transcript report, backups were what brought the work back.

If it's already gone

The sweep is a hard delete, so usually it's gone. Check your backups first. Then look at ~/.claude/history.jsonl: the sweep doesn't touch it, and it holds every prompt you typed with its time and project, though not Claude's replies (docs).

What the fix doesn't cover

Two limits to know first

It can't bring anything back. It only protects what is still on disk. One lower value anywhere undoes it. Every repo you clone can carry its own setting, so the check in step 3 is never finished for good.

How Axiom Lift solves it

Axiom Lift is a small helper on your computer. It reads the session files Claude Code, Codex and OpenCode already keep and saves every prompt, decision, requirement and result to your account as you work. It never edits those files. The full conversation stays in your account, searchable, with the decisions filed, so it no longer depends on one file on one disk.

It also hands that history back. Through a read-only MCP connection, your next session can ask Axiom what was decided and why, and gets the few lines that are true now rather than the whole transcript. Keys and passwords are cut on your computer before anything is sent, and your sessions are seen by you and nobody else unless you share them (the operator can reach accounts to run and support the service).

Day 0: Axiom saves the session to your account as you work. Day 30: the file is swept from disk. Next session: your AI asks Axiom over MCP and gets it back
What Axiom keeps and hands back: the session is saved before the sweep and returned when the next session asks.

The free fix

  • Keeps the JSONL files on that one disk, as long as the setting holds
  • Needs the setting on every computer, and a check in every repo
  • Recovery is your own backups and /export copies
  • Finding means hundreds of JSONL files, in a format that changes between versions
  • Claude Code only

With Axiom

  • Saves every prompt, decision and result to your account as you work
  • Hands back the few lines that are true now, over MCP
  • Claude Code, Codex and OpenCode, and another machine
  • Doesn't stop the sweep: set cleanupPeriodDays anyway
  • Can't recover what was deleted before you installed it; it brings in what's still on disk and shows you what it found first

The Free plan covers one computer, keeps everything up to 5 GB, and lets your AI reach the last six months (up to 1 GB). Pro lets it reach all of your history and adds more computers. It runs on Mac, with Linux and Windows in beta, needs Python 3, and axiom uninstall removes it.

Keep every session, and find it again

One command in the terminal where you use Claude Code, Codex or OpenCode. Free, no card.

Try it free →

Claude, Codex and OpenCode are trademarks of their owners; Axiom works alongside them and is not affiliated.