Writes a handoff document at every context compaction, so a compacted session resumes from a record of what it was doing instead of from the harness's generic summary. A profile chooses what to preserve: default for any session, orchestration for a session that keeps its state in a task directory, and a compaction profile: <name> line in the conversation overrides the choice. The root README's Handoff Compaction section describes the behaviour in both harnesses; this page covers the wiring.
The module has no tools.
- OpenCode:
server.tsregistersctx.session.hook('compaction', ...). The handoff, generated withctx.generate.texton the session's own model, becomes the stored summary. - Claude Code: the installer merges two hooks into
~/.claude/settings.json.PreCompactrunscli.js pre-compactandSessionStart(matchercompact) runscli.js session-start.
node dist/modules/compaction/cli.js pre-compact --writer-model <model> --writer-context-tokens <n> [--writer-timeout-seconds <n>]
node dist/modules/compaction/cli.js session-start
pre-compact reads the PreCompact hook's JSON on stdin, asks a headless claude -p writer for the handoff and saves it under ~/.claude/handoffs/<session id>/; it always exits 0. session-start reads the SessionStart hook's JSON and prints the directive that tells the resumed session to read the handoff. scripts/link-claude-code.sh installs both with the writer model, its context window and the timeout from scripts/compaction-policy.sh.
None of its own. The Claude Code writer runs claude -p, so it uses Claude Code's login; the OpenCode hook uses the session's own model and provider login.
| Variable | Default | Purpose |
|---|---|---|
CLAUDE_CONFIG_DIR |
~/.claude |
Where handoffs/<session id>/ is written |
CLAUDE_BIN |
claude (resolved from PATH) |
The binary the Claude Code handoff writer runs |
- Claude Code: through the two hooks above. The MCP bridge does not load it: the module has no tools and is not in
src/modules/registry.ts. - OpenCode: as a hooks-only plugin linked by
pnpm run symlink:opencode. No agent permission applies, since it has no tools.