GuidesSecurity

Delete Claude Code sessions and history: claude purge

Delete Claude Code transcripts and prompt history with claude purge, for one project or all, remove one session by hand, and make it keep less on a server.

November 20, 2026The Everpod team
The short answer

Run claude purge with a project’s path to delete that project’s transcripts, auto memory, file checkpoints and the prompts you typed there; add --dry-run first to see the plan, or pass --all instead of a path to clear every project and the whole prompt history. Before Claude Code v2.1.288 the command was claude project purge. The session picker has no delete key; a single session is its file under ~/.claude/projects/, which you can remove by hand. To keep less from now on, lower cleanupPeriodDays (30 days by default, 1 at least), or stop the writes with the CLAUDE_CODE_SKIP_PROMPT_HISTORY variable or --no-session-persistence on claude -p runs.

What Claude Code keeps, and why it matters on a server

Each session is a JSONL file at ~/.claude/projects/<project>/<session-id>.jsonl, where <project> is the working directory with every non-alphanumeric character turned into -. Beside it, a folder of the same name holds subagent transcripts and large tool outputs, and ~/.claude/file-history/ holds the pre-edit copies of files that rewind restores. Separately, ~/.claude/history.jsonl is every prompt you typed, with its time and project path, which is what the up arrow and Ctrl+R search read.

Anthropic’s docs are plain about the contents: transcripts and history “are not encrypted at rest. OS file permissions are the only protection.” Whatever passes through a tool is written down, so a .env file the agent read or a token a command printed sits in the transcript, along with the system prompt and the CLAUDE.md files it loaded. On a laptop that is one more copy of your own data. On a shared or long-lived server it is a record of every secret the agent ever saw there, readable by anything that runs as your user.

Delete one project’s sessions: claude purge

Preview first. Nothing is deleted with --dry-run:

claude purge ~/work/my-repo --dry-run
Copied

The plan names each item and why it is included. Anthropic’s own example:

Purge plan for /home/user/work/my-repo:

  dir:    /home/user/.claude/projects/-home-user-work-my-repo
           project transcripts (.jsonl) and memory/
  config: projects["/home/user/work/my-repo"]
           project entry in ~/.claude.json (trust, history, MCP servers)
  filter: /home/user/.claude/history.jsonl
           12 prompt(s) typed in this project

shell-snapshots/ are not project-scoped and will not be touched
backups/ may still contain this project entry in old .claude.json snapshots (/home/user/.claude/backups); at most 5 are kept and they rotate out automatically
Dry run: 3 item(s) would be deleted.
Copied

Run it without the flag to delete. It prints the same plan and asks [y/N], deleting only on y. The options:

For one project it removes the transcripts and auto memory under projects/, that project’s per-session tasks/, debug/ and file-history/ entries, the lines of history.jsonl typed there, and the project’s entry in ~/.claude.json, which carries its folder trust and project MCP servers. A path with nothing stored under it prints an error and exits with status 1.

On a version before v2.1.288, claude purge does not exist; the same command was claude project purge. claude --version tells you which you have, and the Claude Code on Linux guide covers updating.

What a purge leaves behind

Delete a single session

The /resume picker can preview, rename, search and widen its list, but its shortcuts include no delete. To remove one session, find its file in the project’s folder, where each transcript is named by its session ID, and delete it and the folder of the same name beside it:

rm ~/.claude/projects/<project>/<session-id>.jsonl
rm -r ~/.claude/projects/<project>/<session-id>/
Copied

Anthropic’s docs allow deleting any of these data paths by hand. The prompts you typed in that session stay in history.jsonl; a purge of the project removes them with the rest of the prompts typed there. claude rm <id> is not a way to delete a transcript: it removes a background session, and the docs say its transcript “stays on disk and remains available through claude --resume.”

Leave ~/.claude.json, ~/.claude/settings.json, ~/.claude/plugins/ and ~/.claude/.credentials.json alone when clearing by hand: they are your account, settings, plugins and sign-in, not history. Deleting all of ~/.claude/projects/ loses resume, continue and rewind for every past session, and the auto memory of every project with them.

Make Claude Code keep less

A shorter sweep. Claude Code deletes transcripts, their subagent and tool-output folders, file checkpoints, paste cache and the like once they are older than cleanupPeriodDays. The default is 30; the lowest accepted value is 1, and 0 fails validation rather than meaning “keep nothing.” In ~/.claude/settings.json:

{
  "cleanupPeriodDays": 7
}
Copied

Three things the sweep does not do. It leaves history.jsonl alone outside Anthropic’s HIPAA configuration, so typed prompts build up until you purge or delete them. It never deletes auto memory files. And it does not run in a claude -p --bare run, so a server whose only use is bare scripted runs gets no sweep unless an ordinary session runs there now and then. If a settings file fails to parse, the sweep pauses and /status shows a warning.

No writes at all. Setting the CLAUDE_CODE_SKIP_PROMPT_HISTORY environment variable skips writing both transcripts and prompt history, in interactive and scripted runs alike; the value to give it is on Anthropic’s environment variables page. For one scripted run, pass --no-session-persistence with -p. The cost is the same in both cases: nothing saved means nothing to resume, as the guide to resuming sessions notes among the reasons a session is missing. For a job on a timer that never needs resuming, the flag is a natural fit; the headless scheduling guide covers the rest of such a run.

Keep secrets out of the record. A deny rule on reads of credential files stops the agent opening them, so they never reach a transcript; the guide to securing a VPS for Claude Code and Codex covers which files those are on a server.

Codex

Codex keeps its sessions under ~/.codex, or wherever CODEX_HOME points, and OpenAI’s command reference gives it a delete command of its own:

codex delete <SESSION>
codex delete <SESSION_UUID> --force
Copied

It deletes a saved interactive session, named by its ID or its name, for good. --force skips the confirmation and works only with a UUID, so a name that could match more than one session always asks. Inside a session, /delete removes the transcript, its side chats and the sessions it spawned, though not while a turn is running. codex archive and /archive only hide a session from the lists and keep the transcript; codex unarchive brings it back.

To keep less, codex exec --ephemeral writes no session files for that run. Codex’s typed-prompt history, ~/.codex/history.jsonl, is turned off with persistence = "none" under [history] in config.toml, or capped with history.max_bytes, past which the oldest entries are dropped. OpenAI’s docs name no age limit for saved sessions.

Run Claude Code on an always-on developer pod.

A developer pod is a permanent cloud computer (VPS), set up and secured for you, with your pick of Claude Code, Codex, OpenCode, Pi, Hermes and OpenClaw installed. Run more agents at once than your laptop can hold, and keep them working when it’s closed. From $24 a month, built in about ten minutes.