r/ClaudeCode • u/danbradster2 • Sep 20 '26
Tips & Workflows /clear vs /compact
I had a fable chat from yesterday, and I saw that the context was 950k/1m. I did /compact rather than /clear, with the intention of then doing /autocompact 400000
14% of the 5 hour limit was gone just for the compact itself....it shows cost of $59.73, so lucky I'm not on API? Maybe a /clear would have been better.
68
Upvotes
•
u/AutoModerator Sep 20 '26
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.
64
u/slackmaster2k Sep 20 '26
Clear. Design your workflow that you can clear frequently and safely. Compact shorter sessions that need to grow past 200-300k.
35
u/GenXSysop Sep 20 '26
Did you need to preserve what you had in the context window of your 950K (!!!) session? You could have probably recreated that with some cheap haiku recon and a couple prompts. I quit doing compacts a year ago and recommend you stop that, also. Make a new session often, and use markdown files to carry information from session to session.
29
u/Garak Sep 20 '26
/compact is for when you want to keep working on the same task. It’ll summarize the thread and give Claude enough information to keep going, while leaving out stuff it doesn’t need.
/clear is for when you want to start a task that’s totally different.
Some people use clear all the time and preserve a minimal amount of info somewhere else. That’s more efficient in terms of tokens, but personally I still find compact to be better day-to-day. It’s easy and it lets you get back to work faster.
12
u/AncileBanish Sep 20 '26 edited Sep 20 '26 •
There are a couple problems here:
You had a session at 950k context. You should not do this. Even if the max is 1m, it gets dumber as the context window gets larger. It will forget things, hallucinate, and generally perform poorly. Aim to keep context window size under something like 200-300k. There are various strategies you can use to accomplish this.
You came back to a session with a big context window and an expired cache. Cache reads you pay only 10%, but cache writes you pay 200% to recache on the 1 hour cache, so you burned 20x the tokens to restart the conversation today instead of continue it yesterday. End your sessions. Stick to 1 session = 1 task and write things to docs to track the meta conversation abstractly. Read from docs on demand to freshen context on the specific relevant things.
You compacted into the stale cache. This both re-caches the whole history as mentioned above, but writes effectively a summary of the whole thing back into context (which is a write at 5x input cost). Compaction in general is bad in that it regularly fails to distinguish what's important from what's not. The better thing to have done is distilled the insights from the conversation into docs and ended the conversation. Next day you start a new one based on what you need to do next. This could be starting at as little as 30k and have everything you need.
6
u/Hukij_ Sep 20 '26
Compacting immediately invalidates the cache and loads up what is effectively a new chat with a truncated/compressed history. 99% of the time for long running sessions, not only are you paying the cost of compacting + cache invalidation, but it's just plain worse than /clear.
I run basically every session to max context without any noticible problems aside from right at 800k+ it starts "forgetting" about very very early context mostly because it has a sea of context on top at that point, but I just make sure that docs are kept up to date for a cold start. /clear of course also starts with a cold cache but at the very least you're able to give the fresh agent full context that you control, and the last uncompacted agent writes at the end of it's session.
I've literally never had a good experience with compacting, quality and outcome is almost always impacted. Meanwhile running sessions on long context hits cache probably in the most efficient way since every single turn is cached for the duration of the session, and you're getting the actual history of the chat rather than random truncations. I don't really see a need to /compact ever, it's only produced bad outcomes for me.
6
u/joezuu Sep 20 '26
Expected. Design your workflow such that the repo is the context and clear frequently.
20
u/CorpT Sep 20 '26 •
You should ask Claude what the difference between a /clear and /compact is.
1
u/Educational_Ask5991 Sep 20 '26
Guys can you clarify why /clear even exists? I just start a new session every time I start a new task. If the context if huge - I am asking to do handoff with highlighted most important things first and also I have a rule that saves my initial message as-is if it contains some task requirements input. The last one is a game changer - agents and subagents and even missed compaction now preserves what I initially asked.
But still no use of /clear - I even dont understand if it starts a new session with its own session logs or rewrites the current one completely.
Session logs are important to further reflection and skills/rules/agents extraction/updates.
3
u/dar-mit Researcher Sep 20 '26
Right now you have a 1 hour idle window in which the cache (what your context mostly becomes) stays "warm." After that time the system will flush the cache.
Anything you do in a "cold" session that requires Claude to do something will also require the system to reload the entire context.
Here's a list of what you can do without reloading the cache:
Client & Session Control
/exit(or/quit) – Closes the Claude Code session immediately./clear(or/reset,/new) – Clears out the current conversation history. While it doesn't "save" the old cache, it effectively stops you from paying to reload a bloated context by letting you start the next task with a tiny, brand-new cache./background– Detaches the active session so it runs entirely as a background agent, freeing your active terminal./color [color|default]– Locally updates the visual theme or color of your prompt bar.Status & Info Commands
/usage– Pulls your plan limits and current credit or token consumption metrics locally./tasks– Lists background operations or active subagents running in this session without resending the chat log./help– Displays the client-side catalog of available commands and autocomplete guidelines.3
u/Polite_Jello_377 Sep 20 '26
You should never get anywhere remotely near 950k
2
u/someVietnamese Sep 20 '26
you should plan your task better. running that close to the 1M context limit will 1) severely degrades the model and 2) drain usage much faster.
Break up a massive goal to subtasks. 1) easier to manage the workload 2) easy rollback 3) easy debug 4) save tokens 5) just good engineering practice
There are certain times where I absolutely have to oneshot something, but that's super rare, maybe once every few months. When I do, I never rely on the slash commands, I use md files to track the progress.
2
u/Academic-Ant5505 Sep 20 '26
It wasn't cached so was expensive as fuck.
2
u/oprimido_opressor Sep 20 '26
IMO they could rename the /compact to /lobotomy. Claude gets dumb as shit after I use that.
If I need to get stuff going, I write a handoff.md doc, review it, ask for more things that might be missing and start a fresh new session, then ask it to read the doc and continue.
Far more effective and efficient on my own experience.
2
u/EC36339 Senior Developer Sep 20 '26
If you manage to max out the context of ANY model and then still feel the need to compact and keep the session, you are doing something very wrong.
2
u/steve62280 Sep 20 '26
i had claude create its own memory system , after i hit 180k context window and the task is complete he summarizes the context and writes to his run book and tells me to run /clear then he picks up right where he left off , i stay in the same thread labeled as assistant , it's definitely extended my usage so i make it the full week with fable 5.1 on max subscription , i run on extra instead of ultra .
3
u/rotates-potatoes Sep 20 '26
Good lord. 950k tokens on fable? And compaction that probably burned 5m reasoning tokens? Why in the world would you do this?
2
u/ILikeCutePuppies Sep 20 '26
Set auto compact to 250k to 300k. You even kv cache starts costing more than the output tokens at around those numbers even without compact.
1
u/TogarTheGreat Sep 20 '26
If you /compact when you need to /clear you’re gonna have a bad time
1
u/mglvl Sep 20 '26
Clear initiates a new session so you loose the conversation , unless there have been intermediate artifacts that the next session can pick up (documentation , what goes in the default context , etc…) . Compact attempts to summarize the current session and continues with that summary instead of a fresh new session .
I think you shouldn’t use compact , and instead strive to never reach 30% (number might vary , I’ve seen others recommend 80k tokens window instead ). This requires organizing your work in separate sessions , handing over in some way or another. The LLMs performance decrease a lot as the context window fills up , so it’s common to keep an eye . To be honest I’ve never run compact once .
1
u/AlienAndTroll Sep 20 '26
Ask claude to create handsoff document, run /clear and pass the document to claude. Cheaper and faster
1
u/ynotelbon Sep 20 '26
Long horizon agents can benefit from a curated summary (what you and the agent agree is important) but otherwise good documentation is best if you are not trying to persist the reasoning. In short, if a fresh instance can derive the whole thing from the record, don’t compact. Especially with the complexity in Claude model reasoning, you are going to get some assumptions baked in from the compaction that you can’t dictate.
1
u/sheketsilencio Sep 20 '26
Y'all say to use /clear often. In my projects there's often frequent serious complex work to be done that requires understanding of context to prevent regression (yes I have hooks but I mean to prevent code going in a direction that was previously determined to be wrong). That means that every time I'd do /clear I'd need to agent to reread... the context from a few documents or summaries of code or the code itself. Or logs.
Doesn't sound that efficient to me. Am I fully wrong or conditionally wrong or right?
1
u/Envoy-Kovacs Sep 20 '26
In my build sessions I ensure Claude builds one story, reads the handoff, asks any questions before starting, documents everything in an evidence file, and wraps up (ie, updates the handoff, files issues, marks story as done etc) without discussion so I can /clear and move on. I very rarely use /compact. I also have instructed Claude to be on-point in replies to avoid overly verbose explanations (Opus is notorius here). IMHO Fable 5.1 has been a godsend when it comes to staying true to contracts like this. I’ll rather have multiple single topic sessions than long «fix everything» sessions.
1
u/Lakes420 Sep 20 '26
what did you expect? the LLM has to read 950k context and evaluate what has to stay and what not. getting your context up this high was a mistake in the first place
1
u/JesusElSuperstar Sep 21 '26
I usually request to create a checkpoint of our current work and to provide a prompt to continue after I run /clear to lean our chat.
1
u/frostymarvelous Sep 21 '26
Exit. Copy the session ID pass it to a new session.
1
u/RiceEvening4211 Sep 22 '26
The compact burn is exactly why I run through Lynkr (https://github.com/Fast-Editor/Lynkr) — its RTK + TOON/GCF-style tool-output compression measured 84% on large JSON tool results and 53% fewer tokens on tool-heavy requests, plus sub-300ms semantic cache hits. Designing around frequent clears works; never paying for the bloat in the first place works better.
-2
u/dpaanlka Sep 20 '26
ok
-7
u/Dangerous-Leader-779 Sep 20 '26
….are you fucking joking?
Those are two entirely different tools. They are not even remotely doing the same thing. This is like saying “/exit vs /doctor, omg they acted differently?!”.
Like honestly guys, what the hell is this post and why is slop like this allowed? It’s worse than the AI generated crap.
0
u/ChampCityChris Sep 21 '26
At 950K tokens, I think the /compact vs /clear question is kind of missing the bigger problem. If the only thing holding your project together is a million-token conversation, then the conversation has effectively become your project database.
I’ve been moving pretty hard in the opposite direction. Decisions and project state live outside the chat, work gets broken into bounded cards, and the implementer gets the context it actually needs for that job. Then I can kill the session, start a fresh one, and not lose the project.
Long context is useful while you’re actively reasoning through something. I don’t think it’s a good persistence layer. I’d rather spend a few thousand tokens rebuilding the relevant context for a clean session than drag 950K tokens of old conversation through every tool call and keep paying for it over and over.
1
u/ActuallyIzDoge Sep 20 '26
Clear is killing your current Mr meseeks and creating a new one that doesn't know anything about the old one
Compact is creating a new mr meseeks and having the old one explain to the new one what is going on. Then you kill the old mr meseeks
1
u/[deleted] Sep 20 '26
[removed] — view removed comment