§03.05

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.

published 13 Jun 2026 updated 06 Sept 2026 checked against docs 06 Sept 2026 3 min in Claude Code commands Markdown

On this page5 sections
  1. 1. See what’s filling the window
  2. 2. Start fresh with /clear
  3. 3. Shrink a long task with /compact
  4. 4. Name it, then resume
  5. Verify it worked

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

/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

/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

/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

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, which is also how it’s billed — track what a session costs. Two other habits help: keep a CLAUDE.md so a cleared session still knows your conventions, and push big searches into a subagent so the output never enters your main window.

Source: Manage costs effectively.

← All Claude Code commands plates · Search all guides

↑↓ move↵ openalt+↵ copy first command

Keyboard

⌘/ctrl+K or /
Search all guides
alt+↵
In search: copy the guide's first command
j / k
Move through a list of guides
c
On a guide: copy its first command
t
Toggle light / dark
?
This list