Akash001uts/claude-mods/tree/main/plugins/context-handoff
context-handoff
工作階段變長時平順交接:達到 context 閾值後 Claude 更新文件並寫入交接記錄,工作階段帶著指令壓縮,再由啟動提示接續。提供即時 context 讀數與 /wrap-up 外掛
關於這個 mod
context-handoff
工作階段變長後,Claude 往往更難掌握進度,自動壓縮也不一定保留真正需要的部分。這個 mod 會妥善交接工作。它適合無法在一個 context 視窗內完成的長時間工作,例如完整作業、持續幾天的專案或大型重構。沒有它時,我每次壓縮前都得手寫「目前做到這裡」的筆記。
運作方式
當 context 視窗達到閾值(預設 50%)時:
- Claude 會被要求收尾。它會更新專案已有的文件,寫入交接檔案(
.claude/handoff.md),並擬好壓縮指令與啟動提示。 - mod 會用這些指令執行
/compact,讓摘要保留重要內容。 - 壓縮完成後,它會送出啟動提示,Claude 會從交接檔案接續工作。
它也能讓 Claude 看到 context 有多滿。每個提示都會收到一行隱藏資訊,例如
Context window: 34% used (68.0k of 200.0k),並告訴 Claude 在視窗逐漸填滿時建議收尾(只建議一次,而且只在任務確實完成時)。如果你在工作階段結束時自行執行 /context-handoff:wrap-up,下次在該專案開啟工作階段時,啟動提示就會等在提示框裡。
指令與設定
- 狀態列會顯示
Handoff at 50%,表示它已啟用;交接進行時也會顯示目前步驟。 /handoff會立即開始交接,不論目前 context 用量。/handoff 60(或/handoff at 60%)會改變自動交接開始的時機。5% 到 95% 之間的任何值都可以,並會儲存到外掛設定,在不同工作階段間保留。/handoff off與/handoff on會暫停或恢復目前工作階段的自動交接。/handoff status會顯示目前讀數與設定,/handoff resume會把儲存的啟動提示放回提示框。- 在
/config中可以修改mode:auto(預設)會自行完成全部工作,ask會把交接提示放進提示框供你送出,off只把讀數顯示給 Claude。handoffPath會改變交接檔案的位置。 - 它只會從主要對話交接,而且只在一輪正常結束後交接。如果你中斷一輪,它會取消;Claude Code 自己的自動壓縮也不會觸發啟動提示。
執行與儲存的內容
- 它會從 Claude Code 讀取工作階段的 context 用量(已使用百分比、已使用權杖、視窗大小)。它不會把任何內容送到 Claude Code 之外。
- 它送出的提示。 交接開始時,它會送出收尾提示。這個提示只包含目前 context 百分比與視窗大小、交接檔案路徑、上述步驟,沒有其他內容。壓縮後,它會送出 Claude 寫出的啟動提示。在
ask模式中,它只會填入提示框,由你決定是否送出。工作階段開始時,它也可以把儲存的啟動提示放進提示框(不會送出)。 - 它對提示所做的變更。 你送出的每個提示都會多一行隱藏的 context 讀數,例如
[context-handoff] Context window: 34% used (68.0k of 200.0k); handoff at 50%.你的文字不會改變。 - 它加入系統提示的內容。 一段簡短指南,說明那行資訊的含義、在任務自然結束時建議收尾一次,以及交接檔案的位置。
- 它執行的指令。 每次交接只執行一次
/compact,而且是在 Claude 呼叫handoff_ready且這一輪結束之後。它會把 Claude 的壓縮指令當作參數傳入。 - 它自己的工具。 它加入一個
handoff_ready工具,Claude 會在收尾結束時呼叫它。mod 會自行回應這個呼叫:儲存啟動提示與壓縮指令(或在工作階段結束時儲存下次使用的啟動提示),然後回覆 Claude。它不會碰其他工具。你的正常權限規則仍然適用,因此第一次可能會看到提示;若不想被詢問,可以把mcp__context-handoff__handoff_ready加入允許規則。 - 它修改的設定。
/handoff 60會將閾值儲存為這個外掛的threshold設定(與/config中相同)。它不會修改其他內容,也不會接觸環境變數。 - 收尾期間由 Claude(不是 mod)編輯專案已有的文件並寫入交接檔案,使用它平常的工具,因此一般的權限提示仍會生效。
- 啟動提示會儲存在 Claude Code 的外掛儲存中,並以專案為索引,所以可以在下次工作階段提供。使用後會刪除。
安裝
請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。
claude plugin marketplace add Akash001uts/claude-mods claude plugin install context-handoff
原文 / README
context-handoff
Once a session gets long, Claude tends to get worse at keeping track of things, and auto-compact doesn't always keep the parts you actually need. This mod hands the work off properly instead. It's for longer pieces of work that don't fit in one context window, like a full assignment, a project spread over a few days, or a big refactor. Without it I was writing "here's where we're up to" notes by hand before every compact.
How it works
When the context window hits a threshold (50% by default):
- Claude gets asked to wrap up. It updates the docs your project already has, writes a handoff file
(
.claude/handoff.md), and drafts compaction instructions plus a kickoff prompt. - The mod runs
/compactwith those instructions, so the summary keeps what matters. - Once compaction finishes, it sends the kickoff prompt and Claude picks up from the handoff file.
It also lets Claude see how full the context is. Each prompt gets a hidden line like
Context window: 34% used (68.0k of 200.0k), and Claude's told to suggest wrapping up (once, and only when a task is
actually finished) if the window is filling up. If you run /context-handoff:wrap-up yourself at the end of a session,
the kickoff prompt will be waiting in the prompt box next time you open a session in that project.
Commands and settings
- The status line shows
Handoff at 50%so you know it's armed, and shows what step it's on while a handoff runs. /handoffstarts a handoff straight away, whatever the context level./handoff 60(or/handoff at 60%) changes when the automatic handoff starts. Anything from 5% to 95% works, and it saves to the plugin's settings so it sticks between sessions./handoff offand/handoff onpause or resume the automatic handoff for the current session./handoff statusshows the current reading and settings, and/handoff resumeputs a saved kickoff prompt back in the box.- In
/configyou can changemode:auto(the default) does everything itself,askputs the handoff prompt in the box for you to send, andoffjust shows Claude the reading.handoffPathchanges where the handoff file goes. - It only hands off from the main conversation, and only after a turn finishes normally. If you interrupt a turn it cancels, and Claude Code's own auto-compact never triggers the kickoff prompt.
What it runs and stores
- It reads the session's context usage from Claude Code (percentage used, tokens used, window size). It doesn't send anything outside Claude Code.
- Prompts it submits. When a handoff starts, it submits the wrap-up prompt. That prompt contains the current context
percentage and window size, the handoff file path, and the steps above, nothing else. After compaction it submits
the kickoff prompt Claude wrote. In
askmode it only fills the prompt box and you decide whether to send. At the start of a session it can also put a saved kickoff prompt in the prompt box (it doesn't send it). - What it changes in prompts. Each prompt you send gets one extra hidden line with the context reading, like
[context-handoff] Context window: 34% used (68.0k of 200.0k); handoff at 50%.Your own text isn't changed. - What it adds to the system prompt. A short guide telling Claude what that line means, to suggest wrapping up once at the natural end of a task, and where the handoff file goes.
- Commands it runs. Only
/compact, once per handoff, after Claude has calledhandoff_readyand the turn has finished. It passes Claude's compaction instructions as the argument. - Its own tool. It adds one tool,
handoff_ready, which Claude calls at the end of a wrap-up. The mod answers that call itself: it saves the kickoff prompt and compaction instructions (or, at the end of a session, saves the kickoff prompt for next time) and replies to Claude. It doesn't touch any other tool. Your normal permission rules apply to it, so you may get a prompt the first time; addmcp__context-handoff__handoff_readyto your allow rules if you don't want to be asked. - Settings it changes.
/handoff 60saves the threshold as this plugin'sthresholdsetting (the same one in/config). It doesn't set anything else or touch environment variables. - Claude (not the mod) edits your project's existing docs and writes the handoff file during a wrap-up, using its normal tools, so your usual permission prompts still apply.
- The kickoff prompt is saved in Claude Code's plugin storage, keyed to the project, so it can be offered next session. It's deleted once it's used.
Licence
MIT
其他同名作品
- context-handoffWanyaldee · ★ 1
- context-handoffVibe-Commit · ★ 0
