Write a handoff before the prompt cache goes cold #1

Merged
turnercore merged 3 commits from feat/handoff-on-cold into main 2026-09-30 08:38:18 +02:00
Owner

Before a large session's prompt cache goes cold, fork the session while the cache is still warm and save a handoff, so the user can start a fresh Claude or Codex session from it instead of paying for a cold cache rewrite.

  • When: one ping interval after the last warm request, whenever nothing else would keep the cache warm (no keepwarm window, or the window ends first). With a window it replaces the final ping. Once per idle stretch, only at ≥50k context.
  • What: the prompt is ~/.claude/skills/handoff/SKILL.md read at fire time, with an embedded fallback. Saved to <main checkout>/.handoffs/<YYYYMMDD-HHMM>-auto.md (resolved via git rev-parse --git-common-dir, so worktrees share it).
  • Clock: the handoff fork refreshes the cache, so the guard counts it as warm until handoff + TTL.
  • Guard: on a cold send, the message names the handoff: start fresh from it, or resend to continue here.
  • Disposal: a real prompt that goes through in the same session deletes the handoff. Slash commands and dropped sends leave it.
  • Fork results: one forkAnswer helper normalizes the published ModelForkResult | null and the {isAnswered, …} shape Claude Code 2.1.285 actually returns, for pings and handoffs alike.

Checks: claude plugin test . 50 pass, 0 fail; tsc -p . clean. Not yet verified live against a real cache.

🤖 Generated with Claude Code

Before a large session's prompt cache goes cold, fork the session while the cache is still warm and save a handoff, so the user can start a fresh Claude or Codex session from it instead of paying for a cold cache rewrite. - **When:** one ping interval after the last warm request, whenever nothing else would keep the cache warm (no keepwarm window, or the window ends first). With a window it replaces the final ping. Once per idle stretch, only at ≥50k context. - **What:** the prompt is `~/.claude/skills/handoff/SKILL.md` read at fire time, with an embedded fallback. Saved to `<main checkout>/.handoffs/<YYYYMMDD-HHMM>-auto.md` (resolved via `git rev-parse --git-common-dir`, so worktrees share it). - **Clock:** the handoff fork refreshes the cache, so the guard counts it as warm until handoff + TTL. - **Guard:** on a cold send, the message names the handoff: start fresh from it, or resend to continue here. - **Disposal:** a real prompt that goes through in the same session deletes the handoff. Slash commands and dropped sends leave it. - **Fork results:** one `forkAnswer` helper normalizes the published `ModelForkResult | null` and the `{isAnswered, …}` shape Claude Code 2.1.285 actually returns, for pings and handoffs alike. Checks: `claude plugin test .` 50 pass, 0 fail; `tsc -p .` clean. Not yet verified live against a real cache. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Found in a live run: the fork invented a timestamp and fenced its markdown.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
turnercore/cache-tax!1
No description provided.