TokenPincherGet started

Claude Code /compact Explained

TokenPincher

/compactis Claude Code's built-in command for dealing with a conversation that's grown too large for the context window. It's free, it's already there, and it does a real job — but it's worth understanding exactly what it does and doesn't do before you rely on it.

What /compact actually does

When you run /compact, Claude Code takes the existing conversation history and asks the model to summarize it into a shorter form, then continues the session from that summary instead of the full transcript. Claude Code will also trigger this automatically as you approach the context limit if you haven't run it manually. The goal is to preserve the gist of what happened — decisions made, state of the task — while freeing up room in the context window for new work.

What survives, and what doesn't

Summarization is lossy by nature. High-level decisions and the current state of the task tend to survive. What tends to get thinned out or dropped:

  • Exact file contents read earlier in the session — you get the gist, not the verbatim text.
  • Specific error messages or command output from earlier steps.
  • Minor exploratory detours that didn't end up mattering (reasonably dropped) but occasionally something you did need.

If the model needs to reference something precisely from before the compact — an exact line of code, an exact log line — it may no longer have it verbatim and will need to re-fetch it, costing you the tokens again.

When to use it

/compactis the right call when you're deep into a single task, the context window is filling up, and you need continuity — stopping and restarting would lose more than summarizing will. It's the wrong call when you're actually done with a task or switching to something unrelated: at that point /clearis cleaner, since there's no benefit to keeping even a summary of unrelated work around. See our guide on what to do when the context window fills up for the fuller /compact vs /clear decision.

Its limits

Two things /compactdoesn't solve:

  • It's manual (or reactive). You have to run it, or wait for Claude Code to force it near the limit. Nothing about it prevents the context from filling up quickly in the first place.
  • It only touches chat history.The biggest source of token spend in an agentic session — large tool output, file reads, logs — isn't what /compactis compressing. It's summarizing the conversation aboutthat output, not shrinking the output itself before it's added to context on each turn.

Always-on compression as a complement

TokenPincher targets the piece /compactdoesn't: tool output and logs, compressed automatically and lossless by default, on every request, before they ever get added to context — no manual step, no waiting for a warning. The two aren't competing approaches. You can keep using /compact for chat history when a long task needs continuity, while TokenPincherhandles the tool-output side continuously in the background.

Install
npx tokenpincher init

For a direct side-by-side, see /compact vs TokenPincher. For the complete guide to reducing Claude Code token usage, read how to reduce Claude Code token usage or the Claude Code overview.