claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Allow context warnings to be configurable

Open jrp685 opened this issue 4 months ago • 8 comments

20% is too low given how much performance drops off. It used to be 40%. It would be good if there was a setting to set the percentage when the warning comes up - or a way to configure this via the status bar agent. The context command is useful, but it's manual. The less friction the better.

jrp685 avatar Aug 26 '25 21:08 jrp685

Hey, I've noticed this too and it's definitely been a point of friction. You're right, the threshold was changed. I did a quick dig through the changelog, and it looks like version 1.0.51 "Increased auto-compact warning threshold from 60% to 80%". So your memory is spot on.

While there isn't a direct setting to configure that percentage (which I agree would be ideal), I've found a couple of workarounds from the docs that might help you manage it better:

  1. Disable Auto-Compact Entirely: If the warning is more annoying than helpful, you can turn it off. Just run /config and toggle "Auto-compact enabled" to off. You'll have to rely on manually running /context and /compact when you feel performance degrading, but at least you control when it happens.

  2. Create a Custom Status Line: This is a bit more involved, but it gets closer to what you're asking for. You can create a custom script that acts as your status line. According to the changelog for v1.0.88, the data piped to the status line script now includes an exceeds_200k_tokens flag. You could write a simple script to parse that JSON input and display a custom warning in your status line when your context gets high, giving you a persistent, visual indicator without the intrusive popup. You can get started with /statusline.

  3. Use a PreCompact Hook (Advanced): This is the most powerful option. You can set up a script that runs right before an auto-compact is triggered. This hook could send you a desktop notification or print a custom message, giving you a chance to intervene before Claude compacts the context.

It's not a perfect substitute for a simple percentage setting, but hopefully one of those helps reduce the friction for you.

+1 for adding a compactWarningThreshold key to settings.json though. That would be the cleanest solution by far.

coygeek avatar Aug 27 '25 18:08 coygeek

@coygeek I have tried numerous times to get accurate context window counts in the statusline but haven't been able to do it. Have you had any success?

jrp685 avatar Aug 27 '25 22:08 jrp685

Check out:

https://github.com/sirmalloc/ccstatusline and https://github.com/ryoppippi/ccusage

coygeek avatar Aug 27 '25 22:08 coygeek

@coygeek Thank your for the inputs. I personally built myself a custom status line that makes use of ccusage and a custom script. I also turned off auto-compacting. But I still get warnings as soon as I get close to ~75% context usage that I have ~10% left (so compacting seems to be recommended at 85%).

I would like to turn that off too, since I can see at all times with my approach where I'm currently at.

My status line looks like this with automatic yellow/red coloring at 50%/80% passing: Image

So I manage compacting myself, but the built-in warning breaks my status line visually, which is ugly: Image

tl:dr – Please add an option to turn off the warning entirely!

Jeehut avatar Sep 13 '25 15:09 Jeehut

@coygeek Thank your for the inputs. I personally built myself a custom status line that makes use of ccusage and a custom script. I also turned off auto-compacting. But I still get warnings as soon as I get close to ~75% context usage that I have ~10% left (so compacting seems to be recommended at 85%).

I would like to turn that off too, since I can see at all times with my approach where I'm currently at.

My status line looks like this with automatic yellow/red coloring at 50%/80% passing: Image

So I manage compacting myself, but the built-in warning breaks my status line visually, which is ugly: Image

tl:dr – Please add an option to turn off the warning entirely!

care to share how you made that statusline? what api does it use under the hood to get the remaining context?

vinc3m1 avatar Sep 29 '25 11:09 vinc3m1

@vinc3m1 I open-sourced my custom status line in my ContextKit CC framework/plugin, find the full implementation here: https://github.com/FlineDev/ContextKit/blob/main/Templates/Scripts/CustomStatusline.sh

Jeehut avatar Oct 27 '25 16:10 Jeehut

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 08 '25 10:12 github-actions[bot]

Following up, as my issue was auto-closed as a duplicate, but this reference issue was also closed. This would be a great feature as part of the Claude Code (no plugins / hooks required)!

jonobr1 avatar Dec 08 '25 18:12 jonobr1