Why your Claude Code history disappears
Claude Code deletes a terminal session's transcript after 30 days without use, with no message, because cleanupPeriodDays defaults to 30. Set it higher in ~/.claude/settings.json to keep your history.
Checked against Claude Code's documentation on 31 October 2026.
Where Claude Code stores conversation history#
Claude Code writes each session to a plain JSONL file on your Mac:
~/.claude/projects/<project>/<session-id>.jsonl<project> is the full path of the folder you started Claude Code in, with every character that is not a letter or a digit replaced by -. A session started in /Users/you/code/app is in ~/.claude/projects/-Users-you-code-app/. The file holds your messages, Claude's replies, tool calls and tool results. Subagent transcripts and large tool outputs sit in a folder named after the session, next to it. If you set CLAUDE_CONFIG_DIR, all of this lives under that folder instead of ~/.claude.
What deletes it#
After a session starts, Claude Code runs a background sweep. It deletes transcripts older than cleanupPeriodDays, which defaults to 30 days. It shows no message. A session you have not used for longer than that is gone from the /resume picker, and its file is gone from the disk. The sweep also removes that session's subagent transcripts and tool outputs.
What the sweep leaves alone:
- Sessions you started or last continued in Claude Desktop or Cowork, kept at any age from v2.1.248. Earlier versions delete them on the 30-day rule, and Claude Code's docs list a few setups where that rule still applies.
desktopSessionCleanupPeriodDaysadds an age limit, and a transcript goes only once it is older than both numbers - Auto memory, the notes Claude keeps in
~/.claude/projects/<project>/memory/
Keep transcripts longer#
Add the setting to your user settings file:
{
"cleanupPeriodDays": 3650
}- The value is a whole number of days, at least 1
0fails validation, so pick a large number such as 3650 for long retention- If your organization sets
cleanupPeriodDaysin managed settings, its value wins over yours - If the file cannot be parsed, or
cleanupPeriodDaysfails validation (0does), Claude Code pauses the sweep and shows a warning in/status
To check that it holds, list the transcripts older than 30 days after your next session has started. With the default they would be gone:
find ~/.claude/projects -name '*.jsonl' -mtime +30 | headA transcript that was already deleted does not come back with this setting. A copy may still be in Time Machine or another backup.
How to see your Claude Code chat history#
Before you assume a session was deleted, check that its file still exists:
ls ~/.claude/projects/*/<session-id>.jsonl # a session, by its ID
ls -lt ~/.claude/projects/*/*.jsonl | tail -5 # the 5 oldest transcripts leftIf the file is there, the picker may simply not list it. /resume shows the sessions of the current worktree, and sessions that added this folder with /add-dir. In the picker, Ctrl+W widens the list to every worktree of the repository and Ctrl+A to every project on this Mac. claude --resume <session-id> works from any folder.
Search it from your other agents with Onadit#
Raising cleanupPeriodDays keeps the files, 1 folder per project. It does not make them searchable, and Codex or Cursor cannot read them. Onadit is a Mac app that keeps a copy of your sessions in its own archive, where the agents you connect can search them over MCP. Its Capture feature does the copying.
- Every hour, Capture reads new and changed sessions in
~/.claude/projects/. It never changes those files - Claude Code or Codex, signed in with your own account, judges each session: worth keeping, unsure, or trivial. These calls count against your plan with that provider
- A session worth keeping is saved with its full transcript, a summary and its project folder, in
~/Library/Application Support/Rift/, which Claude Code's sweep does not touch - Nothing in Onadit deletes saved sessions on a schedule. They stay until you remove them
- Claude Code, Codex, Cursor and the Claude desktop app can search the archive, see Give Claude Code and Codex the same memory
Its limits:
- Capture is off until you turn it on, and it needs Search by meaning
- It starts on the day you turn it on. Sessions already on your Mac are not imported, unless you resume one later. So raise
cleanupPeriodDaysas well - A trivial session is not stored, and one the judge is unsure about waits in the review queue
- Session text is sent to the provider of the tool that judges it, and to an embedding service for Search by meaning. What leaves your Mac lists every call
- Onadit is free for 7 days, then €5 a month until 31 December 2026 and €9 a month after, VAT excluded. Without a license, capture and Search by meaning pause, and your archive and keyword search stay. See Your free week and your license
- It needs a Mac with Apple silicon and macOS 14 or later
Turn on Capture#
In Onadit.app, open Privacy and click Search by Meaning, then open Capture and click Turn On. From the command line, once Search by meaning is on:
~/.rift/bin/onadit onboard --enable-capture
~/.rift/bin/onadit capture # run once now instead of waiting for the hourA package install does not put onadit on your PATH, hence the full path. Capture covers what it reads, how a session is judged and what is stored.
Last updated 31 October 2026. This page is also available as Markdown, and every page is listed in llms.txt.