0xGondarxyz/claude-code-mods/tree/main/save-game
save-game
一个 Claude Code 模组,会在闲置、深夜、/save 和会话结束时写入一张 3 行存档卡(doing、next step、open question),下次在该 repo 中显示在提示上方,并提供 Continue 按钮。
关于这个 mod
save-game 是一个 Claude Code 模组,让停止工作不再费心。停止时,它会写下一张 3 行存档卡:Doing(你和 Claude 正在处理的内容)、Next(下一步)、Open(待解决的问题或阻碍,或 none)。卡片按 repo 存放(以 session 资料夹的 git toplevel 为准),每个 repo 保留最新 5 张;同一 session 的新卡片会取代旧卡片。
卡片产生时机:(1) 闲置:主线程回合结束后 4 分钟;(2) 午夜 01:00 之后:如果最近 30 分钟有回合,每晚一次并用 toast 提醒;(3) 执行 /save 立即产生;(4) 工作阶段结束:如果有未存档的回合则不调用模型,改将 session 排入队列,下次任何 repo 开启 session 时在后台用 Sonnet 从 transcript 尾端产生卡片。1 到 3 的卡片使用 live session 的 fork 并重用 prompt cache,因此成本低,但必须在 cache 暖机时(最短 5 分钟)才能运作。
命令:/save 立即产生卡片并附上 resume 命令;/save list 列出此 repo 最近 5 张卡片。工作阶段开始时,如果此 repo 有 14 天内的卡片,提示列上方会显示 band,包含 Doing/Next/Open 与 Continue、Dismiss 按钮;Continue 会以“Continue where I stopped. Save card:”加上三行内容作为第一个提示送出。
在 claude -p 与 SDK 的 headless 执行中,模组不会有任何动作。模组没有选项设置。限制包括:模组重新加载时状态会重置、队列在 session 开始时读取并清除、transcript 路径由 session 资料夹与 id 推导、只读取 transcript 最后 3 MB 并截到最后 30,000 个字符、需要机器上有 tail。授权为 MIT。
注意:模组没有沙箱隔离,与 Claude Code 拥有相同权限,安装前请先阅读原始码。
安装
请先查看作者 README 确认 marketplace 和插件名称;命令可能随仓库结构改变。
claude plugin marketplace add 0xGondarxyz/claude-code-mods claude plugin install save-game
原文 / README
save-game
A Claude Code mod that makes stopping painless. It writes a 3 line save card when you stop. The next time a session opens in that repo, the card shows above the prompt with a Continue button.
Install
/plugin marketplace add 0xGondarxyz/claude-code-mods
/plugin install save-game@claude-code-mods
Or try it without installing:
git clone https://github.com/0xGondarxyz/claude-code-mods
claude --plugin-dir claude-code-mods/save-game
Mods are not sandboxed. They run with the same access as Claude Code. Read the source before you install any mod, including this one.
The card
Doing: <what you and Claude were working on: files, feature, bug>
Next: <the single next step>
Open: <the open question or blocker, or "none">
Cards are kept per repo (the git toplevel of the session folder, else the folder). The store holds the 5 newest per repo. A newer card of the same session replaces the older one.
When a card is made
- Idle: 4 minutes after a main thread turn ends. A new prompt or turn cancels the timer. No new turn since the last card means no card.
- Past 01:00 local time: once per night, if the session had a turn in the last 30 minutes. A toast says it is a good point to stop.
/save: makes a card now.- Session end: if there were turns since the last card, the mod does not call a model (exit time is short). It queues the session. The next session that starts, in any repo, turns the queue into cards in the background with Sonnet, from the tail of the transcript file (your prompts and Claude's text only).
Cards from 1 to 3 use a fork of the live session. It reuses the prompt cache, so it is cheap. The fork only works while the cache is warm (the shortest cache lifetime is 5 minutes, hence 4).
Commands
/save: make a card now and print it withfull context: claude --resume <session id>. With no new turns it prints the newest card again./save list: the last 5 cards of this repo, each with its age, its 3 lines and its resume line.
The band
At session start, if this repo has a card younger than 14 days, a band shows above the prompt:
Saved 3h ago (session ab12cd3)
Doing: ...
Next: ...
Open: ...
[ Continue ] [ Dismiss ]
Continue sends Continue where I stopped. Save card: and the 3 lines as your first prompt. Dismiss hides the band. The band also hides after the first prompt you send. If a queued card for this repo finishes during startup, the band updates to it.
Headless runs
In claude -p and SDK runs the mod does nothing: no timers, no queue, no band, no /save.
Options
None.
Limits
- Module state (turn counts, timers) resets when the mod reloads. Cards and the queue live in the plugin store and stay.
- The queue is read and cleared at session start. Two sessions that start in the same instant can both process the same entry.
- The transcript path is derived from the session folder and id. If the file is missing, the queued session is skipped without a message.
- Only the last 3 MB of the transcript file is read, then cut to the last 30,000 characters of text.
- Needs
tailon the machine for the queue step (Linux and macOS have it).
License
MIT
