Compact

The context is at 99 percent, so the whole conversation goes into one small box. Afterwards, nobody can quite say what they were building.

Four-panel pixel-art comic starring Walt and Felix. The words are below.

What they say

  1. 1Walt points at a gauge in the red: “Context at 99 percent.”
  2. 2Felix pushes a mountain of printouts into one small box.
  3. 3The box sits taped shut on a desk. The tag reads “Compacted”. Walt, from outside the panel: “So, what were we building?”
  4. 4Felix reads a single card from the box while Walt scratches his head: “Something with a login button.”

What goes in the box

When a conversation reaches the model's context limit, Claude Code compacts it: it summarizes the history so far so the session can go on. /compact does the same when you ask for it. /clear is the other way out, a new conversation with empty context.

A summary is shorter than what it sums up. A decision from an hour ago, or the name of the thing you are building, can be left out of it.

Tell it what to keep

/compact takes focus instructions: /compact Focus on the login flow keeps the summary on that.

What must outlast every summary belongs in CLAUDE.md. After compaction, Claude Code reads the CLAUDE.md at the root of the project from disk again, so what you are building, and how to test it, come back each time. It can also hold a line for the summaries themselves:

When compacting, always preserve the full list of modified files and any test commands.

Watch the gauge

/context draws what fills the context as a colored grid, with warnings as it gets full. A custom status line gets the number from Claude Code as context_window.used_percentage, and AgentValley's status line draws it as a bar, next to the five-hour and weekly limits. To move the point where it compacts, /autocompact sets the window in tokens, from 100K to 1M: /autocompact 500k.

AgentValley is free and open source.

A small valley of programmers in your notch. Needs macOS 15 or later and Claude Code.

Install itRead the code on GitHub