Home
Back to Blog
TUTORIALBasic

How to View Claude Code Terminal Session History

A complete guide to viewing Claude Code session history — where logs are stored, how to search past sessions by date or keyword, how to recover lost code, and four playbooks that make session management effortless.

May 10, 202611 min readClaude Code Playbooks
view Claude Code session historyClaude Code terminal historyClaude Code session logsrecover Claude Code historyclaude session history~/.claudeClaude Code

Claude Code automatically saves the full history of every session — the code it wrote, files it changed, commands it ran, and every message exchanged. This history lives on your machine in a specific directory and is fully searchable. If you've ever closed a session and realized you needed something from it, the good news is: it's almost certainly still there.

This guide explains exactly where Claude Code stores session history, how to navigate and search it natively, and four playbooks that automate the tasks most developers end up needing repeatedly — recovering lost code, logging decisions as they happen, capturing context for the next session, and visualizing conversation history as a searchable knowledge base.

Where Claude Code Stores Session History

All Claude Code session data is stored in the ~/.claude/ directory on your machine. This is your home directory's hidden .claude folder — present on macOS, Linux, and WSL on Windows. Inside it you'll find:

~/.claude/ directory structure

~/.claude/
├── projects/          # One subfolder per project, keyed by directory path
│   └── <project-id>/
│       └── <session-id>.jsonl  # One file per session
├── settings.json      # Your global Claude Code preferences
└── CLAUDE.md          # Your global CLAUDE.md (if set)

Session files use the .jsonl (JSON Lines) format — one JSON object per line, each representing a message, tool call, file change, or command execution in the session. Every session gets its own file, timestamped in the filename.

Windows users

If you're running Claude Code in WSL, the ~/.claude/ directory is inside your WSL home (\\wsl$\Ubuntu\home\yourname\.claude\). If running natively on Windows, check %USERPROFILE%\.claude\.

Viewing Session History with the Claude Code CLI

The fastest way to view or resume a past session is with the built-in claude CLI. Two flags cover the most common needs:

List recent sessions

terminal

# Resume the most recent session in the current project
claude --continue

# Or pick from a list of recent sessions
claude --resume

claude --resume opens an interactive picker showing your recent sessions with timestamps and the first message of each session as a preview. Use arrow keys to navigate, Enter to resume. Claude reloads the full conversation context from the session file — it can see everything that happened, not just the summary.

Continue the most recent session instantly

terminal

claude --continue

This picks up exactly where you left off without the picker. Useful when you closed the terminal by accident and want to get back immediately. Claude resumes mid-thought — if it was in the middle of a task, it can see that and pick back up.

Searching Session History Manually

When you know roughly what you're looking for — a specific function name, an error message, a timestamp — you can search the raw session files directly. They're plain text (JSON Lines), so standard tools work:

Search all sessions for a keyword

terminal

# Search all sessions for a function name or string
grep -r "generateInvoice" ~/.claude/projects/

# Show the surrounding context (5 lines before and after)
grep -r -C 5 "database migration" ~/.claude/projects/

Find sessions from a specific date

terminal

# List session files modified in the last 7 days
find ~/.claude/projects/ -name "*.jsonl" -mtime -7 -ls

# List sessions from a specific project directory
# (projects are stored by path hash, so navigate by modification date)
ls -lt ~/.claude/projects/*/*.jsonl | head -20

Extract code blocks from a session

terminal

# Print all content from a session file in readable form
cat ~/.claude/projects/<id>/<session>.jsonl | python3 -c "
import sys, json
for line in sys.stdin:
    obj = json.loads(line)
    if obj.get('type') == 'assistant' and obj.get('content'):
        for block in obj['content']:
            if isinstance(block, dict) and block.get('type') == 'text':
                print(block['text'])
"

This works but gets tedious fast for anything beyond a one-off lookup. The four playbooks below automate this into repeatable workflows.

Four Playbooks for Session History Management

1. View & Recover Claude Code Session History — for finding lost code

The most common session history need: you closed a session and want something back. Maybe Claude wrote a migration script you never committed. Maybe it refactored a function in a way you want to reference. Maybe the terminal crashed mid-session. The code is in ~/.claude/ — you just need to find it.

The View & Recover Claude Code Session History playbook turns the search into a structured workflow. Describe what you're looking for — the approximate date, a file name, a keyword from the conversation, a function name — and it scans the ~/.claude/ directory, extracts matching sessions, reconstructs the relevant code blocks with their original file paths and context, and presents them ready to copy or re-apply.

example prompt

"Find the database migration code Claude wrote for me last Tuesday.
It was for the users table — adding the email_verified column."
→ Scans session files from that timeframe, finds the migration code block, extracts it with the original file path and surrounding context, and offers to re-apply the change to the current project.

2. Session Logging Protocol — for capturing decisions as they happen

Session recovery solves the problem of finding past work reactively. The Session Logging Protocol playbook solves it proactively: it automatically detects architectural decision points during a development session and logs them — the decision made, alternatives considered, and the rationale — into a structured, searchable log file alongside your code.

Six months later, when you or a teammate wonders why a certain design choice was made, the answer is in a log file rather than lost with the session. Each entry is timestamped and tagged by topic, so the log becomes a searchable institutional knowledge base for the project.

example prompt

"Start the session logging protocol for this refactoring session.
Log all architectural decisions, including why we chose to extract
the payment module separately instead of keeping it inline."
→ Produces a structured decision log at docs/decisions.md with timestamped entries for each key decision point, alternatives considered, and rationale — updated throughout the session.

3. Session Capture & Handoff — for cross-session continuity

Every time you start a new Claude Code session, you lose the context of the previous one. The new session doesn't know what decisions were made yesterday, what blockers are open, or what was left mid-task. The first ten minutes of every session become re-explaining.

The Session Capture & Handoff playbook solves this by running at session end and producing a structured handoff note: key decisions made, open questions with context, completed vs. remaining tasks, and a file change log with rationale. The next session loads this note as its starting context — continuity in two commands.

example prompt

"Capture this session for handoff. I'm stopping for the day and want
to continue tomorrow without losing context. Summarize decisions,
open blockers, and what's left on the auth refactor."
→ A SESSION_HANDOFF.md with decisions, blockers, completed/remaining tasks, and file change log. Load it in the next session: "Read SESSION_HANDOFF.md and continue from there."

4. Chat History Mind Mapper — for knowledge extraction across sessions

If you use Claude Code heavily, you accumulate months of session history. That history contains a lot of accumulated problem-solving — approaches that worked, dead ends, architectural insights, debugging patterns. It's institutional knowledge that's effectively invisible because it's buried in hundreds of session files.

The Chat History Mind Mapper playbook exports your session history, chunks it into summaries, and generates a visual mind map organized by topic cluster — surfacing recurring themes, key insights, and patterns across sessions. The output is importable into NotebookLM or Obsidian, turning scattered session history into a searchable second brain.

example prompt

"Map my last 6 months of Claude Code sessions. Cluster by topic area
(auth, database, API layer, devops) and surface the key decisions
and solutions from each cluster."
→ Session history chunked, summarized, and organized into a visual mind map with topic clusters, key insights per cluster, and recurring patterns — ready to import into NotebookLM or Obsidian.

Which Approach to Use

I need to get back to where I just left off

Use claude --continue or claude --resume. Built-in, instant, no playbook needed.

I lost code Claude wrote in a past session

Use the Session History Recovery playbook. Describe what you're looking for; it scans ~/.claude/ and extracts the relevant code.

I want to document decisions during a session

Use the Session Logging Protocol. Activate it at session start; it auto-logs key decisions throughout.

I'm stopping for the day and want to continue seamlessly tomorrow

Use the Session Capture & Handoff playbook at session end. Load the handoff note at the start of tomorrow's session.

I want to extract knowledge from months of session history

Use the Chat History Mind Mapper. Export, cluster, and import into NotebookLM or Obsidian.

Common Questions

"How long does Claude Code keep session history?"

Session files in ~/.claude/ are kept indefinitely — they don't expire or auto-delete. They only disappear if you manually delete them or clear the directory. On a typical development machine, the ~/.claude/ directory stays manageable in size (a few hundred MB) even after years of use.

"Is my session history private?"

Session files stay on your local machine — they're not synced to Anthropic or any cloud service by default. The content of your sessions (code, file paths, conversation) lives only on the machine where Claude Code is installed.

"Can I view session history on a different machine?"

Sessions are local, so they don't automatically transfer between machines. You can copy the ~/.claude/projects/ directory manually to another machine and Claude Code will recognize the session files there. The Session Capture & Handoff playbook is a cleaner alternative for multi-machine workflows — it produces a portable markdown file instead of depending on raw session files.

"Can I search sessions for a specific file that was changed?"

Yes — file modification events are logged as tool calls in the session JSONL. The Session History Recovery playbook can search specifically for file-change events, making it easy to find "what did Claude do to auth.ts in the session last Thursday" without sifting through conversation text manually.

The Playbooks

The ~/.claude/ directory is one of the most underutilized features of Claude Code. Most developers discover it only after losing code they wish they'd saved — and then realize the history was there all along. The built-in --resume and --continue flags cover the simple cases. The four playbooks above cover everything else.