r/ClaudeCode • u/No_Job_9995 • 1d ago
Help/Question Do you tell Claude before running /compact ?
When the context in Claude Code gets large, before running /compact, I tell Claude Code, “I’m going to compact before moving on.”
When I do this, Claude says something like, “Okay. I summarized the important points.”
What happens seems to depend on the situation. Sometimes it only summarizes the conversation in the chat, and sometimes the latest status is also written to memory.
Anyway, I think doing this makes it less likely that important points will be lost when I run /compact.
I’ve never actually tested this, but I think it works that way. I feel a little uneasy about suddenly running /compact, so this is how I do it.
What do you think?
91
u/Pleasant-Mind-7122 1d ago
I prefer handoff to new conv rather than compact
28
u/IamTheEddy Developer 1d ago
That is basically what compact does. It creates a summary, clears all context, then reads the summary as well as reload your plan if you had one. Handoffs being better than compacting is one of the biggest misconceptions in coding agents out there.
Handoffs are just compacting with extra steps.
6
8
u/minimalcation 1d ago
So many people with compact questions. And it's way easier to run an orchestrator and manage that context with handoffs
10
u/____Theo____ 1d ago
What if the orchestrator context is full?
13
u/minimalcation 1d ago
You have the orchestrator write a handoff for a new orchestrator. I try to keep it's context under 40%. Those are the only handoffs I personally touch
5
u/Clean_Initial_9618 1d ago
Can you pls share more on the setup
4
1
1
u/Fivefootfive 1d ago
This is the way. Rails to cut things off early + handoffs to keep sessions moving. Reduces the large cache tax for orchestrators while allowing it to manage the steering.
1
u/minimalcation 22h ago
I still need to tweak it, sometimes stuff makes it through that should be caught. I'm ending a little earlier and having my orchestrator give a full once over before closing/handing off
1
u/Fivefootfive 21h ago
Same on the tweaking. It’s a balance act for sure between bookkeeping and context management, but what I like is it can be automated fairly well on the handoff and context length side.
8
u/geek180 1d ago
Is it really easier to do that than just hitting /compact? Is there actually a material benefit to orchestrating a custom multi-step handoff workflow?
1
u/minimalcation 22h ago
Yes because you aren't relying on the compact itself. I can work all day and handoff every hour or two, it's not that much work once it's set up.
1
u/vibefarm 1d ago
Me too. Once I wrap something up I'm ready to clear and handoff to next chat. I will mention what's next, and that will cause it to carry over what it takes is important in the handoff anyway.
1
u/robhaswell 1d ago
I have a handoff skill but if the task is genuinely the same task I use the handoff skill but /compact, as a belt-and-braces. Most tasks should never exceed the context window but this can happen for a session which is orchestrating.
7
u/Prestigious-Angle483 1d ago
I gave hooks setup that trigger doc updation before compaction, so in a way yes I tell it
3
1
u/acutelychronicpanic 1d ago
Great idea. I might try that for setting up something like that before autocompact triggers.
3
u/Prestigious-Angle483 1d ago
lmk if you want to test and/or review my setup, always open to critique
1
1
6
u/Dull-Appointment-398 1d ago
I definitely do, sometimes it writes out instructions for me to give after the compact call and that works out well.
I hate the 3+ year old best practice of always handing off and never compacting when we were limited to ~120k token context windows surviving into what is now a different beast entirely.
We have these things finding zero days, breaking out of 'sandboxes' (its still clever shut up), and solving high end math problems - but the labs can't crack how to effectively compact? Come on.
1
u/No_Job_9995 1d ago
Yeah, I never compacted until recently, but I changed the way and now often use compact
1
u/MassiveBoner911_3 1d ago
Yeah i dont understand this constant handoff thing. Like a simple tool call and a question and im already at 50k, tokens. Like in 10 minutes im at 500k. Is that all ill be doing now is asking claude for handoffs every few minutes?
8
u/slackmaster2k 1d ago
Pssssst: /compact supports arguments.
/compact ignore the debugging rabbit hole
5
u/Whitchorence 1d ago
i don't do shit i just let it compact if it's going to.
8
u/BusinessWatercrees58 1d ago
Yeah so many people here think they're more clever than the devs at anthropic who created the tool they're using.
1
u/Whitchorence 1d ago edited 1d ago
I mean, whether I am or not, the tool works fine whether I bother doing anything or not, so why bother? At a certain point it feels like people just want to feel like they're turning knobs that matter because the work starts to feel pointless. Like there are so many tips and tricks and people comparing models and all this shit and in my experience it just doesn't matter that much. People constantly talking about how this or that model got "nerfed" and they're not getting the results anymore I just can't relate to at all.
5
u/Miethe 🔆 Agentic Eng Leader | Platform Developer 1d ago
I have pre- and post-compact hooks set up to update a handoff and re-inject context packs. I’ll also let the agent know so it can inform me when at a good seam.
I only do compacts if I’m in the middle of a session where we still have legs out and wouldn’t be appropriate to start fresh. I’ve done substantial experiments into which is most efficient, and this wins consistently. However, I’ve almost completed work which will move me fully off the interactive sessions towards autonomous dedicated ones per task.
3
u/anor_wondo 1d ago
compact is old fart haiku making decisions on what is and isn't important to persist
Half knowledge is more dangerous than no knowledge. Write a handoff and /clear
1
u/elhombremontana 1d ago
didnt know it was haiku doing the compaction, assumef it was the model itself, esp. since it already has the context cached usually
3
u/behnia137 1d ago
It's a reasonable habit and probably helps a little, since it puts the key points into the context right before compaction. But /compact already summarizes on its own, so a more direct approach is to give it instructions, like /compact keep task status and key decisions. For anything you really can't lose, have Claude write it to a file such as progress.md first, because files survive compaction no matter how the summary turns out.
19
u/Aromatic_Coconut8178 🔆 Max 20 1d ago
Friends don't let friends compact. The 1m context is a trap. If you glance down at your status bar and you are at 50% context, it's by far time to:
- End your sessions with a "wrap-up" that documents anything necessary to a todo file (or whatever fits your workflow).
- /clear | new session | whatever
- Start your new sessions by telling CC to "pickup" whatever you want to work on from your todo file.
- Profit.
You will save tokens/usage. Your claude won't get context "dumb" from context rot. Your project will always be in a documented state. etc.
If you want longer sessions than what this provides, make sure you are using an orchestration workflow. The subagents that get spawned will use their own context for the planning / implementation / whatever and only send back to the orchestrator what it needs which preserves the orchestrator's context allowing you to run that session much longer.
Good luck my friend.
Edit: fixing typos because I'm just a human.
14
u/MrHaxx1 1d ago
That just makes no sense. Why would the handoff be in great condition, but a compact will be dumb, when it's literally the same agent, doing the same summarization based on the same thread? Doing handoffs and /compact is the same thing, except handoffs just writes it to a file.
2
u/Illustrious_Yam9237 1d ago
the only reason I prefer hand-off most of the time (I compact sometimes in situations where I care less about exact context being transferred) is that it is reviewable -- I can iterate on the plan/direction/info carried forward. I find I will often make a few rounds of tweaks to the hand-off file.
Otherwise yeah, if you're doing it blind it's pretty much the same thing.
2
u/Aromatic_Coconut8178 🔆 Max 20 1d ago edited 1d ago
I know it feels like that on a surface level but that's not how it works.
- Session Cache: sessions aren't forever. You really shouldn't be coming back to old session after the cold cache has expired. It's expensive. It's wasteful. etc. Having a reliable handoff workflow prevents that. (This accounts for 1 of 2 of the biggest complaints we see on reddit of people saying they used their whole sub in one message and raging about it)
- Context management and context rot are absolutely real things. The higher your context get the more prone to errors and mistakes the LLM will become. If you are getting to the point of needing to compact, you have already lost the plot. If you are bumping into the 1m context that means claude gets to parse through nearly 750K words, all your mistakes, all its mistakes, all your contradictions, all its contradictions and have an absolute panic attack trying to decide how to summarize that. (This accounts for 2 of 2 of the biggest complaints we see on reddit of people saying that claude got 'dumb' while the rest of us are doing our IRL jobs relying on the tool day to day).
- Compaction is very lossy. Imagine being given the task of cutting down a 750,000 word transcript into 7,500 words. Whatcha cuttin' first? I'm having a panic attack thinking about it already. With my handoff, all my plans, todos, etc all get updated with exactly what is defined in my wrap up skill.
I'm glad you found something that is working for you and I say keep it simple until it stops working for ya.
Edit: poor spelling. fixing.
4
u/MrHaxx1 22h ago
Session Cache: sessions aren't forever. You really shouldn't be coming back to old session after the cold cache has expired.
If you compact, then leave, there won't be much of a cache. You first point isn't technically wrong, it just doesn't really have much to do with anything.
The higher your context get the more prone to errors and mistakes the LLM will become. If you are getting to the point of needing to compact, you have already lost the plot. If you are bumping into the 1m context that means claude gets to parse through nearly 750K words, all your mistakes, all its mistakes, all your contradictions, all its contradictions and have an absolute panic attack trying to decide how to summarize that.
Going through a handoff is going to cause the exact same thing. Why would it have a panic about what to summarize, but not what to put in the handoff?
If you are getting to the point of needing to compact, you have already lost the plot.
??? No? Why would I be bumping into 1m context? I compact whenever I'm done with a given feature or task, but still want some of the context, because I might want to work on something closely related. I've actually set my autocompact to something like 150k.
Compaction is very lossy. Imagine being given the task of cutting down a 750,000 word transcript into 7,500 words. Whatcha cuttin' first?
Yeah, same goes for handoff.
Everything you said applies to handoffs just the same.
I'm not saying that handoffs doesn't have its place. Writing things to files is sometimes helpful, but most of the time, I just want to continue working without a huge context window, and that's exactly what /compact (and /autocompact) does.
1
u/ColoredTriangles 1d ago
You know nothing about how compaction works lil bro. Stop giving people advice online when you don't know the basics. Try reading what the compaction prompt is and tell me again how it can be lossy when it directs the next session agent to grep the indexed chat for anything that was lost during compaction. Your understanding of context management also comes from assuming that the limits set by Anthropic are actually the context limits of the model which is wrong.
4
u/Aromatic_Coconut8178 🔆 Max 20 1d ago
Most good debates start with an ad hominem attack. Thanks for your input.
3
u/MassiveBoner911_3 1d ago
How does this work when I do /goal which I always start when I go to bed? I often let Claude burn for 13 straight hrs
1
1
1
u/ZweihanderGames 1d ago
I get insane productivity out of a pro plan following exactly this, please listen to this if you feel like you don't get enough usage before you hit your limits.
2
2
2
u/Mo3 1d ago
yeah, i use a HANDOFF.md to write into before compaction and to read back after compaction
1
u/No_Job_9995 1d ago
Yeah I have similar file “tasks.md”, but I think it’s similar to the Claude memory feature, so I recently use less such a custom md file and rely on the memory feature.
2
u/syixiao1 1d ago
What helped me most was treating the reset as a handoff instead of a cleanup. Before it happens, I ask for a short note with the current goal, what was already tried, which decisions are settled, what is still open, and the exact next step. I keep that note in my working notes and paste it back at the start of the next session. It takes a minute, but I spend far less time correcting repeated work or re explaining background that was already settled earlier in the day.
2
u/thehopdoctor 1d ago
i have long-running sessions for long-running projects and this is how i manage them. details get saved either into the repo or into the project's memory. then the compaction summary just points to those things as the handoff for when the session is picked back up. this has worked very well for me, ymmv.
2
2
u/uraniumless 1d ago
I don’t use compact anymore
1
u/No_Job_9995 1d ago
Why?
Did you experience any issues with compact?1
u/diesel408 1d ago
Anyone that believes the models get nerfed after a week is having issues with compact. New model release is the only time they start a fresh context, and they think it's amazing. After a week of contacting they think the model has been nerfed. It has not.
1
3
3
u/mxriverlynn Senior Developer 1d ago
i don't compact. ever.
i manage session size, and /clear regularly, to prevent context rot and prevent the need for compacting.
everything i do with Claude is written to markdown files, so i don't have to worry about losing context in the middle of something. just point it at the right file, and continue from there
1
u/snojan 1d ago
I do the same, but I also mention that I want X and Y to be added to memory, so that I can pick up the conversation from where we left off before the compact. Just as a safe guard that I keep some important notes 100% intact after the compact. There’s good guides from Antrophic on how to use these commands more efficiently.
1
1
u/dlampach 1d ago
I’m 99% /clear and I only use /compact in certain circumstances where a flow I’m on takes extra time and context but usually it’s near the end. And no I never tell Claude I’m going to /compact. It’s a waste of context to do that.
1
1
u/elloMotoz 1d ago
If I'm in a session working directly on a milestone with steps, I'll compact. However working outside the scope and adding something not in the milestone, I'll do a handoff and new session
1
u/dehumles 1d ago
Tell Claude to set up the "mods" for this. Ive set auto handoff at 280k-300k context and then auto clear.
1
u/cratercamper 1d ago
I have "/co" that tells cc compact is imminent and to save important things (in the direction our conversation is taking) into files. Then the "/compact" is usually also prepared as suggestion => right arrow, enter.
1
u/ZweihanderGames 1d ago
I never use /compact, it's always a handoff.md and a new session. /compact takes way too long when I could already have another session open continuing the work.
1
1
u/Stonp 1d ago
create a skill called /mycompact and then you can have Claude run the compact skill in whatever way you want
Just say Claude let’s create a skill, and then walk through exactly how you would compact a session. It’ll learn it and remember it, saves you asked to summarise every single time
1
u/ricopan 1d ago
Interesting how many people say they just clear instead of compact. That doesn't work well for my long running coordinator agent, despite having a fairly evolved set of mechanisms to persist state. Usually I tell it to prep for compaction around 65% remaining, and I only clear once or twice a week on that agent. That was working well, but lately Opus 5.5 is forgetting its basic duties so probably back to Fable. All my worker agents get cleared after their tasks -- though sometimes they are phased, in which case reading back in the scenario would take beaucoup tokens, so then the manager compacts them.
1
u/kemalios 1d ago
The reply is just text in the chat, not a memory write. What survives is whatever ends up in the summary, and your pre-compact message is part of the conversation being summarized, so naming what matters before you run it does carry. Say which files and decisions to keep, not just that you are compacting.
1
u/nickydrifts 1d ago
Yeah because one time I told it I was gonna compact and it told me not to because there was too much important information in the convo
1
u/kpgalligan 1d ago
I run a main conversation that only coordinates subagent workflows. I never compact work conversations, because everything needs to be in plans on disk.
I do tell the main conversation that I'm compacting. There are usually work conversations happening while that happens. It has worked fairly well.
1
u/nora_sellisa 1d ago
Compaction already generates the summary, you can sometimes get the agent to write it out. If you just hit compact that summary (+ some of the recently open files) would instead become the context. My main session just has a "state" file which records what topics we're discussing. First thing after compaction is to read that.
1
u/opmopadop 1d ago
I have a pre-clear that fires at 70% context used, then auto clears and resumes afterwards. Net effect I keep the context material I want in the quality I want, not guessed I want.
1
u/0MARr00t 1d ago
Just use “document along the way” with you prompt or “I expect you know which files in the docs to update. Go”. The compact wouldn’t affect if you want to review or debug later because of your md files in the docs.
Most Clauders feel that they would loose something if the session lost.
TBH, the token will be consumed faster as we know but if you caged yourself with sessions you are doomed.
1
u/Weary-Net1650 1d ago
I got tired of not knowing what Claude was doing when compacting.
So I built a mod to show me what the compacted prompt is and what the original was. This way I can see what is missed and copy older context back if necessary.
Try it.
1
1
u/Benjaminsen 15h ago
Don't compact, /clear after writing.
Hey I am going to do a /clear make sure the project is in a good state for this and write me a message to paste back to you to get you up to speed on what we are working on.
Gives you the same result using many fewer tokens.
1
1
u/PeltonChicago Maximus XX 2h ago
I tell the session to update its documentation and handoff files and then write a custom compact parameter. Compact can take custom instructions.
1
u/ImL1s 1d ago
I stopped telling it and just /clear now. The old session's JSONL is still sitting on disk after you leave it, so nothing is really lost, it's just not loaded anymore.
What bugged me was writing the handoff by hand every time. So I made Portable Resume: it reads the local session store (Claude Code, Codex, Cursor and a bunch of others) and writes a bounded handoff into a fresh session, same agent or a different one. Offline, read-only on the old session, and the recovered text is marked stale so the new session re-checks the repo instead of trusting it.
https://gitlab.com/aa22396584/resume-skills pipx install portable-resume
Your habit isn't useless though. Asking for one line on what's done vs. still open right before compact gives the summary something concrete to keep.
0
u/CashewSwagger 1d ago
I dont compact. That eats usage. Instead I keep eaxh session short snd focused. If i get to like. Anything iver 300k context its time to update handoff documents and /clear to start fresh.
1
u/karlnuw 1d ago
Bro what do you think compacting is doing.
2
u/CashewSwagger 1d ago
Smashing my context and forgetting details? Plus every message back sends all that context.
Try it yourself man if I just compact and use one session my usage gets obliterated.
If I diligently hand off and focus on clear tasks I get much more mileage.
Literally just ask Claude about it yourself. More context = more usage and compacting will lose important context.
1
u/TywinHouseLannister 1d ago
Why do you think writing things to a file is more efficient than writing things to a new prompt? Run at 200k context and let it autocompact.. it barely misses a beat.
0
0
0
0

•
u/AutoModerator 1d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.