How to delete Claude Code sessions, and what you lose
they are files under ~/.claude/projects: rm is the whole operation, and cleanupPeriodDays does it on a timer
Every session your agent runs is written to disk as it happens. Claude Code puts JSONL under ~/.claude/projects, one directory per project and one file per session; Codex writes ~/.codex/sessions/**/rollout-*.jsonl (deleting those); Cursor keeps chats in a SQLite database (deleting those). Where each agent writes has the rest.
Nobody tells you these files exist until they are large — 875 of them and 1.6 GB on the laptop measured below, one file of which was 586 MB.
How to delete Claude Code sessions
From the terminal, a whole project goes with one command: claude project purge, in Claude Code since 2.1.126. It deletes the project's transcripts, and with them its memory/ directory, the file-edit history of each session, and the project's entry in ~/.claude.json (trust, prompt history, MCP servers). Run it with --dry-run first; it prints exactly that list.
A single session has no command. It is a file, and deleting the file is the whole operation. The directory name is the project path with slashes turned into dashes, the file name is the session id. (claude rm <id> is for background sessions started with claude --bg, not for these.)
Or pick it from a list. In deja's terminal UI, D on a session erases it from Claude Code, or from Codex, Cursor CLI, Gemini CLI, Qwen Code, Copilot CLI and the other agents whose sessions are files of their own, and drops deja's copy with it. It asks first and there is no undo. deja delete <id> does the same from a script; --dry-run lists the files it would remove. A session that is still running is refused.
/clear does not delete anything either. It starts a new conversation with an empty context; the one before it stays on disk as its own .jsonl.
# every session of this project, and the state that goes with it
claude project purge --dry-run # see what would be deleted
claude project purge
# every project
claude project purge --all
# one session: see what is there, newest first, then remove the file
ls -t ~/.claude/projects/-Users-you-project/*.jsonl
rm ~/.claude/projects/-Users-you-project/<session-id>.jsonl
# or for any agent: D in the deja TUI, or
deja delete <session-id> --dry-run # the files it would remove
deja delete <session-id> # from the agent and from deja, no undo
# or let Claude Code do it: sessions older than N days go on their own
# ~/.claude/settings.json
{ "cleanupPeriodDays": 7 }
Three things people expect and do not get. A session you delete disappears from claude --resume at once; that list is built from the files. Your prompt history is a separate file, ~/.claude/history.jsonl, and stays until you delete it too. It keeps what you typed and pasted with the session id, so deja reads the prompts of a session whose transcript is gone from it, though the replies and tool calls are not there. And there is no archive: a session that is no longer in --resume was swept by cleanupPeriodDays, and the file is gone, not archived. Before you delete by hand, the sections below say what the files cost you and what you lose.
If one of those sessions might matter later, index them before you delete: deja keeps a searchable copy of every session it has read, and deja resume <id> --write-back puts one back where claude --resume finds it. Already gone? What is still recoverable, and what No conversation found with session ID means.
How big they actually get
One developer's ~/.claude/projects: thirteen projects, two months of heavy daily use.
| Measure | Value |
|---|---|
| Session files | 875 |
| Total size | 1.6 GB |
| Median file | 304 KB |
| 90th percentile | 644 KB |
| Largest single file | 586 MB |
The distribution is the interesting part: a typical session costs a third of a megabyte, and a handful of runaway sessions carry most of the gigabytes. Growth is driven by tool output, not by how much you typed — a session that catted large files or ran a chatty build is orders of magnitude bigger than one where you talked through a design.
To find yours:
du -sh ~/.claude/projects find ~/.claude/projects -name '*.jsonl' -size +50M
What is inside one
A Claude Code session file is JSON Lines: one JSON object per line, appended as the session runs. Each record carries a role, a timestamp, a session id and the payload — your prompt, the assistant's reply, or a tool call with its result. Codex, Copilot CLI and Antigravity use the same line-per-record shape with different field names; Cursor, Zed, Goose and Hermes use SQLite instead. The format registry documents each one field by field.
Two consequences worth knowing. It is plain text, so grep works and so does any tool you write. And it is verbatim: whatever scrolled past in your terminal is in there, including anything a command printed. Treat the directory as you would your shell history.
Claude Code deletes them for you
By default Claude Code keeps a transcript for 30 days and then removes it — the setting is cleanupPeriodDays in ~/.claude/settings.json, documented under data retention. Nothing announces it; people notice when --resume no longer lists a session they had in June. If you want the files to stay, raise the number before the month is up:
{ "cleanupPeriodDays": 3650 }
deja keeps what it indexed: a transcript the sweep removes stays searchable, because the index does not follow a single file out the door — only deja forget drops a session on purpose. The files themselves, though, are gone, and so is --resume for them, until you put one back: the Deleted tab of the interactive screen (deja with no arguments) lists what deja still holds, and R writes a session back where --resume finds it, as does deja resume <id> --write-back. deja install says when the sweep is on, and once a week the note at session start says how many deleted sessions deja kept, with an id to put back.
The sweep is Claude Code's own, not a cron job, and it pauses whenever the client cannot safely determine the retention period — which is why the machine measured above, on the default setting, still holds 69 files older than 31 days. Do not read that as safety. The documented behaviour is deletion after 30 days, and the day the sweep runs is the day the June session goes.
Are old sessions archived anywhere?
Not for the terminal sessions under ~/.claude/projects. There is no archive, no trash and no recycle bin there: a session that has left claude --resume was swept by cleanupPeriodDays and its file is deleted. The resume list has no store of its own — it is built by reading ~/.claude/projects each time — so a session missing from it is a file missing from disk.
Two things are worth checking before you accept that a session is gone. A Time Machine or Backblaze snapshot from before the sweep still holds the JSONL file, and restoring it puts the session back in --resume. And an index built while the file existed still answers from it: that is the one copy that survives the sweep by design.
The same question in VS Code
The Claude Code extension for VS Code runs the same Claude Code underneath and writes the same files: its conversations are the JSONL under ~/.claude/projects, in the directory named after the workspace folder. Everything above applies unchanged, claude project purge included, and a deleted file leaves the extension's list of past conversations the same way it leaves --resume.
GitHub Copilot Chat in VS Code is a different agent and does not use ~/.claude. Its sessions live in the workspace storage of the VS Code profile — ~/Library/Application Support/Code/User/workspaceStorage/<hash>/chatSessions on macOS, ~/.config/Code/User/workspaceStorage on Linux, %APPDATA%\Code\User\workspaceStorage on Windows — one JSONL file per chat (JSON before VS Code 1.109, and newer builds also write GitHub.copilot-chat/transcripts beside it), under a directory whose name is a hash rather than the project's — the file beside it is what says which workspace it belongs to. Deleting VS Code Copilot Chat history covers the paths and what the editor does when they are gone; where sessions are stored has the same for every other agent.
Can you delete them yourself?
Yes — nothing in the agent breaks. What you lose:
- Resume.
claude --resumelists sessions by reading these files. Delete one and it disappears from the list. - Any history search, forever. Anything that answers "have I hit this before?" reads these files. Deleted transcripts are not recoverable and cannot be re-derived — the agent will not reconstruct them.
- Your own audit trail. It is the only record of what an agent actually ran in your repository. See auditing an agent.
If you need the space back, delete narrowly rather than emptying the directory:
# the few outliers, which is usually all the space you need find ~/.claude/projects -name '*.jsonl' -size +100M -ls # a project you will never open again claude project purge ~/code/old-project
Deleting by age is the tempting one and the one to avoid: old sessions are exactly the ones you no longer remember, so they are worth the most per byte. If you do want it, deleting old Claude Code sessions has the find -mtime line and what it frees.
Backing them up
They are ordinary files, so any backup tool works. If you want them readable somewhere else — a different machine, a different agent, or as Markdown — see exporting sessions and across machines.
Making them useful instead of just large
The files are already a complete record of every problem you have solved. What they lack is a way in: opening the right 300 KB file out of 875 is not a thing anyone does by hand.
curl -fsSL https://raw.githubusercontent.com/vshulcz/deja-vu/main/install.sh | sh deja install --auto
deja builds a local index over those transcripts — every agent on the machine, including the sessions from before it was installed — and answers from them in milliseconds. Indexing a few gigabytes takes about ten seconds. Without semantic search from deja embed, indexing and search make no network calls, and credentials are stripped as the index is built (privacy). On the machine measured above the index is 204 MB against 1.6 GB of transcripts; what memory costs has the token side of it.
Wiring it into the agent you use is one command each: Claude Code, Codex, Cursor, and the rest.
Does your agent remember previous conversations? · Finding a session · Getting started
Found this useful? Star deja-vu on GitHub.