Solo Stack Kits Directory
Claude Code workflows & skills for solo consultants and freelancers

← Blog · 2026-10-22

Claude Code Context Filling Up Fast? Why Auto-Compact Keeps Running, and 9 Fixes

Shortcut: our free status line builder writes a tested statusline.sh that shows how full your context window is on every reply, so you see the squeeze coming instead of being surprised by a compaction. It runs in your browser.

Everything Claude knows about your session sits in its context window: your instructions, every message, every file it reads, every command output, plus things that load before you type a word. When the window gets close to full, Claude Code summarizes the older history to make room. That's auto-compaction. It keeps the session alive, but each summary loses detail, and Anthropic's own best-practices page is blunt about why it matters: performance degrades as context fills, and Claude may start "forgetting" earlier instructions or making more mistakes.

If you're compacting every half hour, something is eating the window. Here's how to find it and fix it.

Why context fills so fast

Four things add up:

None of this goes away on its own. Claude Code sends your full conversation with every request, so stale content also costs you on every message until you clear or compact it.

Step 1: see what's actually using the space

Run /context inside Claude Code. It shows a colored grid of the current window, broken down by category: system prompt, system tools, MCP tools, custom subagents, memory files, skills, and conversation messages, with optimization suggestions for heavy tools and memory bloat. Use /context all if the per-item breakdown is collapsed.

Look at the Messages row versus everything above it:

For a number you can watch all the time, put context percentage in your status line (the context_window.used_percentage field). That's what the shortcut tool above sets up.

9 fixes, in the order to try them

  1. Clear between unrelated tasks. Finished the proposal and moving on to an invoice script? Run /clear. It starts a new conversation with empty context. Old conversation crowds out the files you need next and costs tokens on every message. Want the old session back later? /clear client-a-proposal labels it in the /resume picker, and /resume brings it back. Anthropic's costs page also notes that /clear costs nothing, while compacting a large context is itself a large request.

  2. Compact on purpose, with a focus. Don't wait for the automatic pass to guess what matters. Before starting the next chunk of work, run /compact with instructions, like /compact keep the client requirements and the current plan, drop the test output. The summary keeps what you chose.

  3. Tell compaction what to keep, permanently. Add a section to the CLAUDE.md at the root of your project:

    ```markdown

    Compact instructions

    When you are using compact, please focus on the client's requirements, decisions made, and files changed
    ```

    Every compaction, automatic or manual, then has your priorities.

  4. Summarize only part of the conversation. Run /rewind, pick a message, and choose Summarize from here or Summarize up to here. Handy when the first hour was messy exploration but the last twenty minutes are what matters.

  5. Read big files in pieces. If one huge file or log is the problem, ask Claude to read a specific line range or function instead of the whole thing, or to search it for what you need. For quick side questions, /btw your question answers without adding to the conversation history.

  6. Trim CLAUDE.md. It loads at the start of every session and stays there. Anthropic's guidance is to target under 200 lines per CLAUDE.md file; longer files use more context and Claude follows them less reliably. Two traps: @path imports don't save anything, because imported files also load at launch, and instructions that only matter for one part of a project belong in path-scoped rules, which load only when Claude works with matching files.

  7. Move occasional workflows into skills. Instructions for a monthly report or a contract review don't need to sit in context while you're writing an email. A skill loads its full instructions only when it's used; until then only its short description is in context. Anthropic's costs page suggests exactly this move: specialized instructions out of CLAUDE.md and into skills.

  8. Turn off MCP servers you aren't using. MCP tool definitions are deferred by default, so only tool names and server instructions load until Claude uses a tool, but every connected server still adds to that list. Run /mcp to see your servers and disable the ones you're not using right now (/mcp disable <server> works without opening the list). Where a command-line tool exists, like gh for GitHub, Anthropic notes it's more context-efficient than an MCP server.

  9. Hand big reads to a subagent. Each subagent runs in its own context window. Ask Claude to "use a subagent to read these 30 files and summarize how billing works," and the file contents stay in the subagent's window while only the summary comes back to yours. The same goes for running tests, fetching documentation, or digging through logs. One caveat: subagents still send their own requests, which count toward the same usage limits.

"Autocompact is thrashing"

If you see Autocompact is thrashing: the context refilled to the limit..., compaction worked, but a file or tool output refilled the window several times in a row, so Claude Code stopped retrying. Recover in this order: read the oversized file in chunks, run /compact with a focus that drops the large output (for example /compact keep only the plan and the diff), move the large-file work to a subagent, or /clear if you don't need the earlier conversation. If it comes back right after /clear, check /context: if the startup rows are the big ones, go back to fixes 6 to 8.

"Not enough messages to compact."

/compact returns this when there are too few turns to summarize. It can happen even with a full window when a single big paste filled it. /clear and a smaller paste are the way out.

Controlling when auto-compact runs

You can make it run earlier, not later than your model allows. /autocompact 500k sets how full the window gets before the automatic pass runs, saved for the current model; /autocompact auto puts it back to the default tuned for your model. Run /autocompact with no value to see the current setting. Compacting earlier sounds backwards, but on a model with a very large window it keeps sessions shorter and sharper.

You can also switch automatic compaction off with the environment variable DISABLE_AUTO_COMPACT=1, which leaves manual /compact available. Only do that if you're disciplined about compacting yourself. A session that hits the hard limit is worse than one that compacts.

What survives a compaction

Worth knowing so compaction doesn't scare you: your project-root CLAUDE.md, unscoped rules and auto memory are re-read from disk afterward, invoked skills are re-injected (capped in size, so put the important parts near the top of SKILL.md), and Claude Code re-reads up to five of the files it was most recently working on. What gets summarized away is the back-and-forth, plus path-scoped rules and nested CLAUDE.md files, which reload when Claude touches matching files again.

A simple habit for client work

One client task per session. /clear (with a name) when you switch clients. A focused /compact before a long new step. Keep CLAUDE.md short and put the occasional workflows in skills. That alone stops most constant auto-compacting.


Facts on this page come from Anthropic's Claude Code docs on the context window, managing costs, troubleshooting, commands, model configuration, memory and subagents. This guide isn't affiliated with Anthropic.

Want it set up already? Claude Code Power Config Pack

Fixed it? Skip the next one with a tested Claude Code setup you can drop into any repo.

One install command that backs up your settings first. Checked against the official Claude Code docs. MIT licensed.

Launch price: $6 instead of $12 (code LAUNCH50, first 25 buyers, until Nov 10, 2026).

Get the Config Pack: $6 launch price

Prefer to build it yourself? Use the free Claude Code tools, no sign-up.