Claude Code history: where conversations are stored, and how to keep them

Dmitriy Solodukha · checked against Caprock v0.140.1

Where Claude Code stores conversation history, why it disappears after 30 days, how to resume or export a session, and how to keep and search all of it.

Claude Code writes every conversation to a JSON-lines file under ~/.claude/projects/ and, by default, deletes it after 30 days. Until then you can resume it or export it; after that, only your own prompts survive — Claude's replies are gone unless something kept a copy.

Where Claude Code stores conversation history

Where a Claude Code conversation is kept, from the Claude Code docs and Caprock's spec.
FileWhat it holdsHow long
~/.claude/projects/<project>/<session-id>.jsonlthe whole conversation: your messages, Claude's replies, tool calls and output30 days by default
~/.claude/history.jsonlonly the prompts you typed, with the folder and time, across every projectpast the cleanup
Caprock's databaseevery session, read as it is writtenuntil you say otherwise

<project> is the folder you ran claude in, with every character other than letters and digits turned into - — /Users/me/dev/api becomes -Users-me-dev-api. Every line of a transcript is one event, and the transcripts are the only full record of a conversation.

Resume or export a conversation

  1. 1

    Reopen the last session in this folder

  2. 2

    Pick a past session from a list (/resume inside a session)

Inside a session, /export writes the conversation as plain text, to the clipboard or a file you name. Both work only while the transcript exists — more on resuming.

Why old chat history disappears

What happens to one transcript, with the default setting.
WhenWhat happens
Days 0–30on disk; you can resume or export it
After 30 daysdeleted in a background sweep after a session starts, with no message
Once deletedgone; raising the setting brings nothing back

Claude Code keeps transcripts "for 30 days by default to enable session resumption". The setting is cleanupPeriodDays in ~/.claude/settings.json: default 30, minimum 1, and the docs suggest a large value such as 3650 to keep everything. Raise it before the sweep reaches what you want to keep. Sessions started or last continued in the Claude desktop app are the exception: they are kept at any age unless desktopSessionCleanupPeriodDays is set.

{
  "cleanupPeriodDays": 3650
}

On the author's machine, counted on 1 October 2026:

67 of 114
Claude Code sessions whose transcript is no longer on disk
$7,808
of work in them, at API list prices — 56% of the total
51,093
replies from Claude in them, still searchable

Transcript deletedStill on disk

Jul17 / 17$6,362 of work, by session start
Aug44 / 59
Sep6 / 38
Claude Code sessions by the month they started.

Ten of the 67 lived in a git worktree deleted by hand; the cleanup removed the other 57, every one from July among them, before anyone looked — the full count.

A history viewer that keeps everything

Memory: what the agents wrote, newest first, each with its project and a link to the session. Example sessions.

Caprock reads the transcripts already on disk the first time it runs, then every new one as it is written, into a local database that keeps them until you say otherwise. The cleanup can delete the files; Caprock's record stays.

  • Memory searches what Claude wrote across every session — the conclusion at the end of a task, the explanation you scrolled past. Every result links to the moment in its session.
  • Every session stays listed, with its cost, files and timeline, after its transcript is gone; when you try to continue one whose file Claude Code deleted, Caprock says that is why.
  • Export — caprock export writes the whole record as TSV, CSV or JSON lines for your own tools.

What it cannot do: bring back anything deleted before Caprock first read it, or give you a readable copy of one conversation the way /export does — caprock export writes rows (with --payload, the raw prompts and replies), not a transcript.

Other history viewers

Three ways to browse Claude Code history, from each project's README.
ViewerWhat it isHow it keeps history
claude-code-history-viewera desktop app or local web server; Claude Code and some thirty other assistantsa one-click backup you run
claude-code-transcriptsturns session files into HTML pagesthe pages you make, one session or all
Caprocka desktop app that records every session, live, with cost per repositoryautomatically, as each session is written

If you want a viewer and are happy to back up by hand, claude-code-history-viewer browses, searches and shows cost. If you want a conversation as a page to read or publish, claude-code-transcripts makes one.

Questions people ask

Where is Claude Code chat history stored?
In ~/.claude/projects/<project>/<session-id>.jsonl, one JSON-lines file per session. ~/.claude/history.jsonl keeps only the prompts you typed.
How long does Claude Code keep conversation history?
30 days by default. Older transcripts are deleted in a background sweep after a session starts, with no message.
How do I keep Claude Code history longer?
Raise cleanupPeriodDays in ~/.claude/settings.json; the docs suggest a large value such as 3650. It cannot bring back files already deleted.
Can I recover a deleted Claude Code conversation?
No. Once the transcript is deleted, Claude Code cannot resume or export it; only a copy kept elsewhere survives.
How do I export a Claude Code conversation?
Run /export inside the session. It writes the conversation as plain text, to the clipboard or a file you name.

Sources

Try it

The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.

Download for Mac

Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.

Or run it yourself:

curl -fsSL https://caprock.dev/mac.sh | sh

Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app