# Claude Code Sessions

> 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:** [Claude Code Basics](https://learn.benibix.com/learn/ai-claude-code)  
**Time:** 10 min

**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

## 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.

```bash
claude --continue
claude --resume
```
Open the last session in this folder, or pick an older one from a list.

![One chat between you and Claude in the folder my-app, saved to disk as you go. Later, claude --continue brings the whole chat back. A note says /clear starts a new chat and keeps this one stored.](https://learn.benibix.com/diagrams/cc-session.svg)

### 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.

**Words in this lesson:** [Claude Code Session](https://learn.benibix.com/term/ai/claude-code-session), [Session Transcript](https://learn.benibix.com/term/ai/session-transcript), [Context Window](https://learn.benibix.com/term/ai/context-window), [Auto-Compact](https://learn.benibix.com/term/ai/auto-compact), [System Reminder](https://learn.benibix.com/term/ai/system-reminder), [Claude Code Usage Limits](https://learn.benibix.com/term/ai/claude-code-usage-limits), [Claude Code Monitoring (OpenTelemetry)](https://learn.benibix.com/term/ai/claude-code-monitoring)

**Question:** You ran /clear an hour ago. Can you get the old chat back?

**Answer:** Yes, it was saved, and /resume can open it. /clear starts a fresh chat but keeps the old one saved on disk. /resume lists it with your other sessions.

---

Source: https://learn.benibix.com/learn/ai-claude-code/claude-code-sessions
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
