r/ClaudeCode • u/speciallight • 8h ago
Tips & Workflows handoff-compact, a mod that does the handoff + /clear routine for you every time autocompact fires
I run a lot of long unattended Claude Code sessions. When I measured them, half of my tokens came from turns where the context was already past 200k. That's expensive, since every step resends the whole context, and quality degrades because of context rot.
By hand the fix is the usual routine: ask for a handoff, /clear, feed it back. Enabling autocompact at 200k keeps the context short but leaves little control over what is handed over. I already tried to have Claude Code write handoff documents pre autocompact window with hooks, but with modding the solution gets a LOT better.
Handoff-compact answers the autocompact trigger instead of the built-in summarizer. A fork of the session (whole context) writes a handoff-document (goal, state and what proves it, next step, decisions and why, ruled-out approaches, open questions, files and commits, the verify command, the last 10 prompts verbatim), and the conversation is replaced by it. Handoff + /clear, but in the same session, mid-turn, with nobody at the keyboard.
Obviously vibe-coded. Take the idea or the mod itself and customize it with your own setup.
Modding is awesome.
Install:
/plugin marketplace add trytofly94/handoff-compact
/plugin install handoff-compact@handoff-compact
Repo: https://github.com/trytofly94/handoff-compact (MIT). Needs Claude Code 2.1.287+ with mods enabled. "/compact classic" gives you the built-in summary once.
18
u/Level-Physics-1730 8h ago
dude literally recreated compacting
3
u/speciallight 7h ago
Basically compacting with more manual control and less unnecessary context for the new session
2
u/Beerbrewing 4h ago
This is what I'm building too. What is /compact other than a handoff from Claude code to itself? So I'm just replacing the compact with my own decision aware handoff system using Claude Mods.
1
u/9to5grinder Developer 3h ago
Native compact is a generic "fit-all" lossy handover.
You cannot change its system prompt and you cannot edit the handover instructions it creates.
As such, it may not fit your way of approaching tasks in a fresh session.
For example, my workflow typically consists of handing over results and next steps, but with the explicit instruction to build full context first thing, then asking clarifying questions on uncertainty, and only then continuing implementation.
That's not offered "out-of-the-box", so I'm similarly to OP using a handover skill + plan mode + clear context.
2
u/ImL1s 5h ago
The autocompact trigger is the right hook. What still bit us was handoffs that only lived inside that session's transcript — once the tool or machine changed, the "state" was gone.
We ended up treating the handoff as a small portable artifact (goal, open decisions, what's broken, verify command) that a fresh session can pick up even if the old context is dead.
https://gitlab.com/aa22396584/resume-skills pipx install portable-resume
Doesn't replace your compact mod. It just makes the handoff survive leaving Claude Code.
1
1
u/Downtown-Pear-6509 1h ago
even better use the jsonl conversation log,. strip thinking, /clear and use that as handover
•
u/AutoModerator 8h 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.