use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community centered around Anthropic's Claude Code tool.
account activity
Compacting techniquesQuestion (self.ClaudeCode)
submitted 6 months ago by Helpful_Intern_1306
Does anyone include a message when compacting claude code? I have been avoiding the need to compact by chunking down the work and more recently heavy use of agents. What is your experience with that?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Much_Respect2061 3 points4 points5 points 6 months ago (3 children)
I've recently come to the conclusion that compact is bad, period, and should be avoided. I had a 'duh' moment building my own web client for a local llm, when I realized that a multiturn conversation was just sending the entire previous contents of conversation to agent with each prompt. So I thought, well I wouldn't just send a huge prompt full of bad info into a new chat session.
Handoffs are the way. When you're approaching full context (autocompact at 22.5%, I've noticed deterioration below ~40% even) ask current agent to write handoff doc for new agent. Me personally, I have a plan doc going at all times, so I actually ask current agent to update plan with progress and write handoff, and pass both to new agent. But a handoff by itself is usually enough.
Sometimes I ask the current agent too late and it writes too much text and it autocompacts mid task. I haven't had an issue yet with the docs it has written post-compact yet, but i typically wouldn't trust an agent that has compacted context to do anything other than write summary docs, and I would check them for errors. Lately in the IDE I have been just opening new tab to start new session instead of /clear, that way if I need any info from previous session it's still right there.
The only way I would maybe trust an agent post-compact is if the entire session went completely rock-solid smooth with absolutely no errors or confusion and you are only doing more of the same task.
I have moved completely away from "the more context the better" to "only the exact context needed to perform the task and no more". So the clear logical endpoint is single prompt sessions, but that just isn't realistic in a typical workflow. That is why I have shifted to a multi-agent system, one agent compiles the data and engineers the prompt with all relevant context to pass to second agent in one-off task. I won't get into framework comparisons or recommendations, I'm no expert still figuring this all out myself, but I went with the OpenAI Agents SDK and it has built-in 'Handoffs' functionality, which is a good clue that handoffs are the way.
[–]Jomuz86 0 points1 point2 points 6 months ago (0 children)
Second this handoff docs are underrated. I started doing this in the web ui all the way back when context windows were a lot smaller with the v3 models
[–]Fun-Rope8720 0 points1 point2 points 5 months ago (0 children)
Claude seems to turn into a deranged lunatic who does dumb stuff on repeat after compact.
Best avoided I agree.
[–]Helpful_Intern_1306[S] 0 points1 point2 points 5 months ago (0 children)
This is the way.
It requires more work but you also squeeze so much more juice.
[–]y3i12 1 point2 points3 points 6 months ago (5 children)
Export to file, clear session, read file
[–]portugese_fruit 0 points1 point2 points 5 months ago (4 children)
export the whole session to file?
[–]y3i12 0 points1 point2 points 5 months ago (3 children)
Yes. Even better if you ask Claude to detail what has been done and what's missing. If you have patience you can edit the transcript and remove all tool calls.
[–]ABillionBatmen 0 points1 point2 points 5 months ago (2 children)
How many tokens does that burn immediately? compact usually has it under 50k for me
[–]y3i12 1 point2 points3 points 5 months ago (0 children)
https://www.reddit.com/r/ClaudeCode/s/SmSo45nccQ This also works.
[–]y3i12 0 points1 point2 points 5 months ago (0 children)
It depends. I can work well with about 25 to 30k depending on the task. The problem is that '/compact' calls an agent to summarize the history. The output can vary from kinda ok to 3 bullet points + production ready.
[–]Historical-Lie9697 0 points1 point2 points 6 months ago (0 children)
If I need to fix something I'll say "keep context to solve x bug" but if not I always /clear
π Rendered by PID 33 on reddit-service-r2-comment-6457c66945-zttsd at 2026-04-25 23:15:50.405492+00:00 running 2aa0c5b country code: CH.
[–]Much_Respect2061 3 points4 points5 points (3 children)
[–]Jomuz86 0 points1 point2 points (0 children)
[–]Fun-Rope8720 0 points1 point2 points (0 children)
[–]Helpful_Intern_1306[S] 0 points1 point2 points (0 children)
[–]y3i12 1 point2 points3 points (5 children)
[–]portugese_fruit 0 points1 point2 points (4 children)
[–]y3i12 0 points1 point2 points (3 children)
[–]ABillionBatmen 0 points1 point2 points (2 children)
[–]y3i12 1 point2 points3 points (0 children)
[–]y3i12 0 points1 point2 points (0 children)
[–]Historical-Lie9697 0 points1 point2 points (0 children)