Claude Code Session Management — Save, Resume, Restart

You’ve been working with Claude Code for two hours on a complex feature. You’ve built up context, made decisions, refined approaches — and now you need to stop for the day. Tomorrow you want to pick up exactly where you left off, not start explaining everything from scratch. That’s what session management is for. And even if you’re working in shorter bursts, understanding sessions will save you from a lot of confusion.

This is part of our complete How Claude Code Works — A Beginner’s Deep Dive.


TL;DR

  • A session is one continuous Claude Code conversation — from when you open it to when you close it
  • Claude Code has no automatic memory between sessions — each new session starts fresh
  • You can resume previous sessions using the --resume flag or /resume command
  • A well-maintained CLAUDE.md file makes every new session feel like a continuation
  • Token limits mean long sessions eventually need a reset — plan your sessions accordingly

What Is a Claude Code Session?

A session is everything that happens from the moment you start Claude Code to the moment you close it. All the messages you send, all the files Claude Code reads, all the code it writes — that’s your session. The full conversation history lives in that session’s context window.

Here’s what’s not automatic: Claude Code does not carry memories from one session to the next. Close the terminal and reopen it tomorrow, and Claude Code won’t remember what you were working on. This isn’t a bug — it’s by design. Each session starts clean.

Think of it like working with a very capable colleague who has perfect memory within a day, but wakes up fresh every morning with no recollection of yesterday. Your job is to give them a good briefing at the start of each day — or set up systems so they don’t need one.


Step 1: Understand the Session Lifecycle

A typical Claude Code session goes through these phases:

Opening: You start Claude Code from your project directory. Claude Code reads your CLAUDE.md (if you have one) and is ready for your first prompt.


# Starting a Claude Code session
cd ~/projects/my-app
claude
# Claude Code starts and reads CLAUDE.md if present

Working: You send prompts, Claude Code reads files, writes code, and you review and accept changes. Token usage builds up over time.

Approaching limits: As the session grows long, the context window fills. Claude Code may start to lose early context. This is the signal to wrap up the current task and either /clear or start fresh.

Closing: You exit with Ctrl+C. The session ends. The conversation history is gone (unless you’ve saved it — more on that below).


Step 2: Resume a Previous Session

Claude Code stores recent session transcripts so you can pick up where you left off. To resume:


# Resuming the most recent session
claude --resume

# Or use the slash command within a session
/resume

When you resume, Claude Code loads the previous conversation history back into the context window. You’re essentially continuing the same conversation.


# Resuming a specific older session (not just the most recent)
claude --resume [session-id]

# To see available sessions
claude --list-sessions

Terminal showing claude --list-sessions output with a list of recent sessions, dates, and token counts

💡 Pro Tip: Resume is most useful when you had to stop mid-task unexpectedly — a meeting, end of day, system restart. If you’re starting a new task, starting fresh is usually better than resuming an old context.


Step 3: Set Up CLAUDE.md as Your Persistent Memory

Since sessions don’t share memory, the best tool you have is the CLAUDE.md file. Claude Code reads this at the start of every session, automatically. Whatever you put in there is always available.

Think of CLAUDE.md as your session briefing document — the information Claude Code needs to work effectively on your project, regardless of how many sessions you’ve had or how long ago the last one was.


# CLAUDE.md template for session persistence
# Project: [Your App Name]

## Current Status
[Optional: what you're working on right now — update this as the project evolves]

## Active Feature Branch
[Optional: what feature or sprint you're currently building]

## Recent Decisions
- [Date]: Decided to use Zustand instead of Redux for state management
- [Date]: Agreed to delay the notification system until v2

## Tech Stack
[Your stack — framework, language, key libraries]

## Conventions
[Naming, patterns, things Claude Code should always do]

## Off-Limits
[Files or directories not to touch without asking]

The “Recent Decisions” section is particularly useful. Every time you make a significant architecture or approach decision in a Claude Code session, add it to CLAUDE.md so future sessions know about it.


Step 4: Use /clear to Reset Context Without Ending the Session

Sometimes you don’t want to end the whole session — you just want to start a new task with a clean context slate. That’s what /clear does.


# Clearing conversation context mid-session
/clear

# Output
Conversation context cleared.
CLAUDE.md is still active.
Files on disk are unchanged.
Ready for your next prompt.

After /clear:

  • The conversation history is gone from the context window
  • Token count resets
  • CLAUDE.md is still read (it’s re-read fresh)
  • All your files are exactly as you left them — nothing on disk changes
  • You’re ready to start a new task from a clean slate

When to use /clear vs. starting a new session:

Use /clear when you want to stay in the terminal but need fresh context. Start a new session when you’re switching projects, or when /clear alone won’t fix a stuck situation.


Step 5: Plan Your Session Length

Not every session needs to be the same length. Knowing what kind of task you’re doing helps you plan.

Short sessions (15-30 minutes, low token use):

  • Fixing a specific bug
  • Adding a small, contained feature
  • Writing tests for an existing function
  • Code review or explanation requests

These sessions rarely hit context limits. Just work and close when done.

Medium sessions (1-2 hours, moderate token use):

  • Implementing a new feature across several files
  • Refactoring a module
  • Iterative back-and-forth on a complex problem

Watch your token usage with /status. Plan to /clear or wrap up naturally before you approach 80% context usage.

Long/complex sessions (2+ hours or many files):

  • Major feature development
  • Large-scale refactors
  • Migrations or significant architecture changes

For these, use Plan Mode upfront to map out the work. Break it into chunks. Use /clear between major chunks. Keep CLAUDE.md updated so each chunk starts with good context.

⚠️ Warning: Working in a single session for many hours on a very large task can cause Claude Code to start making inconsistent decisions as early context drops out of the window. Better to plan for multiple sessions with CLAUDE.md carrying the important context between them.


Step 6: Save Important Outputs Before Closing

There’s no automatic session logging in Claude Code by default. If Claude Code explained something important — architecture reasoning, a decision it made, a plan it laid out — and you want to keep it, you need to save it yourself.

Option 1: Copy Claude Code’s output to a notes file


# Saving Claude Code's architectural explanation to a notes file
# (Run in a separate terminal tab)
echo "Claude Code recommended using the Repository pattern for data access because:
- Easier to swap out the database layer later
- Better testability with mock repositories
- Consistent with the existing service layer pattern" >> docs/architecture-notes.md

Option 2: Add key decisions directly to CLAUDE.md

If it’s a project decision that should affect future sessions, put it in CLAUDE.md:


# Adding a session decision to CLAUDE.md
## Architectural Decisions
- Use Repository pattern for all database access (decided 2024-03-15)
- All repositories live in src/repositories/ and extend BaseRepository
- Never access Prisma directly from API routes — always through a repository

Option 3: Use git commit messages

Your commit messages are a form of session documentation. When you finish a Claude Code session that produced significant changes, write a detailed commit message:


# Detailed commit message that captures session work
git commit -m "feat: add user notification system

- New NotificationService with in-app and email delivery
- NotificationBell component added to main Header
- Notifications stored in PostgreSQL via new notifications table
- Order creation now triggers notifications automatically

Architecture decision: notifications are soft-deleted, not hard-deleted,
to preserve audit trail for customer support."

Common Mistakes and How to Fix Them

Mistake 1: Expecting Claude Code to Remember Yesterday’s Session

Problem: You open Claude Code the next day and say “continue where we left off” — Claude Code has no idea what you mean.

Fix: Either resume the session explicitly with claude --resume, or re-establish context in your first prompt. Better yet, use CLAUDE.md to persist the important stuff automatically.

Mistake 2: Never Updating CLAUDE.md

Problem: You made a big architectural decision three weeks ago in a Claude Code session. Today’s session has no idea about it and goes in a conflicting direction.

Fix: Update CLAUDE.md whenever you make a significant decision. It takes two minutes and saves you from relitigating decisions in future sessions.

Mistake 3: Resuming When a Fresh Start Is Better

Problem: You resume an old session from two weeks ago, hoping to continue a task. But the context is stale — files have changed, requirements have shifted — and the resumed context is more confusing than helpful.

Fix: Resume works best for continuing tasks you stopped mid-stream. For returning to a project after time away, start fresh with an updated CLAUDE.md.

Mistake 4: Running One Giant Session for Complex Multi-Day Work

Problem: You try to do a major multi-day feature in a single Claude Code session, running it continuously. Context fills up, things get confused.

Fix: Design your work in session-sized chunks. Finish a chunk, commit the code, update CLAUDE.md with decisions made, start a new session for the next chunk.

Mistake 5: Not Checking Session Status Before a Big Task

Problem: You start a complex task late in an existing session, not realizing the context is already at 60%. Midway through, you hit the limit and Claude Code starts losing context at the worst possible time.

Fix: Before any significant task, run /status. If you’re above 40%, either /clear or start a new session first.


Key Takeaways

  • A session is one continuous conversation — Claude Code has no automatic memory between sessions
  • Use claude --resume or /resume to pick up a previous session
  • CLAUDE.md is your best tool for persistent context — it’s read at the start of every session
  • /clear resets the conversation history without ending the session or touching your files
  • Plan session length based on task complexity — for big work, break it into session-sized chunks

Next Steps

Return to How Claude Code Works — A Beginner’s Deep Dive for the full picture.