OmniscioGuidesDelete Claude Code sessions
How to delete Claude Code sessions and chat history
Claude Code writes every conversation to a JSONL file on your machine and keeps it, along with file snapshots, plans, task lists and debug logs, until it ages out. So “delete a session” can mean three different things, and only one of them is about the file on disk.
This page covers all three: clearing a conversation, deleting a session from view, and removing a project's stored history for good. If you came here to get a conversation back instead, the resume guide and export guide cover that.
- What /clear does not do.
- Delete a project's history, with a preview first.
- Delete one session from agent view.
- What happens by itself, and the 30-day setting.
- Delete the files yourself.
- What survives a purge.
Checked against Anthropic's Claude Code documentation on November 25, 2026. By the Omniscio team. Updated .
First, what /clear does not do
If what you want is a fresh conversation rather than a deletion, /clear is the command: it starts a new conversation with an empty context and saves the previous one, which you can return to with /resume. Nothing is removed from disk, so it is not a way to delete chat history.
The transcript is still there because Claude Code saves sessions continuously as you work. The file is JSONL at ~/.claude/projects/<project>/<session-id>.jsonl, where <project> is your working directory path with its non-alphanumeric characters replaced by hyphens.
Delete a project's history with claude purge
This is the command that actually removes a project's stored conversations. claude purge takes a project path and deletes four things: transcripts and auto memory under projects/, the per-session tasks/, debug/ and file-history/ entries, matching prompt lines in history.jsonl, and the project's entry in ~/.claude.json.
It prints the full deletion plan and asks for confirmation before removing anything, and it tells you in that prompt that the deletion cannot be undone. If you are not sure what path to give it, run it with no path at all: it offers an interactive list to pick a project from. Before v2.1.288 the same command was spelled claude project purge. If no state matches the path you give it, it prints an error and exits with status 1.
The preview counts the items before anything is deleted:
claude purge ~/work/my-repo --dry-runFour options are worth knowing:
--dry-runprints the plan and deletes nothing.--yesskips the confirmation prompt, for a script.--allpurges every project at once, and deleteshistory.jsonloutright rather than filtering the lines that belong to one project. It is the one flag that reaches beyond the project you named.-isteps through the deletion plan one item at a time.
Run the dry run first when the project holds sessions you might still want. It deletes nothing.
Delete one session with claude rm
A background session is a different object: a row in agent view, Claude Code's list of agents running in the background, possibly with a git worktree of its own, which is a separate checkout of your repository that Claude edits in. Commit anything you want to keep before you delete, because the worktree goes with it.
Delete it with claude rm <id>, or by pressing Ctrl+X twice within two seconds on its row in agent view. The row disappears from the list, but the conversation transcript stays on your machine and remains available through claude --resume.
The worktree is where the two routes differ, and it matters more than the row:
- Agent view removes the worktree it created, including uncommitted changes, so commit what you want to keep first.
claude rmleaves the worktree in place, along with the session row, when the worktree has uncommitted changes.
One reason Claude Code refuses to delete a session is unpushed commits in its worktree. Push them first if you want to keep the work; if you mean to discard it, the refusal message offers the command that does that, claude rm <id> --discard-unpushed <commit>@<worktree-id>, which requires v2.1.260 or later. The agent view guide covers the list itself and the other keys on those rows.
What Claude Code deletes on its own
Most people never need either command. Claude Code deletes the files it lists under ~/.claude once they are older than cleanupPeriodDays, as long as it can safely work out the retention period. The default is 30 days and the minimum is 1; setting 0 fails with a validation error rather than turning the sweep off. The setting lives in settings.json, which is where you change it.
What ages out is more than the transcript. The list includes the conversation file, the transcripts of any subagents it spawned, tool outputs too large to keep inline, the pre-edit file snapshots behind checkpoint restore, plan files, per-session debug logs, cached pastes and task lists.
Two exceptions are worth knowing. Auto memory, the notes Claude Code keeps about your project between sessions, is not deleted by the sweep; Claude Code removes a project's memory directory only if it has been empty for the whole retention period. And the sweep can be paused entirely: if the retention period cannot be determined safely it stops and reports why through the retention_sweep event, and /status warns you when a settings file is the cause.
The sweep waits for the age limit, so deleting by hand is the faster route when you want the history gone today. The next section lists what goes with it.
Delete the stored history yourself
Deleting these directories is a file operation, not a Claude Code command, so there is no confirmation prompt and no undo:
~/.claude/projects/takes resume, continue and rewind for past sessions, plus auto memory for every project.~/.claude/history.jsonltakes up-arrow prompt recall,Ctrl+Rhistory search and!shell-command completion.~/.claude/paste-cache/takes the pasted text that recalled prompts refer to.
What a purge leaves behind
A purge is thorough about ~/.claude and deliberately narrow about everything else. Images you pasted or attached, and each session's scratchpad, live in Claude Code's temp directory rather than ~/.claude, so the purge does not remove them. The retention sweep still deletes the images once they pass cleanupPeriodDays; a purged session's scratchpad stays until you delete it or your operating system clears the temp directory.
The command also leaves shell-snapshots/ and backups/ alone, because they are not project-scoped, and it says so in the plan output. backups/ holds earlier copies of ~/.claude.json, taken when Claude Code rewrites that file, and it keeps the five newest, so an older copy of the project's entry can survive in one of them until it rotates out; shell-snapshots/ holds the shell settings each Bash command runs with and is cleared on a clean exit. One more file sits outside both the purge and the sweep: a .heapsnapshot written by /heapdump holds the full conversation and any credentials the process held, so if anyone ran that on the machine, those files need deleting by hand.
The practical rule: run claude purge for the conversation record, then clear the scratchpad and any heap snapshots yourself if the point was to leave nothing behind.
Sources
Every factual line above rests on one of these pages, read on November 25, 2026.
- Anthropic's Manage sessions, for
/clear, where transcripts are stored, and the pointer toclaude purgeandclaude rm. - Anthropic's Explore the .claude directory, for what the retention sweep deletes, the
cleanupPeriodDaysdefault and floor, and the fullclaude purgeplan, options and leftovers. - Anthropic's Manage multiple agents with agent view, for what deleting a session removes and when Claude Code refuses.
No purge or deletion was run for this page. Every path, flag and version floor is transcribed from those pages.
Common questions
How do I delete a Claude Code session?
For a background session, run claude rm <id> or press Ctrl+X twice within two seconds on its row in agent view. Its transcript stays on your machine and Claude Code can still resume it. To remove the conversations themselves, delete the project's state with claude purge, which removes the transcripts under ~/.claude/projects, the per-session task, debug and file-history entries, the project's prompt lines in history.jsonl and its entry in ~/.claude.json.
Does /clear delete a Claude Code conversation?
No. /clear starts a new conversation with an empty context and saves the one you were in, so you can come back to it with /resume. Deleting is a separate action: claude purge for a whole project, or the retention sweep when the transcript reaches cleanupPeriodDays.
How long does Claude Code keep chat history?
30 days by default. Claude Code deletes transcripts and the other files it writes under ~/.claude once they are older than cleanupPeriodDays, which defaults to 30 and accepts a minimum of 1; setting it to 0 fails with a validation error.
What does claude purge not delete?
Images you pasted or attached and the per-session scratchpad, because they live in Claude Code's temp directory rather than ~/.claude. It also leaves shell-snapshots/ and backups/ alone, since those are not project-scoped. Heap snapshots written by /heapdump are untouched by the purge and by the retention sweep.
Can I delete one conversation without losing the rest?
The delete commands Anthropic documents are claude purge for a project's state and claude rm <id> for a background session. For a single conversation the options are to delete its JSONL file from ~/.claude/projects yourself, which also removes any chance of resuming it, or to start fresh with /clear and let the retention sweep remove the old transcript when it ages out.
Know which session you are deleting
Omniscio lists every agent session side by side with its project, its branch and its status, so the one you close is the one you meant. Claude Code, Codex, OpenCode, Devin, Pi and Hermes all run in the same window.