handoff-compact

Reviewed at commit ff01a3c

Caution: Saves each handoff, which quotes your last prompts word for word and can include secrets, as a Markdown file in ~/.claude/handoffs outside your project.

Replaces Claude Code's compaction with a structured handoff: a fork of the session writes it from the prompt cache, and the conversation continues from…

Made by
trytofly94
What we checked

Replaces Claude Code's compaction: when it compacts, a fork of your session writes a structured handoff, and that one message replaces the conversation. The last prompts and answers are added word for word. The handoff is also saved as a file. Optionally it decides when to compact and, if you allow it, keeps the session going. It makes no network calls of its own.

Review details

Static review of the source at the pinned commit; not run. Registers session.compact (always), and with trigger self also session.measure and turn.complete. Uses $.model.fork (extra model call on your account), $.session.messages/compact/id/cwd, $.prompt.submit (sends the handoff as the next prompt after a self-triggered compaction; continues on its own only when autoContinue is always or the adapter says so, default never), $.ui.toast/log, $.fs.read/write/exists and $.process.run for mkdir -p. Writes handoff-<session>-<time>.md to the handoffDir option or ~/.claude/handoffs; the file contains the model's summary, adapter notes, the last N user prompts verbatim (default 10, each clipped to 1000 chars) and shortened answers, and is never deleted. Reads HOME, CLAUDE_CODE_AUTO_COMPACT_WINDOW and the autoCompactWindow value of ~/.claude/settings.json, plus the optional outline file. The optional adapter is a user-chosen executable run with session id, cwd and context on stdin (10 s timeout); nothing runs unless the user sets one. Subagent compactions, the precompute compaction (skipped by default) and /compact classic are passed to Claude Code. If the fork fails the compaction falls back to Claude Code with the outline as instructions. Failures are logged and never block. Not reviewed: any adapter the user supplies.

What it uses
  • Reads your prompts: yes
  • Sees tool calls: no
  • Blocks or changes tool calls: no
  • Reads or writes files: yes
  • Runs programs on your machine: yes
  • Calls the model (uses tokens): yes
  • Sends data over the network: no
  • Stores data: yes
  • Shows something on screen: yes
Hooked events

Replaces Claude Code's compaction with a structured handoff: a fork of the session writes it from the prompt cache, and the conversation continues from exactly that handoff.

Made this mod? Add a badge to your README

modsforClaude badge for handoff-compact

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/handoff-compact.svg)](https://modsforclaude.com/mods/handoff-compact/)

← All mods