Key takeaways
- claude purge deletes a project's transcripts, auto memory, per-session state and matching prompt history, and it asks for confirmation first.
- Claude Code deletes transcripts older than cleanupPeriodDays automatically: the default is 30 days, the minimum is 1, and 0 is rejected.
- /clear starts a new conversation but saves the old one, which you can bring back with /resume.
Claude Code how to delete a session: run claude purge to delete a project's transcripts and related state now, or lower cleanupPeriodDays so Claude Code deletes old ones on its own. Inside a running session, /clear does not delete anything. It starts a new conversation and keeps the old one for /resume. This guide follows Anthropic's Manage sessions and .claude directory docs, as of November 8, 2026. We did not run the commands ourselves, so every step comes from those pages.
The short version is that Claude Code has no single "delete this conversation" command for a normal terminal session. It has three tools: a project-wide purge, an automatic age limit, and deleting the files yourself.
What /clear does and does not do
/clear starts a new conversation with empty context. Anthropic's commands reference lists /reset and /new as aliases. The previous conversation is saved, and you can bring it back with /resume. So /clear frees up the context window, but the old transcript stays on disk.
If you only want Claude to forget what was said, /clear is enough. If you want the transcript gone from your machine, use one of the methods below. To keep working in the same conversation with less context, use /compact instead. It replaces the history with a summary. Our guide to resuming a session covers /resume and the picker.
Where Claude Code keeps your sessions
Claude Code writes every message, tool call and result to a plaintext JSONL file under ~/.claude/projects/<project>/<session-id>.jsonl. The <project> part is your working directory path with every character other than letters and digits replaced by -. On Windows, ~/.claude means %USERPROFILE%\.claude, and setting CLAUDE_CONFIG_DIR moves it elsewhere.
Anthropic warns that these files are not encrypted. If a tool reads a .env file or a command prints a credential, that value is written to the transcript. That is the main reason to delete old sessions.
Around the transcript, Claude Code also stores:
projects/<project>/<session>/subagents/for subagent transcriptsprojects/<project>/<session>/tool-results/for large tool outputsfile-history/<session>/for the file snapshots behind checkpoint restorehistory.jsonlfor the prompts you typed, used for up-arrow recall andCtrl+Rsearch
How to delete a project's sessions with claude purge
claude purge deletes the state Claude Code holds for one project. According to the docs it removes:
- transcripts and auto memory under
projects/ - the per-session
tasks/,debug/andfile-history/entries - the matching prompt lines in
history.jsonl - the project's entry in
~/.claude.json
Run it in three steps, with your own project path in place of the placeholder. First preview with --dry-run, then delete with a confirmation prompt, or add --yes to skip the prompt in scripts.
claude purge ~/work/my-repo --dry-run
claude purge ~/work/my-repo
claude purge ~/work/my-repo --yes
Leave out the path to pick a project from an interactive list. Pass --all instead of a path to purge every project at once. In that case history.jsonl is deleted outright instead of filtered. Pass -i to go through the plan one item at a time. If no state matches the path, the command prints an error and exits with status 1.
The command prints the full plan and asks This cannot be undone. [y/N] before it deletes anything. Before Claude Code v2.1.288 the command was claude project purge.
Two things survive a purge. Pasted and attached images and each session's scratchpad live under Claude Code's temp directory, not ~/.claude, so they stay until the age sweep or your operating system removes them. And shell-snapshots/ and backups/ are not project-scoped, so purge leaves them alone. Auto memory goes with the purge, so run the dry run first if you want to keep Claude's notes about the project.
How to delete old sessions automatically with cleanupPeriodDays
Claude Code deletes transcripts and the other files in the same table once they are older than cleanupPeriodDays. The default is 30 days and the minimum is 1. Setting it to 0 fails with a validation error, so you cannot use it to turn off storage. The setting works in any settings file. To keep transcripts for a week, add this to ~/.claude/settings.json:
{
"cleanupPeriodDays": 7
}
A few rules from the docs decide what the sweep touches:
- Claude Code skips the sweep when you run
claude -pwith--bare. - If Claude Code cannot safely work out the retention period, it pauses the sweep. When a broken settings file is the cause,
/statusshows a warning until you fix it. - Auto memory files in
projects/<project>/memory/are not deleted by the sweep. history.jsonl,stats-cache.jsonand a few caches are kept until you delete them. The sweep trimshistory.jsonlonly when the HIPAA configuration applies to your sessions.- Transcripts of sessions you started or last continued in Claude Desktop or Cowork are kept at any age. To give them a limit, set
desktopSessionCleanupPeriodDays(Claude Code v2.1.248 or later). If your organization's managed settings setcleanupPeriodDays, those transcripts follow it instead.
How to delete one session or everything by hand
The docs say you can delete any of the application-data paths yourself, apart from the state files to keep. This table is from the "Clear local data" section of the .claude directory page.
| Delete | You lose |
|---|---|
~/.claude/projects/ |
Resume, continue and rewind for past sessions, and auto memory for every project |
~/.claude/history.jsonl |
Up-arrow prompt recall, Ctrl+R history search and ! shell-command completion |
~/.claude/file-history/ |
Checkpoint restore for past sessions |
~/.claude/stats-cache.json |
Historical totals shown by /usage |
~/.claude/debug/, ~/.claude/plans/, ~/.claude/session-env/, ~/.claude/shell-snapshots/ |
Nothing user-facing |
Don't delete ~/.claude.json, ~/.claude/settings.json or ~/.claude/plugins/. They hold your account details, preferences and installed plugins. Also keep .credentials.json, agent-memory/, and the jobs/ and daemon/ directories.
The docs do not describe a command or a picker shortcut that deletes a single ordinary session. The /resume picker lists shortcuts for moving between sessions, previewing, renaming and filtering, but none for deleting. To remove one conversation, you would delete its <session-id>.jsonl file under ~/.claude/projects/<project>/ and, if you want the leftovers gone too, the folder with the same session ID next to it and the matching folder under file-history/. That follows from the paths the docs list, but the docs do not spell it out as a procedure. Preview the session with Space in the picker first, so you delete the right one.
What claude rm deletes (background sessions only)
Background sessions, the ones shown in agent view, have their own delete. Press Ctrl+X twice in agent view or run claude rm <id>. Both remove the session from the list, but Anthropic says the transcript stays on your machine and remains available through claude --resume. claude rm also removes a git worktree Claude created for the session when that is safe, and keeps it when it has uncommitted changes. So claude rm tidies the list. It does not erase the conversation.
How to stop Claude Code writing transcripts at all
Set the CLAUDE_CODE_SKIP_PROMPT_HISTORY environment variable to skip writing transcripts and prompt history in any mode. For a single non-interactive run, pass --no-session-persistence with -p. Both mean you cannot resume those conversations later. In the TypeScript Agent SDK the equivalent is persistSession: false, and the Python SDK has no equivalent option.
Common problems
- The session still shows in
/resume./clearkeeps the old session on purpose. Delete the transcript or runclaude purge. - Old transcripts are still there after 30 days. The sweep may be paused by a settings error (check
/status), or the session came from Claude Desktop or Cowork. - You deleted the wrong thing. The purge says it cannot be undone. Run
--dry-runfirst.
If you meant chats in the Claude app and not Claude Code, see how to delete chats in Claude.
Frequently asked questions
Does /clear delete a Claude Code session?
No. /clear starts a new conversation with empty context and saves the previous one, which you can reopen with /resume. The transcript stays on disk until it ages out or you delete it.
How long does Claude Code keep session history?
30 days by default. Claude Code deletes transcripts and related files older than cleanupPeriodDays, which you can change in settings.json. The minimum is 1, and 0 fails validation.
Where does Claude Code store conversation history?
As plaintext JSONL files at ~/.claude/projects/<project>/<session-id>.jsonl. Typed prompts are in ~/.claude/history.jsonl. On Windows, ~/.claude is %USERPROFILE%\.claude.
Can I stop Claude Code from saving sessions?
Set the CLAUDE_CODE_SKIP_PROMPT_HISTORY environment variable to skip writing transcripts and prompt history in any mode. For one non-interactive run, pass --no-session-persistence with -p.
Sources
- Explore the .claude directory: application dataAnthropic
- Manage sessionsAnthropic
- CommandsAnthropic
- Agent view: what deleting a session removesAnthropic
- How Claude Code worksAnthropic