# Where Claude Code, Codex and Cursor Keep Your Chat History on Disk, and How to Read It

> Source: <https://dev.to/open-agentic-brain-and-memory/where-claude-code-codex-and-cursor-keep-your-chat-history-on-disk-and-how-to-read-it-hc3>
> Published: 2026-11-06 21:13:54+00:00

Claude Code chat history is stored on your own machine as plaintext JSONL files under `~/.claude/projects/`, one file per session, and deleted after 30 days by default. On Windows the same folder is `%USERPROFILE%\.claude\projects\`. Codex and Cursor keep their own records in their own places and formats. Paths and defaults below were last verified on 6 November 2026, and they do change, so check them against your installed version.

Most of us never open these files. We should, for two reasons. They record real work: why you dropped Redis for SQLite, the three-hour bug behind a one-line fix, the reason the repo always uses pnpm. Yet you may still [re-explain your project every morning](https://rohithhn.github.io/brain-site/blog/why-ai-coding-tools-need-memory.html) while all of that sits on disk.

They also hold more than you'd guess. Claude Code's own docs (the "Explore the .claude directory" page) say anything that passes through a tool lands in the transcript: file contents, command output, pasted text. That makes these folders worth knowing about whether you want to mine them or clean them out.

Each session is a file at `~/.claude/projects/<project>/<session>.jsonl`. The project folder name is your working directory with separators swapped for dashes, such as `-Users-you-my-project`. Each transcript holds messages, tool calls and tool results, plus the system prompt and tool definitions Claude Code sent the model.

**Typed prompts:** these live separately in `~/.claude/history.jsonl`, which powers up-arrow recall. The 30-day sweep doesn't normally touch that file, so it stays until you remove it.

**Retention:** the `cleanupPeriodDays` setting controls the age limit. The default is 30 and the minimum is 1. Transcripts from sessions last used in Claude Desktop or Cowork follow a separate rule and are kept at any age by default.

**Moving it:** set `CLAUDE_CONFIG_DIR` and all of this moves with it.

Codex is less documented here. OpenAI's config reference covers settings, but community write-ups are the source for the layout: `~/.codex/sessions/YYYY/MM/DD/rollout-<timestamp>-<uuid>.jsonl`. One of those is "Where Six AI Coding CLIs Store Your Session Logs" (Adrian Ghinda's All About Coding, August 2026), which calls the path undocumented. Treat it as observed behaviour. Another community post reports Zstandard-compressed `.jsonl.zst` rollouts, so run `ls` before you assume.

There's also `~/.codex/history.jsonl`. OpenAI's reference says `history.persistence` controls whether transcripts are saved there. The Ghinda write-up found it holds only the text you typed, and that setting it to `none` leaves the rollout files running. Sources disagree, so test it on your version if it matters to you. The same write-up found no documented age-based deletion, which means rollouts pile up until you remove them. `CODEX_HOME` moves the whole tree.

Cursor's data-use page doesn't say where chats live. Community tooling points to SQLite databases named `state.vscdb`, under the `User` folder:

**macOS:** `~/Library/Application Support/Cursor/User/`

**Linux:** `~/.config/Cursor/User/`

**Windows:** `%APPDATA%\Cursor\User\`

Look in `globalStorage/state.vscdb` and in `workspaceStorage/<hash>/state.vscdb`. Write-ups disagree on which holds the chat content, so check both. The Cursor CLI is separate: the Ghinda write-up places its chats at `~/.cursor/chats/<chat-id>/<session-uuid>/store.db`. None of this is a stable interface, and an update can rearrange it.

You don't need a special viewer. JSONL is one JSON object per line, so `grep` and `jq` go a long way. To find every Claude Code session that mentions a decision:

```
grep -rl "pnpm" ~/.claude/projects/
```

To read just what you typed in one session (this skips messages stored as content arrays):

```
jq -r 'select(.type=="user") | .message.content | strings' session.jsonl
```

Codex works the same way against `~/.codex/sessions/`. Field names differ and neither format is a promised API, so look at a line or two first.

For Cursor, use `sqlite3` in read-only mode. A copy of the file is safer still:

```
sqlite3 -readonly "$HOME/Library/Application Support/Cursor/User/globalStorage/state.vscdb" \
  "SELECT key FROM cursorDiskKV LIMIT 20;"
```

Run one more search while you're here, for credentials in common shapes:

```
grep -rlE 'sk-[A-Za-z0-9_-]{20,}|ghp_[A-Za-z0-9]{36}|AKIA[0-9A-Z]{16}' \
  ~/.claude/projects ~/.codex/sessions
```

A clean result only means none of those patterns matched. It doesn't prove the folder is free of secrets.

For deletion, Claude Code has the best tool. `claude purge ~/work/my-repo --dry-run` prints exactly what would go, and dropping the flag deletes it after a confirmation. Versions before v2.1.288 call it `claude project purge`. For Codex, the Ghinda write-up says v0.136 and later ship a `delete` subcommand. Removing a rollout file by hand also works. For Cursor, delete chats inside the app. If you must touch the database, close Cursor and back up the whole `User` folder first.

Before you wipe `~/.claude/projects/`, know that it also holds auto memory. Claude Code's docs say deleting the folder costs you resume, continue and rewind for past sessions, plus auto memory for every project.

Grep answers "did I ever say this?" It's poor at "what should my agent know right now?" Three things get in the way.

**Tool boundaries.** A decision made in Claude Code sits in a JSONL file that Cursor will never open. Cursor's reasoning sits in a SQLite blob that Codex can't see. If you [work across several agents](https://rohithhn.github.io/brain-site/blog/use-multiple-ai-coding-agents.html), you have several partial histories and no shared one. A second laptop has its own set again.

**Volume.** Transcripts carry tool output, system prompts and dead ends. Pasting them back into a chat costs far more tokens than they're worth, and that spend comes straight off your Claude, Cursor or Codex limits. We've written about [cutting those token costs](https://rohithhn.github.io/brain-site/blog/reduce-ai-coding-token-costs.html) in more detail.

**No sense of what still matters.** A log treats a reversed decision and a current one the same. Last month's "use Redis" looks as true as this week's "we moved to SQLite." And Claude Code deletes the record at 30 days whether the content still matters or not.

At Open Agentic Brain & Memory (OpenAB), we think these files are the best raw material you already have, and that they should stay yours. We read the same transcripts and local stores described above, then distill decisions, fixes and preferences into memories tagged by project. They go into a local SQLite database, with no account and no server of ours. Sync between machines is an age-encrypted file in your own private GitHub repo, and you can read, edit, pin or delete every memory in a local control panel.

The installer asks one question that matters here: start from the past sessions your AI tools already keep on this computer, or start fresh. Choose the first and Claude Code, Codex and Cursor history that's still on disk becomes the starting memory, so you begin with your own work behind you. You can change your mind later with `brain past-sessions on` or `off`. Since Claude Code only keeps 30 days by default, what you have today may be more than you have next month.

After that, each tool gets a briefing of at most 2,000 tokens at session start, in 84 ms (p50), and can recall on demand over MCP in 28 ms (p50) across 10,000 memories. In our own benchmarks, loading context for a 10,000-memory store takes 1,325 tokens instead of 1,131,367. On LoCoMo we keep 97% of the full-conversation score while reading 18% of the tokens. Fewer tokens per session means you hit your limits later.

One honest limit: OpenAB runs on macOS and Linux, and Windows isn't supported yet, so the Windows paths above are for your own digging. You can see the benchmarks and the install steps on the [OpenAB home page](https://rohithhn.github.io/brain-site/index.html).

[Install Open Agentic Brain & Memory (OpenAB)](https://rohithhn.github.io/brain-site/index.html)

Yes, the tools keep running, but you lose features tied to that history. Deleting `~/.claude/projects/` removes resume, rewind and auto memory, while `~/.claude/settings.json` and `~/.claude.json` should stay. Codex rollouts can go, though you can't resume those sessions afterwards. Leave Cursor's `state.vscdb` alone and delete chats in the app, because that database holds other editor state too.

They can. Claude Code's docs confirm that transcripts aren't encrypted at rest, that OS file permissions are the only protection, and that a `.env` file a tool reads ends up in the transcript. Assume the same risk for Codex and Cursor. Run the grep above and rotate anything it finds. Our [self-hosted memory privacy guide](https://rohithhn.github.io/brain-site/blog/self-hosted-ai-memory-privacy-security.html) covers how OpenAB handles this.

Both. The files are local, but your prompts and the model's replies go to the provider so the model can answer. Claude Code's "Data usage" page lists Anthropic's server-side retention at 30 days for commercial accounts and for consumers who opt out of model training, and 5 years for consumers who opt in. Cursor's data-use page says requests pass through its backend even with your own API key, and Privacy Mode changes what providers may keep. For Codex, read OpenAI's data controls for your plan.

Set `cleanupPeriodDays` to a higher number in `~/.claude/settings.json`. Don't try `0`: it fails validation. Longer retention also means sensitive content sits in plaintext for longer.

Claude Code has no undo for this, and `claude purge` warns that it can't be undone. Your only route is a backup, such as Time Machine or a filesystem snapshot taken before the deletion.

Use `grep -rl` across `~/.claude/projects/` to find the file, then `jq` to read it. Inside Claude Code, `Ctrl+R` searches your typed prompts.
