Skip to main content
Home/Blog/How to Recover an Accidentally Closed Claude Code Session
Developer Tools

How to Recover an Accidentally Closed Claude Code Session

Closed your Claude Code terminal by accident? Your conversation isn't gone. Learn how to resume it with claude --continue and --resume, where transcripts are stored on disk, and how to reopen the closed terminal window itself on macOS and Windows.

By Sean

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 claude process ✓
  • 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-session to 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/inventivehq becomes the folder -Users-sean-git-inventivehq.
  • <session-uuid>.jsonl is 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:

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-refactor so it's easy to spot in the --resume picker weeks later. Rename mid-session with /rename.
  • Know your reflex command. Right after any accidental close: cd into the project, run claude --continue. Commit it to muscle memory.
  • Run terminals durably for remote work. Over SSH, start Claude Code inside tmux or screen so 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 --continue from the same project directory to reopen the most recent session, or claude --resume to pick from a list or resume by ID/name.
  • If --continue can'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.

Frequently Asked Questions

Find answers to common questions

No. Claude Code writes every conversation to a transcript file on disk (under ~/.claude/projects/) as you go. Closing the terminal window, quitting the process, or even rebooting does not delete it. Reopen a terminal, change into the same project directory, and run claude --continue to pick up exactly where you left off.

claude --continue (or claude -c) immediately reopens the most recent conversation in your current directory. claude --resume (or claude -r) shows an interactive list of past sessions so you can choose which one to reopen, and it also lets you resume a specific session by its ID or name. Use --continue when you just want the last one back; use --resume when you need to pick from several.

The most common reason is that you're in the wrong directory. Claude Code scopes conversations to the project directory they were created in, so you must cd back into that exact folder before running claude --continue or claude --resume. If you still can't find it, the transcript files live in ~/.claude/projects/ in a folder named after your project path — confirm the session exists there.

In your home directory under ~/.claude/projects/. Each project gets its own subfolder (named after the project's full path with slashes replaced by dashes), and each conversation is stored as a .jsonl file named with the session's UUID. These are plain-text JSON Lines files, so you can open and read them directly even without resuming.

Not directly through the CLI — --continue and --resume read the local transcript files in ~/.claude/projects/. You could copy the relevant .jsonl transcript to the same relative location on another machine, but the supported path is to resume on the machine where the session ran. The transcripts being plain files on disk is also why a closed terminal never loses them.

You don't need to do anything special — sessions persist automatically. For peace of mind, give important sessions a name with claude --name my-feature so they're easy to find later in the --resume picker, and remember that claude --continue always brings back the most recent conversation in the current directory.

Building Something Great?

Our development team builds secure, scalable applications. From APIs to full platforms, we turn your ideas into production-ready software.