cjavdev/mods/tree/main/cache-saver

一個適合你暫時離開長工作階段時使用的 Claude Code 外掛。在閒置提示快取即將過期前趁快取仍然溫熱時摘要對話。你回到冷快取時,選單會詢問如何繼續:
cjavdev/mods/tree/main/cache-saver

閒置工作階段的提示快取即將過期時,會趁快取仍然溫熱時摘要工作階段;你回來後可選擇 A(保留完整工作階段,支付快取寫入費用)或 B(從摘要繼續)。
請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。
claude plugin marketplace add cjavdev/mods claude plugin install cache-saver
A Claude Code mod for when you walk away from a long session. Just before the idle prompt cache expires, it summarizes the conversation while the cache is still warm. When you come back to a cold cache, a menu asks how to continue:

Pick with the arrow keys and Enter, or press the option's number.
If you close the menu with Esc, the same choice stays above the prompt:

There, press 1 or 2, or type a or b and press Enter. Anything else you type before choosing is held, shown under the choices, and sent once you pick.
You need Claude Code 2.1.287 or newer.
git clone https://github.com/cjavdev/mods.git ~/mods
claude --plugin-dir ~/mods/cache-saver
Or add ~/mods/cache-saver to CLAUDE_CODE_PLUGIN_DIRS in the env block of ~/.claude/settings.json. It works well alongside cache-shot-clock.
The summary is a $.model.fork of the main thread. It's sent while the cache is warm, so its prefix is a cache read (0.1× base input), plus the summary's output tokens. One fork per idle stretch. Sessions smaller than minTokens are skipped, because re-caching them is cheap anyway.
The fork's cache read also refreshes the cache entry, so the cache stays warm for one more TTL after the summary is built. The choice only appears once it is actually cold. If you come back before then, just keep working: the summary is dropped when the next response arrives.
/compactThe engine skips a plugin's own hooks on any compaction that plugin starts directly. A compaction cache-saver started that way would go to Claude Code's summarizer, which reads the whole cold transcript. That is the cost this mod exists to avoid. So when you pick the summary, cache-saver runs /compact as a queued command, the way you would by typing it. That compaction reaches cache-saver's session.compact hook, which answers with the prepared summary, and Claude Code's summarizer never runs.
A /compact that you type yourself, or one with instructions (/compact focus on X), still goes to Claude Code as usual.
| Option | Default | |
| --- | --- | --- |
| enabled | true | Turns the mod off without unloading it. |
| ttl | auto | auto reads the TTL from the transcript; 5m or 1h forces it. |
| leadSeconds | 45 | How long before the idle cache expires to build the summary. |
| minTokens | 30000 | Sessions smaller than this get no summary. |
| testTtlSeconds | 0 | For testing: treat the cache as expiring after this many seconds. 0 is off. |
With a 1-hour cache, the choice shows up two hours after you go idle. testTtlSeconds runs the whole cycle on a short clock instead. The real cache stays warm, so the summary is still cheap:
claude --settings '{"pluginConfigs":{"cache-saver":{"options":{"testTtlSeconds":40,"leadSeconds":20}},"cache-shot-clock":{"options":{"testTtlSeconds":40}}}}'
Send one prompt and wait. The summary is built about 20 seconds after the reply, and the choice appears about 45 seconds after that. The session needs at least minTokens of context, which a fresh session with a few connectors already has.
claude plugin validate ~/mods/cache-saver
claude plugin test ~/mods/cache-saver
The tests drive a whole idle stretch on a mocked clock. They cover the summary built 45 seconds before expiry, a single fork per stretch, the choice appearing only once the cache is cold, a typed prompt held and then sent, the choice typed as a or b, /compact answered with the summary without the engine's summarizer, and the short test TTL.