keepcalculator

06 Numbers and Powers

Resume a Claude Code Session When Continue Fails

Card No. 06·71747 · Updated · Standard formula, shown below

When a Claude Code session won’t resume with the usual claude --continue or claude -c command, you can still recover your conversation history and pick up where you left off. This guide walks through manual recovery using the session files that Claude Code stores locally, so you can restore your context, conversation, and working state without losing your work.

What You’ll Need

  • A terminal or command prompt on the machine where you ran the original session.
  • Access to the project directory where Claude Code was used (the session files are stored inside the project).
  • Basic familiarity with the command line (listing files, copying, editing).
  • If you use multiple machines, note that sessions are stored locally, so you must be on the same machine and project directory.

Step-by-Step

  1. Try the standard resume command again with explicit project path. Navigate to the project directory and run claude --continue (or claude -c). If that fails, try claude --resume (older versions) or claude --continue --force. Sometimes a stale lock or a transient error clears.
  2. Check if the session is actually stored. If the resume command says “no session found,” the session file may have been deleted or is in a different location. Look at the project’s .claude folder: ls -la .claude. You should see a projects subfolder containing JSON files named by a hash of the project path.
  3. Identify your project’s session file. Inside .claude/projects, list files: ls -la .claude/projects. Each JSON file corresponds to a project. If you have multiple, check the modification times to find the most recent one. You can also open each file and look for the project field to match the path.
  4. Open the session file to inspect its contents. Use cat or a text editor to view the JSON. The file contains a history array with the conversation messages, plus metadata like session_id, cwd, and tools. If the file is empty or malformed, the session is likely corrupted and you’ll need to salvage what you can.
  5. If the file is valid, try resuming by specifying the session ID. Look for a field like session_id or uuid in the JSON. Then run claude --continue <session_id> (or claude -c <session_id>). This directly targets the session, bypassing the project detection.
  6. If the resume command still fails, start a new session and manually re-import context. Run claude in the same project. Then, in the new session, paste the key parts of the old conversation—especially the original request, any constraints, and the last few exchanges. This is a manual but reliable way to continue.
  7. As a last resort, extract the conversation from the JSON. If the session file is intact but the CLI refuses to load it, you can read the history array and copy the text of each message into a text file. Then start a new session and feed that file to Claude using cat session_history.txt | claude or by pasting the content.

Common Mistakes

  • Running the resume command from a different directory. Claude Code stores sessions per project, so you must be in the exact same project folder where the session started.
  • Assuming sessions are stored globally. Sessions are not synced across machines or even across different clones of the same repo. If you switched computers, the session won’t be there.
  • Deleting the .claude folder. Some users clean up hidden folders, not realizing they contain session history. Avoid deleting .claude unless you’re sure.
  • Overwriting the session file. If you try to edit the JSON manually, a syntax error can corrupt the session permanently. Back up the file first.
  • Using an outdated flag. The --resume flag was used in older versions; newer versions use --continue. Check your version with claude --version.

Tips

  • Use the session ID early. When you start a session, note the session ID that appears in the header. You can then always resume with claude -c <id> even if the project detection fails.
  • Keep a backup of the .claude folder. Periodically copy .claude/projects to a safe location, especially before upgrading Claude Code or cleaning your system.
  • Use --continue with a time limit. If you have multiple sessions, you can list them with claude --sessions (if available) to see recent session IDs.
  • Export important conversations. If a session contains critical context, copy the conversation text to a markdown file as a fallback.
  • Check for updates. Resume failures are often bugs that get fixed. Run claude update or reinstall the latest version.

Troubleshooting

What if the session file is corrupted? Open the JSON in a text editor. If it’s truncated or has invalid syntax, you can try to salvage the history array by copying the readable parts. If the file is completely unreadable, you’ll have to start fresh and manually re-enter the context.

What if the resume command says “permission denied”? Check file permissions on the .claude folder and its contents. Run chmod -R u+rw .claude to ensure you have read/write access.

What if the session ID is not recognized? The ID might have expired or been cleaned up. Claude Code may prune old sessions after a certain time or when the project is deleted. If so, you’ll need to rely on the manual import method.

What if the CLI hangs or crashes on resume? This can happen with a very large session. Try starting a new session and using the manual import method instead. Also check for any background processes that might be locking the file.

What if the session file exists but the history is empty? The session might have been created but never received a message. In that case, there’s nothing to resume; just start a new session.

What if the project path has changed? If you moved the project folder, the session file’s hash (based on the path) will no longer match. You can rename the session file to match the new path hash, but this is advanced. Easier to use the session ID or manual import.

Frequently Asked Questions

Can I resume a session from a different machine?

No. Sessions are stored locally in the project’s .claude folder. You must be on the same machine and in the same project directory.

Will my session be lost if I update Claude Code?

Usually not. Updates preserve the .claude folder. However, it’s wise to back up the folder before a major update, just in case.

Is there a way to list all my previous sessions?

Some versions support claude --sessions or claude --history. If not, inspect the .claude/projects/*.json files and look at modification times.

What does the --continue flag actually do?

It tells Claude Code to load the most recent session for the current project. If that fails, it may be because the session file is missing or corrupt.

Can I manually edit the session JSON to remove a bad message?

Yes, but carefully. Make a backup first. Edit the history array to remove the problematic entry, ensuring valid JSON. Then try resuming again.

How long are sessions kept?

There’s no fixed retention. Sessions are kept until the .claude folder is deleted or manually cleaned. Some versions may have a max size limit, but generally they persist indefinitely.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →