Claude Code says Autocompact is thrashing. Stop the refill loop
Autocompact thrashing means compaction succeeded, then a file or tool output refilled the context. Claude Code stops retrying so it does not burn API calls. Short answer: 5 steps. 1) Recognize thrashing vs a normal compact; 2) Read oversized files in chunks; 3) Run a focused /compact or move work to a subagent; 4) If it returns after /clear, inspect /context; 5) Prevent the next thrash.
Last updated: · This page is the decision checklist; the tools list for “Fix Claude Code autocompact thrashing” is a separate URL.
How do I stop a Claude Code Autocompact refill loop?
Recognize thrashing vs a normal compact
If you see `Autocompact is thrashing: the context refilled to the limit...`, automatic compaction worked but something immediately filled the window again. Waiting will not help—Claude Code intentionally stops the retry loop. Docs: https://code.claude.com/docs/en/troubleshooting
Read oversized files in chunks
Ask Claude to open a specific line range, function, or section instead of the whole file. Large single reads and huge tool outputs are the usual refill source right after a compact.
Run a focused /compact or move work to a subagent
Use `/compact` with an explicit focus such as `/compact keep only the plan and the diff` so the large payload is dropped. For exploration of big files, move that work to a subagent so it runs in a separate context window.
If it returns after /clear, inspect /context
Run `/clear` when the earlier conversation is disposable, then `/context`. If the Messages row is the largest, a new file or tool output is refilling the window—chunk reads again. If the rows above Messages dominate, trim what loads at session start (rules, MCP, large CLAUDE.md).
Prevent the next thrash
Prefer targeted `@` paths, smaller tool results, and `/compact` between major tasks. For chronic high memory after heavy sessions, restart Claude Code and use `claude --continue` so the conversation resumes in a fresh process without carrying the bloated heap.
Which tools are best to fix Claude Code autocompact thrashing?
Claude Code troubleshooting
Official Autocompact is thrashing recovery steps and /context guidance.
Manage Claude’s memory
How CLAUDE.md and memory load into context at session start.
Claude Code costs
Why burning tokens on a compact retry loop matters on plan and API billing.
Claude Code overview
Product docs after you stabilize context size.
Open: 1 spot per week
One labeled sponsor for this topic each week; this week's spot is open. See open weeks →
All tools for “Fix Claude Code autocompact thrashing” →
Related fixes
- Stop a Cursor agent loopHow to fix a Cursor agent loop (same edit, or work after Stop)Fix →
- Claude Code vs Codex vs Cursor ~$20 plansClaude Code vs Codex vs Cursor $20 plan limits: how to pick without burning the weekFix →
- Scan a vibe-coded app for leaked API keysCheck a vibe-coded app for leaked API keys before you share itFix →
- Add an MCP server to Claude Code, Cursor, or CodexHow to add an MCP server to Claude Code, Cursor, or CodexFix →
See also AI tools launched today on the daily board.
NewAIToolsToday Daily
Top 3 AI launches, one model or news item that matters, and one simple fix. A 5-minute read, every weekday.