# Where Claude Code stores your session history

> Claude Code keeps every session as a JSONL file in ~/.claude/projects and deletes them after 30 days by default. How to find, resume, export, keep and delete them.

Source: https://groundedby.com/agents/claude-code (updated 2026-10-29)

Claude Code writes every session to disk as it happens. If you have used it for a while, you have a detailed record of your work in `~/.claude/projects`, until the 30-day cleanup removes it.

## Where the files are

```text
~/.claude/
├── projects/
│   └── -Users-you-dev-my-app/          # one folder per working directory
│       ├── 7f3c...e21.jsonl            # one file per session
│       └── 7f3c...e21/
│           ├── subagents/              # transcripts of subagents it spawned
│           └── tool-results/           # large tool outputs, stored apart
├── history.jsonl                       # every prompt you typed, all projects
├── file-history/<session>/             # file snapshots before edits
└── settings.json
```

The project folder name is the working directory's path with every non-alphanumeric character turned into `-`. Very long paths are cut at 200 characters with a hash added.

On Windows the same tree lives under `%USERPROFILE%\.claude`. Setting `CLAUDE_CONFIG_DIR` moves all of it.

Find your biggest projects:

```bash
du -sh ~/.claude/projects/* | sort -h | tail
```

## What is inside a session file

Each line is one JSON record. Anthropic describes the format as internal and subject to change between versions, so treat field names as a snapshot. Common top-level fields:

| Field | What it holds |
| --- | --- |
| `type` | `user`, `assistant`, `attachment` and a few internal kinds |
| `timestamp` | When the record was written |
| `sessionId`, `uuid`, `parentUuid` | Session and message ids, linked as a chain |
| `cwd`, `gitBranch`, `version` | Where and with which version it ran |
| `message` | The message: `role`, `content`, `model`, `usage` (token counts) |
| `toolUseResult` | The result of a tool call |

Tool calls appear inside assistant messages as `tool_use` blocks, and their results come back in the next user record. [What is inside an agent session file](/guides/whats-inside-an-agent-session-file).

## Keep sessions longer

The default cleanup deletes transcripts, file snapshots, plans and debug logs older than 30 days. To keep a year, add this to `~/.claude/settings.json`:

```json
{
  "cleanupPeriodDays": 365
}
```

It takes effect from now on; it does not restore anything already removed. Your prompt history in `history.jsonl` is not part of the cleanup and stays until you delete it.

## Resume a session

```bash
claude --continue            # the most recent session in this folder
claude --resume              # pick from a list
claude --resume <id|name>    # a specific session, or a path to its .jsonl
claude --resume <id> --fork-session   # branch off without changing the original
```

Inside a session, `/resume` opens the picker, `/rename` names the session, and `/branch` forks it.

## Export a session

`/export` copies the current conversation to the clipboard or saves it as a text file. For a readable archive of many sessions, tools such as claude-code-log turn the JSONL files into HTML or Markdown. [Tools that read agent logs](/guides/tools-that-read-agent-session-logs).

## Delete history

```bash
claude purge --dry-run       # what would be removed for this project
claude purge                 # remove this project's sessions
claude purge --all           # every project
```

Before version 2.1.288 the command was `claude project purge`. Deleting the files in `~/.claude/projects` by hand works too. If you use the desktop app or claude.ai/code, those keep their own session lists.

## Privacy notes

- Transcripts are **plain text**. Anything the agent read - `.env` files, command output, API responses - is in them. [Redact before sharing](/guides/redact-secrets-from-agent-logs).
- On Free, Pro and Max plans, Anthropic may train on Claude Code sessions unless you opt out in your privacy settings. Team, Enterprise and API use are excluded. [What the terms say](/blog/ai-terms-of-service-and-your-sessions).

## Measure it

The [evaluator](/evaluate) reads `~/.claude/projects` in your browser and counts sessions, active hours, tool calls and the products your agents used.

## Questions

**Where is my Claude Code conversation history?**

In ~/.claude/projects, one folder per project, one .jsonl file per session. The folder name is your project's path with every character other than letters and digits replaced by a dash. Your typed prompts are also kept in ~/.claude/history.jsonl.

**How long does Claude Code keep sessions?**

30 days by default. Set cleanupPeriodDays in ~/.claude/settings.json to keep them longer, for example 365. The minimum is 1; 0 is rejected.

**How do I resume an old Claude Code session?**

Run claude --continue for the most recent session in the current folder, or claude --resume to pick from a list. Inside a session, /resume opens the picker; Ctrl+A shows sessions from every project.

**How do I delete Claude Code history?**

Run claude purge for the current project, with --dry-run to see what would go, or claude purge --all for every project. You can also delete the files in ~/.claude/projects directly.

**Can I stop Claude Code from saving sessions?**

Yes. Set the environment variable CLAUDE_CODE_SKIP_PROMPT_HISTORY to stop transcripts being written, or pass --no-session-persistence to a single claude -p run.

## Sources

- [Claude Code docs, sessions](https://code.claude.com/docs/en/sessions)
- [Claude Code docs, the .claude directory](https://code.claude.com/docs/en/claude-directory)
- [Claude Code docs, CLI reference](https://code.claude.com/docs/en/cli-reference)
