✳ClaudeModsClaude Code 模组目录
☰
● 0 人在线 · 浏览 0 次
+ 提交作品
← 返回作品集
Reddit 帖子 · 用量与成本 / 记忆与上下文 / 工具与集成 / 工作流与 CI

handoff-compact:自动压缩时自动执行交接与清理

一个 Claude Code mod,在 autocompact 触发时自动生成交接文档并替换上下文,等同于自动完成 handoff + /clear 流程。

sspeciallight@speciallight
已翻译

关于这个 mod

作者运行大量长时间无人值守的 Claude Code 会话,发现一半 token 花在上下文已超 20 万后的轮次,既昂贵又因上下文腐化降低质量。手动方案是请求交接、/clear、再喂回,但启用 200k autocompact 后交接内容不可控。handoff-compact 在 autocompact 触发时介入,会话分支(完整上下文)会写出交接文档,包含目标、状态与证据、下一步、决策与理由、已排除方案、开放问题、文件与提交、验证命令、最近 10 条 prompt 原文,然后用该文档替换对话内容,实现同一会话内、轮次中途、无人值守的 handoff + /clear。该项目为 vibe-coded,MIT 许可,需要 Claude Code 2.1.287+ 且启用 mods;"/compact classic" 可临时使用内置摘要。

安装

请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。

/plugin marketplace add trytofly94/handoff-compact
/plugin install handoff-compact@handoff-compact
原文 / README

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. submitted by /u/speciallight [link] [comments]

查看原始来源 ↗

更多类似作品