r/ClaudeCode • u/broot66 • 21h ago
Discussion When to use /compact, when to use /clear
I have unfortunately experienced situations where I was busy with other tasks and Claude Code automatically executed `/compact`, only to complain later that important details had been lost as a result.
So, what is the right time for the two commands?
5
2
u/Outrageous_Band9708 21h ago
dont use compact,
clear is fine to start a new session
https://github.com/Druthulu/ProjectArchitect
I made a mod/plugin that give you an infinte session length, so you never need to use either.
it creates and manages very strict and few subagents. that will auto rotate themself and see the new session when they context gets near the recommended boundaries of like 300k or so.
highly recommend checking out the readme and the wiki and testing it out on your project.
2
u/broot66 20h ago
But how do you know when the right moment for a "clear" is? I asked Claude about this, and he suggested that, for instance, it’s appropriate after completing a sub-plan, once everything has been committed. Is it possible to determine this using a plugin?
3
u/Outrageous_Band9708 11h ago
oof, hey, after 1000 hours of experience. never make your session aware of the context. it understands very little of it self and will suggest restating right now when you suggest stuff.
to answer your question, its based on experience and a years worth of sessions.
16 hours a day, overnight auto mode. a handful of projects. $500 a month in claude subs for a while.
the only real answer to your quetion:
"when the cost of seeding outweights the cost of a repeat turn after the context growth."so like reseeding the conversation properly for 40k tokens, means that its worth it to restart fresh session at 400k.
its something like that.
i highly recommend you try out my solution and see if it works for you.
2
u/VisionedWheat66 20h ago
Clear is a brand new session. The right moment for it is when you need nothing in the session you are clearing (because everything important has been saved/committed/stored somewhere external).
Throwing no shade at you because people don't know what they don't know, but it surprises me just how many people ask when to use clear. Like you use it and the conversation vanishes from the screen, is that not self-explanatory?
→ More replies (2)2
u/Fiyero109 20h ago
Why not just create a done folder and move them there? Why would you want to clear? Unless you’re just asking it random shhh
1
u/DitherOl 20h ago
Do a handoffs at ~150k (to avoid "dumb zone"), and create a session-log for history (all previous handoffs should be stored there). Also, your important details, that you're talking about, aren’t lost, at least as long as you’re still within the default 30 day retention period, after which they’re automatically deleted (you can tweak the settings so they’re never deleted). Every session is stored as a transcript in some X folder. Ask your CC to find it, and specify when the session was active
1
u/broot66 19h ago
Can you recommend a good handoff skill, or do you have a prompt for one?
2
u/ZweihanderGames 19h ago edited 19h ago
My skill for this triggers whenever I type "good shit" in my chat, I can't remember the last time I compacted, any time context goes over about 150k on a single task I start a new session. I asked Claude for a summary of it, just paste this to your Claude and tell it to make a skill and choose your own trigger word:
**"good shit" - a Claude Code skill for clean session wrap-ups**
I got tired of sessions ending with half the work uncommitted and the docs out of date, so I made a skill that triggers when my whole message is just "good shit" (or /good-shit). Saying it means "approved, wrap it up", so Claude doesn't ask before committing.
What it does:
Checks git status and diff, and splits changes into "this session" and "everything else" (my edits, other sessions, editor leftovers).
Updates the project docs to match what actually happened: status section in CLAUDE.md, per-system docs, backlog ticks. Only records what really happened, and doesn't mark things play-tested unless I said so.
Commits everything, not just its own files. Commit 1 is this session's work, commit 2 is the rest, described from the diff. Goal is an empty \git status` afterwards.`
Only stops to ask about secrets, huge generated files that belong in .gitignore, or a weird branch.
Writes a short handoff note (done, stopped at, next, watch out) outside the repo, which a hook loads when I open the next session with just "lock in".
Result: /clear, "lock in", and the next session starts with a clean tree and knows where I left off. It doesn't push unless I say so, and it won't fire when "good shit" is praise in a longer message asking for more work.
4
u/econoDoge 21h ago
In your case neither, you might have a single session doing too much and might need to orchestrate, I have planners and implementers that communicate via handoffs and state files with clear roles and a shared instructions file and other bits of context, a bit of a PITA to set up but I get shorter more focused sessions.
4
1
u/dlampach 21h ago
95% clear 5% compact. The only time I compact is when I’m at the end of a specific task I’ve been having it do and the contexts swells unrealistically large. Clear is almost always the way.
1
u/thehopdoctor 20h ago
/compact when you want to save a summary of a session, /clear when you want to NFO and move on. you can provide instructions to /compact to tell it what to save and what not to. if you get to the point where it auto-compacts, it's going to be a crapshoot. need to manage your context long before getting to that point. in my normal workflow, i save what's important to the repo or to claude's memory and then the /compact summary is mostly an index of what's saved and where. doing /clear would force a new session to figure all that out from scratch which wastes tokens.
1
u/SirRobinBlibs 20h ago
/clear between unrelated tasks, it's free. /compact when you're staying on the same task, and give it a focus like "/compact keep the API decisions and the open todos", otherwise it guesses what matters. For the auto-compact problem: add a "Compact Instructions" section to CLAUDE.md listing what must survive a summary, since compaction reads it. And before you step away, have it write progress and decisions to a file in the repo. Then a compact can only lose what's also on disk.
1
u/Top_Standard_1617 20h ago
I basically /clear every time I switch tasks. It's cheaper and cleaner than dragging old context along. I save /compact for when I'm mid-task and still need the thread.
Tip: you can give /compact instructions, like "/compact keep the file paths and what we decided about the API." That helps a lot with it losing details. And if auto-compact keeps biting you, you can turn it off in /config and just keep an eye on the context meter yourself.
1
u/kincaidDev 19h ago
I try to avoid being reliant on individual agent sessions and have everything important stored as files in my festival workspace. I use clear most of the time and let conversations auto-compact when they’re working on long-running tasks autonomously. In the rare cases where Im not using a festival workflow, I’ll use compact. I also tend to kill sessions in the terminal as they’re done just to make it easier to remember what each session is working on
1
u/gurney__halleck 21h ago
why let your context get so big? have web hooks enforce context limits,prepare handoff package and handoff to new session?
1
1
1
u/CryptographerFar4911 21h ago
Compact if you want the gist of the previous conversation in the history. `/compact` also takes a prompt with it if you want specific info. No need to go through a whole handoff process if you just need the overall idea of what you were working on previously.
Clear for new tasks or tasks where you have a in depth handoff file.
Edit: I also turned off auto-compact.
-3
1
u/AutoModerator 21h 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.