Skip to main content
These commands control the lifecycle and state of your Claude Code session — clearing or compressing context, resuming previous conversations, monitoring token and cost consumption, and exiting.

/clear

Wipe conversation history and start fresh

/compact

Summarise history into a compact context

/resume

Return to a previous conversation

/context

Visualise current context window fill

/cost

Show session API cost breakdown

/usage

Show plan usage limits

/exit

Quit Claude Code

/clear

Clears the entire conversation history and frees up context. Equivalent to starting a brand-new session while staying in the same terminal. Aliases: reset, new
Arguments: none
Non-interactive: no

When to use

  • The conversation has drifted off-topic and you want a clean slate.
  • You’ve hit the context limit and /compact is not sufficient.
  • You want to start a completely unrelated task.
/clear permanently discards the current conversation history from the REPL. It is not recoverable after the session ends. Use /compact if you want to retain a summary for continuity.

Example


/compact

Compresses the current conversation into a summary and continues with that summary as the new context. This frees up a large portion of the context window while preserving the essential history. Arguments: [optional summarisation instructions]
Non-interactive: yes (can be used in --print mode)
Disabled by: DISABLE_COMPACT=1 environment variable

How it works

  1. Claude Code sends the current conversation to the model with an internal summarisation prompt.
  2. The model produces a concise summary capturing key decisions, code changes, and outstanding tasks.
  3. The conversation is replaced with the summary as a system message, freeing context.
  4. If session memory is configured, the summary is also written to the session memory file.

Custom summarisation instructions

Pass an optional argument to guide what the summary prioritises:
Without arguments, the default summarisation prompt is used, which tries to capture all important context.
/compact is also triggered automatically by Claude Code when the context window is approaching its limit, unless disabled by configuration.

Examples

Compact with default instructions:
Compact with custom focus:
Compact in non-interactive (print) mode:

/resume

Opens a session picker that lets you search through and resume previous Claude Code conversations. When resumed, the full conversation history is loaded back into context. Aliases: continue
Arguments: [conversation id or search term]
Non-interactive: no

Usage

Run without arguments to open the interactive session browser:
Pass a session ID or search term to jump directly to a match:

Session browser

The browser shows sessions sorted by most recent activity. You can:
  • Type to filter by session content or description
  • Use arrow keys to navigate
  • Press Enter to load the selected session
Sessions are stored in ~/.claude/projects/. Each project directory contains .jsonl transcript files named by session ID.

/context

Displays the current context window utilisation as a colour-coded grid. Each cell represents a fraction of the total context window. Arguments: none
Non-interactive: yes (shows raw numbers in non-interactive mode)

Example output

Colours shift from green → yellow → red as the window fills. When above ~80%, consider running /compact or starting a new session with /clear.

/cost

Shows the total API cost and time elapsed for the current session, broken down by model and token type. Arguments: none
Non-interactive: yes
Hidden for: claude.ai subscribers (cost is covered by subscription)

Example output

/cost shows the cost for the current session only. Use /insights to analyse costs across multiple historical sessions.

/usage

Displays your plan usage against the current billing period’s limits. Available to claude.ai subscribers only. Arguments: none
Availability: claude.ai subscribers

Example output


/exit

Exits the Claude Code REPL immediately. Any unsaved state (conversation history, background tasks) is cleaned up gracefully. Aliases: quit
Arguments: none

Example

You can also exit with the standard terminal shortcut Ctrl+D (sends EOF) or Ctrl+C twice in quick succession.
Background tasks started with run_in_background: true are terminated when you exit. If you want them to continue, detach from the session instead of exiting.

/export

Exports the current conversation to a file in your chosen format. Useful for sharing transcripts or archiving sessions. Arguments: [path]

/rewind

Steps back to an earlier point in the conversation, discarding messages after the selected checkpoint. Arguments: none (opens interactive rewind UI)
Use arrow keys to select how far back to rewind. Messages after the selected point are removed from context.