By default, Claude Code deletes a session's transcript once it has gone unused for longer than cleanupPeriodDays, which is 30 days unless you change it. The sweep runs in the background after a session starts. To stop it, add "cleanupPeriodDays": 3650 to ~/.claude/settings.json and back up ~/.claude/projects. If you see No conversation found with session ID, the file may be gone, or it may still be on disk and Claude Code is looking somewhere else. This guide covers both, plus a third cause the setting does not fix.
What does "No conversation found with session ID" mean?#
You run claude --resume, or /resume inside a session, and either the list is empty or you get:
No conversation found with session ID: 3f2c…
Claude Code keeps every conversation as a JSON Lines file on your machine:
~/.claude/projects/<the project path, with non-alphanumeric characters replaced by ->/<session id>.jsonl
A project at /Users/ada/code/api gets a folder called -Users-ada-code-api. That error means Claude Code found no transcript for that ID in the places it searched. There are three separate reasons that happens, and they need different fixes:
| Cause | What you see | Does cleanupPeriodDays fix it? |
|---|---|---|
| The startup cleanup deleted the file | Older sessions are missing everywhere | Yes, for future sessions |
| The file exists but was looked up in the wrong place | /resume is empty in one folder, fine in another | No |
| An update or restart removed the file anyway | Recent sessions gone despite a high setting | No; only a backup helps |
Why does Claude Code delete conversations after 30 days?#
Because that is the default retention period, and you can change it. Claude Code's settings reference says transcripts older than cleanupPeriodDays are deleted, with a default of 30 days and a minimum of 1.
A few things about it that the top results skip over:
- It runs when you use Claude Code, not on a schedule. The docs describe "a background sweep after a session starts". A transcript that has sat unused past the limit can go the next time you start a session, and the sweep covers every project on the machine. Two exceptions in the current docs: transcripts of sessions started or last continued in Claude Desktop or Cowork are kept at any age (v2.1.248 and later, unless an admin or
desktopSessionCleanupPeriodDayssets a limit), and the sweep pauses when Claude Code can't safely determine the retention period. - It deletes the file; it does not move it to the Trash. #64999 describes files removed with
fs.unlink, bypassing the Windows Recycle Bin, and #62476 asks for a soft-delete folder instead. #85466 describes about 950 transcripts removed in one pass, on an app start the reporter believes followed an update. - It only takes the conversation. Your code, git history,
CLAUDE.mdfiles and settings are untouched. What goes is the reasoning trail: the dead ends you rejected, the debugging, the "why" behind a change. The/resumelist loses the session too. 0does not mean "never". Before v2.1.89, setting0silently stopped transcripts being written at all (#23710). Since then it is rejected with a validation error. Use a large number.
As of September 15, 2026, #62476 (opened May 26, 2026) is still open, and the documented default is still 30.
Why can't Claude Code find a session that is still on disk?#
Sessions are filed by project directory. So whether one "exists" depends on where you are standing when you ask. #33912 is a clear example (on v2.1.74, closed as not planned): the .jsonl file was right there, and every resume attempt still returned No conversation found.
Here is how lookup works as of Claude Code's current session docs:
claude --continueonly resumes the most recent session in the current directory.- The
/resumepicker shows sessions from the current worktree by default. PressCtrl+Wto widen it to every worktree of the repository, orCtrl+Ato see every project on the machine. claude --resume <id>checks the current project and its worktrees first, then every other project on the machine. Before v2.1.223 it stopped at the current project, so older builds needed you tocdinto the original folder. If a hand-copied duplicate of the transcript exists in two places, it reports not found rather than guessing.- Sessions started with
claude -por the Agent SDK are left out of the picker and out of--continue. They can still be resumed by ID. Scripts and tools built on the SDK create these, which is why they never show in the list. - The desktop app, Claude Code on the web and the VS Code extension each keep their own history. A session started in one does not appear in the CLI's picker.
That produces the common "it vanished" cases:
- You renamed or moved the project folder. The transcripts live under a folder named after the old path. The new path's picker is empty.
Ctrl+Afinds them. (Moving a session with/cdrelocates it to the new directory's storage; moving the folder in Finder does not.) - You opened a git worktree or a subfolder. Different directory, different default list.
Ctrl+WorCtrl+Abrings them back. - You opened the project on another Mac. The files were never there.
~/.claude/projectsis local to one machine and nothing in the CLI syncs it.
Why were transcripts deleted even with cleanupPeriodDays set high?#
Several reports describe transcripts disappearing with retention set to years. One has an explanation; the others do not:
- #86991 (v2.1.146): with
cleanupPeriodDays: 9999, projects were pruned to one transcript each. A Claude Code maintainer explained that ifsettings.jsonwas not valid JSON at the moment cleanup ran, that version fell back to the 30-day default, and said it is fixed in a recent release. (The reporter had suspectedautoUploadSessions; the maintainer said that setting has no effect in public builds.) - #62272 (v2.1.91): files deleted with
cleanupPeriodDays: 36500, which the reporter correlated with VS Code restarts, CLI and extension auto-updates, and Claude Desktop running alongside. Closed as a duplicate. - #78578: the VS Code extension updated from 2.1.211 to 2.1.212, restarted into a fresh session, and the multi-week transcript was gone. Closed as not planned after a period of inactivity.
As of September 15, 2026, we found no published root cause for #62272 or #78578. Two practical conclusions: keep settings.json valid JSON (an editor that checks it helps), and treat the setting as reducing the risk while a backup removes it.
The 60-second fix: raise the setting and back up the folder#
1. Raise retention. Open ~/.claude/settings.json (create it if it does not exist) and add the key, keeping whatever else is in the file:
{
"cleanupPeriodDays": 3650
}
That is about ten years. Put it in your user settings file, not a project's shared .claude/settings.json, so it applies everywhere and does not depend on a repo. Make sure the file is still valid JSON after editing, and run /status after launch to check for a settings warning.
2. Back up the transcripts. Copy the folder somewhere Claude Code does not manage. Leave out --delete, so a file removed from the source is kept in the copy:
mkdir -p ~/Backups/claude-projects
rsync -a ~/.claude/projects/ ~/Backups/claude-projects/
To run it every hour, add a line with crontab -e:
0 * * * * rsync -a "$HOME/.claude/projects/" "$HOME/Backups/claude-projects/"
Time Machine covers ~/.claude too, as long as your home folder is not excluded. It is worth checking before you need it.
3. Before an update, resume what matters. If a session is important, open it after an extension or CLI update, before you start new work. Reports #62272 and #78578 both involve the restart that follows an update.
How to recover a Claude Code conversation that is already gone#
Honestly: only from a copy. Claude Code has no restore command and no trash folder for transcripts.
Where to look:
- Time Machine. Browse
~/.claude/projects/<project folder>/in a snapshot from before the deletion and restore the.jsonl. The reporter of #62272 published a helper for exactly this, restore-claude-history. - Your own backup, iCloud Drive or Dropbox copies, or another machine you worked on.
~/.claude/history.jsonl. It records prompts you typed. It will not give you the model's replies, the tool calls or the file diffs, but it can remind you what you asked.
If you find the .jsonl:
- Put it back under
~/.claude/projects/in the folder named after the project's current path (for example-Users-ada-code-api). Create the folder if needed. - Make sure only one copy of that session ID exists across all project folders, or
--resume <id>will report not found. - Run
claude --resume <session id>from the project directory.
What a restored transcript gives back: the full conversation, including tool calls and results, and the model and agent it was using. It does not bring back the state of your files at the time; that is what git is for. On Pro and Max plans, resuming a session that has been idle for more than about an hour and is over 100,000 tokens offers to resume from a summary instead of the full history.
Do Codex, Gemini CLI and Grok have the same problem?#
The lookup problem, yes; the default deletion, at least for Gemini CLI. Each of these CLIs keeps conversations in its own home directory, and each refuses a resume it cannot honour. These are the messages we saw when we ran each tool against a missing thread on our own Mac on August 31, 2026 (wording can change between versions):
| Tool | Where it keeps conversations | What a lost thread says |
|---|---|---|
| Claude Code | ~/.claude/projects/<path>/<id>.jsonl | No conversation found with session ID: … |
| Codex | ~/.codex/sessions/<year>/<month>/<day>/rollout-…-<thread>.jsonl | no rollout found for thread id … |
| Gemini CLI | ~/.gemini/tmp/<project>/ | No previous sessions found for this project. (exit code 42) |
| Grok | ~/.grok/sessions/<encoded path>/<thread>/ | Failed to restore session from remote: … 404 |
Two notes on that table:
- Gemini CLI also deletes after 30 days by default. Its configuration reference sets
general.sessionRetentiontoenabled: true,maxAge: "30d". RaisemaxAgeor setenabledtofalsein itssettings.json. - In our testing, Grok printed a line that looks like an error and is not.
Session "…" not found locally, restoring conversation from remote...is a status line, after which Grok tried to fetch the conversation remotely. OnlyFailed to restore session from remotemeant it could not be restored.
If you switch between these tools, each one's memory of a project lives in a different place under a different key. Moving work between them loses context unless something carries it across. We wrote about that in running Claude Code, Codex, Gemini and Grok from one app.
The durable fix: keep the conversation with the project#
The settings change and the backup deal with deletion. They do not change the underlying design: the conversation lives in a folder named after a path, in a tool's private directory, on one machine. So a rename hides it, a second Mac never has it, and an update can remove it.
This matters to us because Universe, the Mac app we make, runs Claude Code, Codex, Gemini CLI and Grok as engines. So Universe keeps its own record of each conversation instead of relying only on each CLI's private copy.
How Universe handles it:
- The record is files you can open. Sessions live in
~/.universe, with their transcripts and the files the agent made. The app's database is an index rebuilt from those files, so deleting it loses nothing. - Switching engines keeps the conversation. Change the model mid-conversation and the new engine is given the conversation so far, instead of starting blank.
- Signed in, it is backed up. When you sign in, session transcripts and a backup of the model's conversation memory sync to Universe's cloud. That is also how a session can move to a second Mac and keep its history.
Where Universe fits, and where it does not#
- It does not protect sessions you run in a terminal. A plain
claudesession outside Universe still lives in~/.claude/projectsand is still subject to cleanup. SetcleanupPeriodDayseither way. - It is Mac only (Apple silicon or Intel, macOS 13 or later), and it needs your own model account: Claude Pro or Max, a ChatGPT Plus, Pro or Business plan, a Google account for Gemini, an xAI key, or a local open model.
- Cloud backup needs an account. The app works without one, but then the record is only on that Mac, in
~/.universe. - If all you want is Claude Code in a terminal with your history kept, the settings change plus an hourly
rsyncis the whole answer, and it is free.
If you would rather your agents' conversations stay with the work across renames, restarts, engine switches and machines, see what Universe does, check the plans (there is a $0 plan), or download it.
Questions#
- Does /clear delete my Claude Code conversation?
- No. /clear empties the context window and starts a fresh conversation, but Claude Code saves the previous one as its own session. You can get back to it with /resume, or from the rewind menu in the same process. It is still a transcript file under ~/.claude/projects, so the retention cleanup applies to it like any other session.
- Is compacting a conversation the same as deleting it?
- No. /compact replaces the history the model carries forward with a summary, so details the summary leaves out are no longer in context. It does not remove the session, and it has nothing to do with cleanupPeriodDays. Cleanup deletes the whole transcript file once it has gone unused for longer than the retention period.
- Can I set cleanupPeriodDays to 0 to keep everything?
- No. Before v2.1.89, 0 silently switched transcript writing off, so nothing was kept. Claude Code's changelog says 0 is now rejected with a validation error, and the docs give a minimum of 1. To keep sessions, set a large number such as 3650 in ~/.claude/settings.json.
- Can I sync Claude Code sessions between two Macs?
- There is no built-in sync in the CLI. Sessions are local files under ~/.claude/projects, filed in a folder named after the project's path. You can copy them, but they only line up if the project sits at the same path on both machines. Otherwise, pass the session ID to claude --resume, which searches every project folder on the Mac from v2.1.223.
- Can I recover a Claude Code conversation that was already deleted?
- Only from a copy. Cleanup removes the file outright rather than moving it to the Trash, so the usual places to look are Time Machine, another backup of ~/.claude/projects, or a synced folder. ~/.claude/history.jsonl may still hold the prompts you typed, but not the model's replies or tool calls.