Claude / Operating Manual · Reference

← All Operating Manual pages

Context management

Steer what stays in the window and what persists across sessions. /compact directs compaction, /clear resets, /memory edits the memory files.

GA · updated 2026-08-24

The commands for managing the live context window and the files that persist between sessions. For how the layers fit together and what belongs where, see Memory & Context.

How you use it day-to-day

  • /compact [instructions] summarizes the conversation when the window fills, and you can steer what survives: /compact focus on the auth refactor and the files still to migrate keeps your working set instead of a generic summary. The highest-value long-session move.
  • /clear wipes the conversation context for a clean start, while leaving your CLAUDE.md and memory files in place. Reach for it between unrelated tasks rather than letting an old thread bleed into a new one.
  • /memory opens and edits your CLAUDE.md memory files and controls auto-memory from inside the session, so you never hand-edit the files.
  • # mid-session writes a one-line rule straight into CLAUDE.md instead of forgetting it after the turn.
  • /context in a fresh session shows what's already loaded (CLAUDE.md, MCP tools, skills). Audit it once per project and disable unused MCP servers with /mcp; startup context is a tax on every single turn.
  • Set /model and /effort once, at the start. Changing either mid-conversation breaks the prompt cache and re-prefills the whole window at full price. Anthropic's cost ranking: model choice first, session length second, cache breaks third, command noise fourth.
  • /rewind beats /compact for a wrong turn. Rewind only cuts the end and keeps the cache; save /compact for when the whole conversation needs rewriting.

Gotchas

  • Auto-memory loads in full every session. The MEMORY.md index is read every time, so keep it lean and one fact per entry. Past a couple hundred lines it crowds out real work.
  • The automatic compaction summary is generic. On a long session, run a directed /compact before the window forces one on you, or you lose the details you cared about. Compact before a break, not after: the prompt cache expires after about an hour on subscriptions, so summarizing while it's still warm is materially cheaper than resuming cold.
  • Noisy commands quietly eat the window. Add quiet flags (--reporter=dot and friends) or run loud commands in a subagent so pages of test output don't ride along on every turn.
  • A subagent resets the clock. Quality degrades as the window fills; delegating a noisy task to a subagent keeps your main context clean (it gets a fresh window).
  • Nothing persists unless it is in a file. Between sessions, only CLAUDE.md and memory files survive. If you want it next time, write it down (or press #).