Akash001uts/claude-mods/tree/main/plugins/context-handoff
context-handoff
長いセッションをきれいに引き継ぎます。コンテキストのしきい値で Claude がドキュメントを更新して引き継ぎを書き、指示付きでセッションを圧縮し、キックオフプロンプトで続行します。ライブのコンテキスト表示と /wrap-up スキルを提供します
この mod について
context-handoff
セッションが長くなると、Claude は進捗を追いにくくなり、自動コンパクトでも本当に必要な部分が残るとは限りません。この mod は作業を適切に引き継ぎます。1 つのコンテキストウィンドウに収まらない長い作業、たとえば課題全体、数日にわたるプロジェクト、大規模なリファクタリングに向いています。これがなければ、私はコンパクトの前に毎回「ここまで進んだ」というメモを手書きしていました。
仕組み
コンテキストウィンドウがしきい値(デフォルト 50%)に達すると:
- Claude に作業をまとめるよう求めます。プロジェクトに既にあるドキュメントを更新し、引き継ぎファイル(
.claude/handoff.md)を書き、コンパクションの指示とキックオフプロンプトを下書きします。 - mod がその指示で
/compactを実行し、重要な内容を要約に残します。 - コンパクションが終わるとキックオフプロンプトを送り、Claude は引き継ぎファイルから作業を再開します。
Claude がコンテキストの埋まり具合も確認できるようになります。各プロンプトには、たとえば
Context window: 34% used (68.0k of 200.0k) のような隠し行が入り、ウィンドウが埋まりつつあるときは自然な区切りでのまとめを提案するよう Claude に伝えます(提案は 1 回だけで、タスクが実際に完了したときに限ります)。セッションの最後に自分で /context-handoff:wrap-up を実行すると、次にそのプロジェクトのセッションを開いたときにキックオフプロンプトが入力欄で待機します。
コマンドと設定
- ステータスラインに
Handoff at 50%と表示され、準備ができていることが分かります。引き継ぎ中は現在のステップも表示されます。 /handoffはコンテキスト量にかかわらず、すぐに引き継ぎを開始します。/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 からセッションのコンテキスト使用量(使用率、使用 token、ウィンドウサイズ)を読み取ります。Claude Code の外部には何も送信しません。
- 送信するプロンプト。 引き継ぎが始まると、まとめ用プロンプトを送信します。現在のコンテキスト率とウィンドウサイズ、引き継ぎファイルのパス、上記の手順だけを含みます。コンパクション後は Claude が書いたキックオフプロンプトを送信します。
askモードでは入力欄に入れるだけで、送信するかどうかはあなたが決めます。セッション開始時には、保存されたキックオフプロンプトを入力欄に置くこともできます(送信はしません)。 - プロンプトへの変更。 送信する各プロンプトに、たとえば
[context-handoff] Context window: 34% used (68.0k of 200.0k); handoff at 50%.のようなコンテキスト表示の隠し行を 1 行追加します。自分のテキストは変更しません。 - システムプロンプトへの追加。 その行の意味、タスクを自然に終えたときに一度だけまとめを提案すること、引き継ぎファイルの場所を説明する短いガイドを加えます。
- 実行するコマンド。 引き継ぎごとに
/compactだけを 1 回実行します。Claude がhandoff_readyを呼び、ターンが終了した後に行われます。Claude のコンパクション指示を引数として渡します。 - 独自のツール。
handoff_readyというツールを 1 つ追加します。まとめの最後に Claude が呼び出し、mod がその呼び出しに応答します。キックオフプロンプトとコンパクション指示を保存し(セッションの最後なら次回用のキックオフプロンプトを保存し)、Claude に返します。他のツールには触れません。通常の権限ルールが適用されるため、初回に確認が出ることがあります。確認を省きたい場合はmcp__context-handoff__handoff_readyを許可ルールに追加します。 - 変更する設定。
/handoff 60はこのプラグインのthreshold設定(/configの同じ設定)にしきい値を保存します。他の設定や環境変数は変更しません。 - まとめの間、プロジェクトの既存ドキュメントを編集して引き継ぎファイルを書くのは mod ではなく Claude です。通常のツールを使うため、通常の権限確認も適用されます。
- キックオフプロンプトは 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-handoffVibe-Commit · ★ 0
