Claude Code Session History and How to Resume It
Related guide: Claude Code commands, built-in and custom
Our heaviest user’s laptop opened 596 of the 878 pull requests we merged in the 30 days to October 3, 2026 (68%), and its history has no record of the other 282. Claude Code saves each session as a JSONL file in ~/.claude/projects/<project>/ on the machine that ran it. Reopen one with claude --resume or /resume, and press Ctrl+A in the list to see every project. Transcripts older than 30 days are deleted unless you raise cleanupPeriodDays.
The other 282 came from three other engineers, Codex and other machines. We know these files because our Claude Code plugin parses them in production. The commands below come from Anthropic’s docs, and we confirmed the flags against claude --help in version 2.1.322 on November 10, 2026. We’d raise the retention before you need it, name any session you’ll want back, and keep your scripts off the file format.
Where does Claude Code store session history?
Each session is one file at ~/.claude/projects/<project>/<session-id>.jsonl. On Windows, ~/.claude means %USERPROFILE%\.claude, and setting CLAUDE_CONFIG_DIR moves the whole directory. Each line is a JSON object holding a message, a tool call or result, a model request, or metadata.
The folder name is where scripts go wrong. <project> is your working directory with every non-alphanumeric character replaced by -, so /work/my_app, /work/my.app and /work/my-app all become -work-my-app. That can’t be turned back into a path. Our plugin doesn’t try, and reads the cwd field near the top of each file instead.
| What | Path under ~/.claude/ |
How long it stays |
|---|---|---|
| Session transcript | projects/<project>/<session-id>.jsonl |
30 days by default |
| Subagent transcripts | projects/<project>/<session-id>/subagents/ |
Removed with the parent |
| Prompts you typed | history.jsonl |
Until you delete it |
| Token and cost totals | stats-cache.json |
Until you delete it |
The desktop app, claude.ai/code and the VS Code extension each keep their own session list. In VS Code, the Session history button at the top of the Claude Code panel lets you search by keyword or browse by time.
How to resume a Claude Code session
| You want | Run |
|---|---|
| The latest session in this directory | claude --continue or claude -c |
| A list to choose from | claude --resume, claude -r, or /resume inside a session |
| A session you named | claude --resume auth-refactor |
| A session by ID, from any directory | claude --resume <session-id> |
| A file at an absolute path | claude --resume <transcript-path> |
| A copy that leaves the original alone | claude --continue --fork-session |
The picker opens narrow, on the current worktree. In a repository with several worktrees, Ctrl+W widens it to all of them. Ctrl+A widens it to every project on the machine, and Ctrl+B filters to the current git branch. Space previews a session before you open it, and typing starts a search. Picking one from an unrelated project copies a cd and resume command to your clipboard instead of opening it.
Name a session with claude -n auth-refactor, run /rename auth-refactor mid-session, or press Ctrl+R on a row in the picker.
Resuming restores the messages, tool calls and model, but flags like --mcp-config, --settings and --add-dir have to be passed again. A compacted session opens at a Conversation compacted row, and what that compaction summarized isn’t loaded back.
How to find the session behind a pull request
claude --from-pr 123
That opens the picker filtered to sessions linked to that pull request. It also takes a pull request URL, and so does the picker’s search. Claude Code makes the link when Claude creates the pull request, so one you opened by hand may have nothing to find.
It’s the command we’d reach for in code review, but the picker only knows this machine. If a teammate’s Claude opened the pull request, the transcript is on their laptop.
Why a session is missing
- It’s in another worktree or project. The picker starts on the current worktree, so press
Ctrl+WorCtrl+Abefore assuming anything is gone. - It aged out. The cleanup runs in the background after a session starts and deletes old files without a message, so the row stops appearing.
- It ran without a person at the keyboard. Sessions from
claude -pand the Agent SDK are left out of the picker and ofclaude --continue, and so are sessions whose first prompt was/loop.claude --resume <session-id>still opens the-pand SDK ones. - It started in the desktop app, claude.ai/code or VS Code, which keep their own lists.
- Someone purged it.
claude purgeremoves a project’s transcripts and its lines inhistory.jsonl, and its prompt warns that this cannot be undone. - It ran on another machine, and the file is still there.
With an ID in hand, claude --resume <session-id> searches the current project and its worktrees, then every other project on the machine. No conversation found with session ID means the file isn’t here.
How long Claude Code keeps history, and how to keep it longer
Transcripts last 30 days by default. Change that with cleanupPeriodDays in ~/.claude/settings.json.
{
"cleanupPeriodDays": 3650
}
The minimum is 1 and 0 fails validation, so Anthropic’s docs suggest a large number like this one for long retention. Raising it protects only what’s still on disk. When we recounted one engineer’s sessions on October 4, 2026, the ones from September 2 and 3 were already gone.
Longer retention also means more secrets on disk. These files aren’t encrypted at rest and file permissions are the only protection, so a .env a tool read or a credential a command printed stays in that JSONL as long as the file does. To stop writing transcripts at all, set CLAUDE_CODE_SKIP_PROMPT_HISTORY to 1, and those sessions can’t be resumed. Claude Desktop and Cowork transcripts are kept at any age by default, and desktopSessionCleanupPeriodDays gives them a limit.
To delete a project’s history sooner, preview it first, then run the same command without --dry-run and confirm.
claude purge ~/work/my-repo --dry-run
How to search or export your history
/export copies the current conversation to your clipboard or saves it as plain text, and /export notes.txt writes straight to that file. To archive every session as it ends, use a SessionEnd hook, which receives the file’s location as transcript_path on stdin. This one goes in ~/.claude/settings.json and needs jq.
{
"hooks": {
"SessionEnd": [
{
"hooks": [
{
"type": "command",
"command": "mkdir -p ~/claude-archive && jq -r .transcript_path | xargs -I{} cp {} ~/claude-archive/",
"timeout": 10
}
]
}
]
}
}
Keep the timeout, because SessionEnd hooks get only 1.5 seconds by default.
The picker’s search filters the list of sessions. To search inside them, run ripgrep over the files, which are plain text. Each file it lists is named after a session ID you can pass to claude --resume.
rg -l "rate limiter" ~/.claude/projects --glob '*.jsonl'
For a history viewer, Claude Code History Viewer is a desktop app that describes itself as 100% offline, agent-history is a CLI that exports to Markdown or HTML, and search-sessions is a Rust CLI for searching. We haven’t tested these, and they all read the same files.
Those files aren’t an API. Anthropic says the format is internal and can break scripts on any release, and points you to /export, hooks and claude -p --output-format json instead. Token counts show how wrong a simple reading can go. Each response’s usage is logged once per content block, so on the Claude Code version we ran, the cache behind /stats counted 1.9 to 2.7 times the tokens of a deduplicated recount of the same transcripts (September 5 to 12, 2026). Our post on Claude Code token usage counts each API response once.
How to see a teammate’s Claude Code sessions
Claude Code session history stops at the laptop that ran it, so nobody else can open a local session through Claude Code. Cloud sessions at claude.ai/code are different. Change a session’s visibility and send its link, and on Team and Enterprise accounts your organization’s members can open it. For a local session, the usual workaround is a /export sent by hand, which says nothing about what the team’s sessions added up to.
We make Zest for that. A plugin in each engineer’s Claude Code records each session (prompts, replies, model, token counts, skills and tool calls), redacts secrets on the machine and uploads it to the team’s workspace. A GitHub App links each session to the pull request it led to, so the question --from-pr answers on one laptop gets an answer across the team.
It won’t rescue old history, though, because a first login imports at most the 10 most recently active chats from that day and everything else arrives going forward. It doesn’t put a session back in your terminal either, so claude --resume still needs the file on your disk. Every engineer has to install the plugin, pull request links need GitHub, and no code diffs are collected. Reading another engineer’s raw prompts and replies takes an owner or admin role in the workspace, and how long they’re kept is a workspace setting, so treat it as a team view and not an archive.
Questions about Claude Code history
How do I resume my last Claude Code session?
Run claude --continue from the same directory.
Does /clear delete a session?
No. /clear starts a new conversation with empty context and saves the old one, so /resume brings it back.
Can I recover a deleted session?
Anthropic documents no undo, and the file only existed on your machine, so the way back is a backup of ~/.claude/projects. Before giving up, look in the project’s folder for names containing .orphaned- or .jsonl.superseded-. Those are earlier transcripts Claude Code set aside, and they don’t appear in the picker.
Where is Claude Code history on Windows?
It’s in %USERPROFILE%\.claude\projects\, in a folder named after your working directory with the same character replacement.
Can I resume a Claude Code session on a different computer?
Not from Claude Code’s own history. While a session is running, /remote-control lets you drive it from claude.ai/code or the Claude app on another device. claude --resume accepts a file at an absolute path, so copying one over is the obvious thing to try, but Anthropic doesn’t document that as a way to move sessions between machines.
Commands, paths and retention rules are from Anthropic’s docs on sessions, the .claude directory, the CLI, settings, hooks, Remote Control and cloud sessions, read on November 10, 2026.
Zest is AI coding analytics for engineering teams: it shows which coding agents, models and skills each engineer uses, what they cost, and which sessions end in merged pull requests. See how Zest works.