Claude Code Sessions
Level 1 · Starting out
How a Claude Code session keeps one chat, where it is saved, and how to pick it up later. What fills the context window and how compact frees room.
Course contentsLesson 2 of 16
Level 1 · Starting out
Level 2 · Asking before it acts
Level 3 · Telling it how you work
Level 4 · The tools it uses
Level 5 · Growing past one chat
After this lesson you can
- Resume the last session or an older one
- Say where a session is saved and for how long
- Explain what auto-compact keeps and what it may lose
10 mincovers 7 glossary entries
Worth reading first: Claude Code and Its Surfaces
How a session keeps your work
A Claude Code session is one chat, tied to the folder you started it in. It is saved as you go, one line of JSON per message, under ~/.claude/projects/ on your computer. By default the files are kept for 30 days. Run claude --continue to reopen the last session, or /resume to pick an older one.
Each session has its own memory of the chat. What you say in one session does not leak into another. So you can run two sessions at once in two terminals, one on a bug and one on a new page, and neither gets confused by the other.
Running /clear starts a fresh chat and keeps the old one saved, so /resume can still find it. Use /clear when you switch to a new task. A long chat about a bug you already fixed only gets in the way of the next job.
The saved file is called the session transcript. Each message, each tool call and each result is one line in it. Claude Code reads it back when you resume. You can open it yourself to see exactly what happened, though its format can change between versions.
All that Claude sees at once has to fit in its context window. Your prompts, its replies, the files it read and the output of each command all take up room, counted in tokens. A long session full of logs can fill it. Then the model starts to lose track of the early parts.
When the window is nearly full, auto-compact writes a short summary of the chat so far and carries on from there. Your CLAUDE.md file at the top of the project is read again from disk after a compact. A rule you only typed in the chat may be lost. You can also run /compact yourself and say what to keep.
Claude Code also adds notes of its own to the chat, called system reminders. The list of skills you have, and a note that a file Claude edited has changed on disk, both reach Claude this way. You never type them. They are why Claude knows about your setup without being told each time.
On a Claude plan, use is counted against usage limits. The count resets every five hours. When a window is full, Claude Code tells you when it resets. A company can also send numbers about use, such as cost and tokens, to its own dashboard. A shared format, OpenTelemetry, carries them.
claude --continue
claude --resumeWorked example
Emma compacts on purpose
Emma has spent 2 hours in one session chasing a slow page, and the chat is full of logs. She found the cause an hour ago.
She runs /compact keep the cache fix and the test plan. The summary is short, the logs are gone, and Claude still knows the two things she needs next.
The words for this lesson7
Check yourself
You ran /clear an hour ago. Can you get the old chat back?
Finished this lesson?
Marking it complete also marks its 7 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.