You're deep into a Claude Code session — context built up, a plan in motion — and you close the wrong terminal tab, your laptop sleeps and drops the SSH connection, or the window crashes. The work feels gone.
It isn't. Claude Code persists every conversation to disk as you go, so a closed terminal almost never means a lost session. This guide shows you the two commands that bring it back, where the transcripts actually live, and how to reopen the closed terminal window itself.
TL;DR
cd /path/to/your/project # the SAME directory the session ran in
claude --continue # reopen the most recent conversation here
# or
claude --resume # pick from a list of past sessions
That's the whole fix in most cases. The rest of this article explains why it works and what to do when it doesn't.
Why Your Session Isn't Lost
Claude Code doesn't keep your conversation only in memory. As the session runs, it appends every message, tool call, and result to a transcript file on disk. Because that file is written continuously, your history survives:
- Closing the terminal window or tab ✓
- Quitting or killing the
claudeprocess ✓ - Closing your laptop / dropping an SSH connection ✓
- Rebooting the machine ✓
The terminal window is just a view onto the session. Closing it doesn't delete the transcript any more than closing a document viewer deletes the document.
The Fix: --continue and --resume
There are two ways to reopen a past conversation, and the difference matters.
claude --continue (or claude -c)
Reopens the most recent conversation in your current directory, immediately, with no prompts:
cd /path/to/your/project
claude --continue
This is what you want right after an accidental close — it's the fastest path back to the session you just lost.
claude --resume (or claude -r)
Shows an interactive picker of past sessions so you can choose which one to reopen:
cd /path/to/your/project
claude --resume
Use this when you've had several conversations in the same project and the most recent one isn't the one you want. You can also resume a specific session directly by passing its ID or name:
claude --resume 59d46c3a-4fc1-4213-b8fa-d99925c0443b
claude --resume my-feature # if you named the session
Tip: Add
--fork-sessionto resume into a new session ID instead of writing back into the original transcript — handy when you want to branch off an old conversation without altering it.
When --continue Can't Find Your Session
Ninety percent of the time, the reason is you're in the wrong directory.
Claude Code scopes conversations to the project directory they were created in. --continue and --resume only look at sessions belonging to your current working directory (plus any its git worktrees). So:
# This works — same directory the session ran in
cd /Users/you/git/myproject
claude --continue
# This does NOT find it — different directory
cd /Users/you
claude --continue # "no conversation found here"
The fix is simply to cd back into the exact project folder before resuming. If you're not sure which folder it was, the next section shows you how to find it on disk.
Where Claude Code Stores Your Conversations
Every conversation lives in a plain file under your home directory:
~/.claude/projects/<encoded-project-path>/<session-uuid>.jsonl
<encoded-project-path>is your project's full path with the slashes turned into dashes. For example,/Users/sean/git/inventivehqbecomes the folder-Users-sean-git-inventivehq.<session-uuid>.jsonlis a single conversation, named with its session ID, stored as JSON Lines (one JSON object per line).
On Windows the base folder is %USERPROFILE%\.claude\projects\.
You can list and inspect them directly:
# See which projects have saved sessions
ls ~/.claude/projects/
# List the conversations for one project, newest last
ls -lt ~/.claude/projects/-Users-sean-git-inventivehq/
# Peek at a transcript without resuming it
tail -n 20 ~/.claude/projects/-Users-sean-git-inventivehq/<session-uuid>.jsonl
Because these are plain text, you can recover the content of a conversation — prompts, responses, file edits — even if you never resume it. The folder name also tells you exactly which directory to cd into so that --continue will work.
Reopening the Terminal Window Itself
Resuming the conversation is solved. But you may also want the terminal window back — your tabs, your scrollback, the commands you'd typed around Claude Code. That's a separate problem handled by your terminal app and shell, and there's no universal "undo close" shortcut. We've written dedicated step-by-step guides for each platform:
- macOS — How to reopen a closed Terminal window on macOS: why Cmd+Shift+T doesn't work in Terminal, how to make windows restore on relaunch, recovering commands from
~/.zsh_history, and iTerm2's session restoration. - Windows — How to reopen a closed PowerShell window on Windows: restoring Windows Terminal tabs on launch, and recovering every command from PSReadLine's
ConsoleHost_history.txt.
The key thing to remember: even if the terminal window can't be perfectly restored, your Claude Code conversation is safe — it never depended on that window.
Avoiding the Panic Next Time
You don't have to do anything to get persistence; it's automatic. A few habits make recovery even smoother:
- Name important sessions. Start a session with
claude --name auth-refactorso it's easy to spot in the--resumepicker weeks later. Rename mid-session with/rename. - Know your reflex command. Right after any accidental close:
cdinto the project, runclaude --continue. Commit it to muscle memory. - Run terminals durably for remote work. Over SSH, start Claude Code inside
tmuxorscreenso a dropped connection only detaches the window — the session (and everything else in that shell) keeps running.
Summary
- Closing the terminal does not delete your Claude Code conversation — it's written to disk continuously.
- Run
claude --continuefrom the same project directory to reopen the most recent session, orclaude --resumeto pick from a list or resume by ID/name. - If
--continuecan't find it, you're almost certainly in the wrong directory; transcripts live in~/.claude/projects/in a folder named after the project path. - Reopening the terminal window itself is a separate task — see the macOS and Windows guides.