Claude Code history: where conversations are stored, and how to keep them
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
| File | What it holds | How long |
|---|---|---|
~/.claude/projects/<project>/<session-id>.jsonl | the whole conversation: your messages, Claude's replies, tool calls and output | 30 days by default |
~/.claude/history.jsonl | only the prompts you typed, with the folder and time, across every project | past the cleanup |
| Caprock's database | every session, read as it is written | until 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
Reopen the last session in this folder
- 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
| When | What happens |
|---|---|
| Days 0–30 | on disk; you can resume or export it |
| After 30 days | deleted in a background sweep after a session starts, with no message |
| Once deleted | gone; 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
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
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 exportwrites 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
| Viewer | What it is | How it keeps history |
|---|---|---|
| claude-code-history-viewer | a desktop app or local web server; Claude Code and some thirty other assistants | a one-click backup you run |
| claude-code-transcripts | turns session files into HTML pages | the pages you make, one session or all |
| Caprock | a desktop app that records every session, live, with cost per repository | automatically, 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
- Claude Code docs — Data usage: local retention
- Claude Code docs — The .claude directory
- Claude Code docs — Settings reference: cleanupPeriodDays, desktopSessionCleanupPeriodDays
- Claude Code docs — Commands (/resume, /export)
- jhlee0409/claude-code-history-viewer
- simonw/claude-code-transcripts
- Caprock UI spec — Memory
Try it
The record of every coding agent you run, the sessions it did not start included. Free, open source; nothing leaves your machine.
Notarized by Apple. One file for Apple silicon and Intel, macOS 13 or later.
Or run it yourself:
Paste in Terminal: it installs Caprock and opens it.Or with Homebrew: brew install --cask dspv/tap/caprock-app