# Manage Context in Claude Code: /clear, /compact

> Use /clear between tasks, /compact within one, /context to see what fills the window, and claude -c to resume. Keeps long sessions fast and cheap.

- Canonical: https://guides-ai.pages.dev/guides/claude-code-manage-context/
- Plate 03.05 · Topic: Claude Code commands (https://guides-ai.pages.dev/topics/commands/)
- Published: 13 Jun 2026 · Updated: 06 Sept 2026 · 3 min read
- Source site: guides-ai — https://guides-ai.pages.dev/

Claude Code sends the whole conversation with every request, so a session left open all day
draws usage for the entire history even on a one-line question. Four commands keep that under
control.

## 1. See what's filling the window

```text
/context
```

What it does: visualizes current context usage as a colored grid — system prompt, memory files,
skills, MCP tool definitions and the conversation. Run it before you guess; MCP servers and an
oversized `CLAUDE.md` are the usual surprises.

## 2. Start fresh with /clear

```text
/clear
```

What it does: starts a new conversation with empty context. Your project setup and `CLAUDE.md`
still load; the chat history is gone. `/clear` also resets the session cost counter, and it
costs nothing — unlike compaction.

Use it whenever you switch to unrelated work. Stale context wastes tokens on every subsequent
message.

## 3. Shrink a long task with /compact

```text
/compact focus on the auth refactor decisions and open TODOs
```

What it does: summarizes the conversation so far and continues with a much smaller context,
keeping what you name. Claude Code also auto-compacts as you approach the limit.

Compaction reads everything it summarizes, so it is itself a large request. When you want a
clean break rather than continuity, `/clear` is the cheaper move. You can set standing
compaction instructions in your `CLAUDE.md` under a `# Compact instructions` heading.

## 4. Name it, then resume

```bash
claude -c    # continue the most recent conversation in this directory
claude -r    # pick an older session from a list
```

What it does: reopens a session after you close the terminal. Run `/rename` before you clear so
the session is findable, then `/resume` to come back to it.

## Verify it worked

Run `/context` again after compacting. If the grid barely moved, the space is going to
something permanent — memory files, skills or MCP tool definitions — not to your conversation,
and `/compact` will never fix it.

Rule of thumb: `/clear` **between** tasks, `/compact` **within** one. Everything you meet here
is measured in [tokens](/glossary/#token), which is also how it's billed —
[track what a session costs](/guides/claude-code-track-costs/). Two other habits help: keep a
[CLAUDE.md](/guides/create-claude-md-project-memory/) so a cleared session still knows your
conventions, and push big searches into a [subagent](/guides/claude-code-subagents/) so the
output never enters your main window.

Source: [Manage costs effectively](https://code.claude.com/docs/en/costs).
