# Claude Code history and logs: where sessions live on Mac

> Where Claude Code stores session transcripts, prompt history and debug logs on your Mac, how to find and resume a session, and how to set retention.

Claude Code saves each session as a JSONL transcript at `~/.claude/projects/<project>/<session-id>.jsonl`. The prompts you typed go to `~/.claude/history.jsonl`. Debug logs go to `~/.claude/debug/` while debug logging is on. Transcripts are deleted after 30 days by default, and you change that with `cleanupPeriodDays`. All of it is plaintext.

## What is stored and where

`<project>` is your working directory path with non-alphanumeric characters replaced by `-`, so `/Users/you/my-project` becomes `-Users-you-my-project`. Very long names are truncated and given a hash.

| Path under `~/.claude/` | Contents | Retention |
| --- | --- | --- |
| `projects/<project>/<session>.jsonl` | Messages, tool calls and results, plus the system prompt, tool definitions and request parameters | Swept after `cleanupPeriodDays` |
| `projects/<project>/<session>/subagents/` | Subagent transcripts | Removed with the parent |
| `projects/<project>/<session>/tool-results/` | Large tool outputs | Swept after `cleanupPeriodDays` |
| `file-history/<session>/` | Pre-edit snapshots for checkpoint restore | Swept after `cleanupPeriodDays` |
| `debug/` | Per-session debug logs, only while debug logging is on | Swept after `cleanupPeriodDays` |
| `history.jsonl` | Prompts you typed, with timestamp and project path | Kept until you delete it |

Each transcript line is a JSON object. The sessions page says the entry format is internal and changes between versions, so a script that parses these files can break on any release. It recommends `/export` or `claude -p --output-format json` for stable data.

If you set `CLAUDE_CONFIG_DIR`, every `~/.claude` path above lives under that directory instead.

## Find and resume a session

| Command | What it does |
| --- | --- |
| `claude --continue` | Reopens the most recent session in the current directory |
| `claude --resume` | Opens the session picker |
| `claude --resume <name>` or `<session-id>` | Resumes that session directly |
| `/resume` | Switches session from inside Claude Code |

In the picker, `Ctrl+A` widens to every project on the machine, `Ctrl+W` to all worktrees and `Ctrl+B` filters to the current git branch. Typing searches. `Space` previews a session. Name sessions with `claude -n <name>` or `/rename` so you can find them later. Sessions from `claude -p`, the Agent SDK and `/loop` stay out of the picker, but you can resume one by ID. To read a past session by hand, open its `.jsonl` file or run `/export` in a live session.

## Check what happened afterward

Use the transcript to compare the tool call with its result. Start from the session ID, project folder and timestamp. Debug logs are separate. Start with `claude --debug`, or `--debug-file <path>` to write them to a file you choose. The installed help for Claude Code 2.1.322 lists both flags. [Read a session by hand](https://www.excellent.so/research/check-what-your-ai-agent-actually-did)

## Retention and cleanup settings

- `cleanupPeriodDays` in settings sets how many days transcripts are kept. The default is 30 and the minimum is 1. Setting `0` fails validation.
- `desktopSessionCleanupPeriodDays` gives Claude Desktop and Cowork transcripts an age limit. Without it, those transcripts are kept at any age.
- `CLAUDE_CODE_SKIP_PROMPT_HISTORY=1` skips writing prompt history and transcripts. Those sessions do not appear in `--resume`.
- `claude -p --no-session-persistence` skips writing for one non-interactive run.
- `claude purge [path]` deletes one project’s transcripts, memory, tasks, file history, matching `history.jsonl` lines and its entry in `~/.claude.json`. Add `--dry-run` first to see the plan. `--all` purges every project.

The docs warn that a transcript can hold anything that passed through a tool, including a `.env` file the agent read or a credential a command printed. Lower `cleanupPeriodDays` to shorten exposure, and deny reads of credential files. [Keys and logs guide](https://www.excellent.so/guides/keep-keys-and-email-out-of-agent-logs) · [Environment variables](https://www.excellent.so/guides/claude-code-environment-variables)

Checked against the vendor documentation on November 25, 2026. [Claude directory](https://code.claude.com/docs/en/claude-directory) · [Manage sessions](https://code.claude.com/docs/en/sessions) · [Data usage](https://code.claude.com/docs/en/data-usage)

## Reading these logs with Excellent

Excellent’s free scan reads supported logs on the Mac and reports findings for review. Claude Code’s session logs are among them, along with Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code. For a local report without installing an app, [run the free scan](https://www.excellent.so/scan). Its script uses Python 3.9 or later when your Mac has it and the shell when it doesn’t, reads the logs locally and makes no network requests. [See a sample report](https://www.excellent.so/r/sample).

The [Mac app](https://www.excellent.so/download) runs on Apple silicon with macOS 14 or later. Manual scanning is free and needs no account. [Check what your AI agents did](https://www.excellent.so/guides/check-what-your-ai-agents-did)

Source: https://www.excellent.so/guides/claude-code-history-and-logs
