[FEATURE REQUEST] Better compaction is possible without any fancy machinery, MCPs, and with very little plumbing.

Resolved 💬 10 comments Opened Aug 25, 2025 by ariccio Closed Jan 13, 2026

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [X] Other: Claude code
  • Claude CLI version: 1.0.90 (Claude Code)
  • Operating System: macOS 15.6, BuildVersion: 24G84
  • Terminal: zsh 5.9 (arm64-apple-darwin24.0), macOS terminal Version 2.14 (455.1)

Bug Description

Current autocompaction and manually invoked compaction is acceptably okay-ish, but could be a lot better. This is not necessarily a trivial problem. I'm by far not even close to the only one in the world thinking about LLM context management. I'm proposing an automatable workflow that may be an easy to implement tremendous improvement.

I think everybody's kinda known how this relates specifically to claude code for a while, and there are of course plenty of issues filed here about it:

...and closely-matched but not exactly the same issues:

Some other users who seem to be paying attention here include:

  • @coygeek

Steps to Reproduce

  1. Give claude a VERY long running task that consumes many many tokens, kick it off to work with autocompaction turned on, OR prepare to pay attention and manually invoke /compact as you approach the full window capacity.
  2. Let it autocompact or compact manually
  3. Watch as claude slowly loses focus over the course of several iterations of compaction to the point of digital punding.

Expected Behavior

~~Magic~~Claude code intelligently figures out what to bring across the compaction events to continue seamlessly.

Actual Behavior

Claude slowly loses focus over the course of several iterations of compaction to the point of being actively counterproductive or harmful.

Additional Context

I'm not opening this just to further saturate the Anthropic dev team with open issues on a multibillion dollar product. I've just found one manual workflow that is very simple and has worked nearly perfectly for me for almost a month now, without any complex tooling, memory/planning MCPs, or plumbing. It's kinda shocking to me that it works so well and isn't built in.

The workflow that works for me is:

  1. When approaching the context limits, preferably as early as 130k-140k tokens, interrupt any ongoing work if necessary, ask claude something like one of the prompts after this list, all taken directly from my claude history. Copy the prompt that it spits out to the clipboard.
  2. run /compact. Sometimes - only for the most complex and longest running tasks - also ask the compaction to ultrathink to reduce token usage as much as possible without losing any relevant context, reasoning, information, or anything else critical to seamlessly continuing after the compaction. The decision to ultrathink or not could even be made in the prior step, as an output of the model depending on the complexity it encountered in generating the continuation prompt.
  3. Paste the continuation prompt into the post-compaction input field. Sometimes, it's worth explicitly referencing the notes files that claude wrote to disk in the prior steps.

Example prompts from my Claude code history

(simple)
please provide me with a prompt that contains all the required info, context, reasoning, direction, and references, to seamlessly continue after auto-compaction. It should be seamless - retaining everything you need to perform at your maximum potential and maximum creativity."
(more complex, more effective)
Please write ALL the relevant thoughts, reasoning, context, state, and anything else to notes on disk, and then give me a prompt I can copy and paste into a new session of claude code to seamlessly continue this work, without any loss of reasoning ability, details, focus, intelligence, or goal-directed abilities.

or

Please provide me with a prompt that contains all the required info, context, reasoning, direction, and references, to seamlessly continue after auto-compaction. It should be seamless - retaining everything you need to perform at your maximum potential and maximum creativity.

or

Ok. This is a good point to take a deep breath and manage context - of which we only have 12% left before auto-compaction. Please ultrathink to generate a prompt for me that (e.g. contains ALL the relevant context and thoughts and plans and directions and TODOs) will allow us to seamlessly continue with this extremely long and complex task without any loss of reasoning abilities, loss of focus on the tasks at hand, and maintaining your excellent benevolent-skynet-like abilities to self improve (which I have seen and loved so far!). Write notes to disk if it will help.

The specific mention of "benevolent-skynet-like abilities to self improve" is something that does actually (hilariously) help for some workloads.

the general form of what I've been using in the past week:
Excellent work so far. We will have more work to do on this next - but first we need to do some context management. As per the instructions, write any and all relevant distilled thoughts, context, reasoning, plans, and anything else critical for a seamless continuation after compaction. Please also provide a prompt that I can copy and paste into claude, detailed and thorough enough to continue seamlessly even if I were to paste into a fresh instance of claude code, that contains all relevant distilled thoughts, reasoning, and and all relevant context, plans, and anything else necessary to continue our work seamlessly.

I initially used this workflow with sonnet, but then the workflow was partly responsible for really improving my claude code user experience so much that I then held back the tears and upgraded to the $100/mo and $200/mo option to use opus 4, for which the workflow essentially never fails me. ultrathink opus 4 may be too expensive to implement by default compared to the improved developer experience, but that's a business decision for anthropic, not something I can provide technical feedback on.

I have no idea why I've figured out something this simple, and this effective. I will be shocked if it turns out that nobody at anthropic has considered or tried this approach! That seems unusual, surely I'll just be the 497th person to propose it. And yet, I know that if I never share it, there's a zero percent chance it'll help.

I've used this workflow across as many as two dozen compactions and had zero degradation of performance. It might work well enough that autocompaction would actually be sustainable and useful as a strategy for many man dozens of autocompactions. I don't have the tooling, infrastructure, or formal skills, necessary to evaluate that at scale though.

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗