
claude-auto-handoff
Claude Code mod: hand a long session off to a fresh one with a structured brief, instead of auto-compacting
Install with your AI
Paste into Claude Code, Cursor, or any agent — it reads the repo and wires the tool into your project.
Install and set up claude-auto-handoff (claude-plugin project) into my current project. Found on https://claudeers.com/claude-auto-handoff Repo: https://github.com/alexknowshtml/claude-auto-handoff Homepage/docs: — Detected install method: claude-plugin → /plugin install claude-auto-handoff@alexknowshtml/claude-auto-handoff Category: plugins. Platforms: cli, api, desktop, mobile. Read the repo's README for exact setup and env vars, then install it and wire it into my project. Claudeers Health Verdict: unknown; community-verified: false. Confirm the source before running anything.
⚠ Unverified / not recently updated — review before pasting a run-this config.
/plugin marketplace add alexknowshtml/claude-auto-handoff /plugin install claude-auto-handoff@alexknowshtml/claude-auto-handoff
git clone https://github.com/alexknowshtml/claude-auto-handoff
// compatibility
| Platforms | cli, api, desktop, mobile |
|---|---|
| Operating systems | — |
| AI compatibility | claude |
| License | MIT |
| Pricing | open-source |
| Language | TypeScript |
claude-auto-handoff
A Claude Code mod that hands a long session off to a fresh one before the context fills up. It replaces auto-compact.
At the threshold, Haiku writes a structured handoff brief to disk. Then the mod runs /clear and seeds the new session with one line that points at the brief. The fresh session reads the brief and keeps working.

A live run on Haiku with the threshold at 80k. The mod refuses a read at the threshold, writes the brief, clears, and the fresh session is back at work about 7 seconds later at 31k. (video)
Why not auto-compact?
Auto-compact summarizes in place, and you can't control what it keeps. A handoff brief has a fixed structure that you can edit. It covers work in progress, decisions, assumptions to verify, dead ends, your last request and whether it was answered, and the next step. The files, commits and issues sections come from the transcript in code, so they don't depend on the model's memory.
What happens
-
Threshold. The mod checks the context size after each turn and before each model request, including tool output that hasn't been measured yet. Once it's past the threshold, the mod refuses new tool calls, so one burst of reads can't overflow the window. Unmeasured tool output is an estimate that can run high, so the real size sometimes comes in under the threshold. A refused call still ends in a handoff, at the next request or the end of the turn.
-
Brief. Haiku writes the brief from the transcript. If Haiku fails, a facts-only brief stands in. Briefs go to
~/.claude/state/auto-handoff/<session-id>.md. -
Clear and seed. The mod runs
/clearand sends the fresh session one line: read the brief and follow its Instructions section. In the transcript, that line's brief path and viewer URL are drawn as links. Claude Code makes them clickable only when it detects a terminal that supports links. Over plain SSH it usually doesn't, so setFORCE_HYPERLINK=1if your terminal handles links, or use the status line link below. -
A panel above the prompt. It shows each step with a braille spinner on the one still running: writing the brief, clearing, starting the fresh session. Once the new session is measured it reads
✓ handed off · 162k → 45kwith anopen brieflink, then collapses after 10 seconds. Failures, the loop-guard pause, a facts-only brief and a too-tight threshold stay up until you press Dismiss. Typing/clearyourself closes the panel, including one waiting for Dismiss, unless a handoff is running. The panel steps aside while a survey holds that band. The band is drawn on the terminal and desktop only, so on the mobile app or in VS Code the threshold, the result, and anything that stays up also arrive as a toast. -
Viewer. Each brief also gets a readable page in
~/.claude/state/auto-handoff/pages/. The page shows the brief and every handoff in the same run, linked in order. The served link is short, likehttp://100.x.y.z:3846/1a2b3c4d, so it fits on one line on a phone. By default the mod serves these pages on your Tailscale IP at port 3846, so you can open them from any device on your tailnet. Devices off your tailnet can't reach them. The server starts with the first session that loads the mod and runs while that session is open; if it stops, including when the mod reloads, the next session to finish a turn starts it again. A session that finds the port already taken logs one line and leaves the running server alone, since it serves the same pages. Without Tailscale, the mod serves on127.0.0.1instead, so the link opens only on this machine. If Tailscale comes up later, a session already serving on localhost keeps using it; the next new session can serve on the Tailscale IP. -
Status line link (optional).
statusline/handoff-link.shwraps your status line command and adds a↪ <link>line when the session came from a handoff. Set it as thestatusLinecommand in~/.claude/settings.json, with your existing command after it:"statusLine": { "type": "command", "command": "~/claude-auto-handoff/statusline/handoff-link.sh ~/.claude/my-statusline.sh" }It needs
jq. It finds the link in the previous brief's header, which names this session into:and the page inviewer:.
Loop guards stop a fresh session that starts large from handing off again right away. They also cap how many handoffs run in a row before you type something.
Install
Requires a Claude Code build with mods (function-hook plugins).
git clone https://github.com/alexknowshtml/claude-auto-handoff.git ~/claude-auto-handoff
claude --plugin-dir ~/claude-auto-handoff
To load it in every session, set CLAUDE_CODE_PLUGIN_DIRS to the folder in your shell environment, or in the env block of ~/.claude/settings.json:
{ "env": { "CLAUDE_CODE_PLUGIN_DIRS": "~/claude-auto-handoff" } }
Configure
Every setting is a row in /config under auto-handoff. They're stored in ~/.claude/settings.json under pluginConfigs.
| Setting | Default | What it does |
|---|---|---|
threshold | 160000 | Context tokens that trigger a handoff. Sized for a 200k window: it leaves room for the brief and the turn in flight. A seeded session hands off no sooner than 40k past its own starting size, whatever this says; set it lower than that and the panel tells you where the line actually is |
maxConsecutiveHandoffs | 2 | Handoffs allowed before you type a prompt; past this, the mod pauses until you do |
briefTemplate | ~/.claude/auto-handoff/brief.md | Your copy of the sections Haiku writes |
instructionsTemplate | ~/.claude/auto-handoff/instructions.md | Your copy of what the fresh session is told to do |
ignoreFiles | blank | Regex for edited files to leave out of the brief, such as caches or synced state |
viewer | tailscale:3846 | Where to serve the brief pages, as host:port. tailscale as the host means this machine's Tailscale IP, or 127.0.0.1 when Tailscale isn't set up. Leave blank for no server; the link is then the local file |
Environment variables:
AUTO_HANDOFF_TOKENS=60000overrides the threshold for one run, so you can watch a handoff without filling 160k first. It stays set in that shell after the test. Seeded sessions start near 45k, so a value under about 85k leaves them less than 40k of room: the mod then hands off at start + 40k instead and the panel showsthreshold 60k (AUTO_HANDOFF_TOKENS) leaves 15k ...so you know the override is still live.AUTO_HANDOFF_DISABLE=1turns the mod off for one session, viewer server included.DISABLE_AUTO_COMPACTalso turns it off. When something else manages the context limit, such as a wrapper that pipes the session,/clearwould break that pipe. The viewer server still runs there.
Change the brief's structure and rules
The brief is shaped by two markdown files. The defaults live in this repo's templates/ folder:
templates/brief.mdis the prompt Haiku gets after the transcript. Each##heading is a section of the brief.templates/instructions.mdgoes at the top of the brief and tells the fresh session what to do with it.
On a session's first start, the mod copies both files to ~/.claude/auto-handoff/ if they aren't there yet. Edit those copies, not the ones in the repo, so a git pull never overwrites your changes. The next handoff uses your version.
To get the current default back, delete your copy. The next start copies it fresh. To keep your files somewhere else, point briefTemplate or instructionsTemplate in /config at them.
Editing brief.md
Add, remove, rename or reorder ## sections. The text under each heading tells Haiku what to put there. A Haiku reply counts as valid if it contains at least one of your headings. Otherwise the mod falls back to a facts-only brief.
Leave out files and commits sections. The mod adds them from the transcript in code.
Editing instructions.md
It has one switch:
{{#priority}}Shown when the last request is not fully answered.{{/priority}}
{{^priority}}Shown when it is.{{/priority}}
The switch reads the brief's ## Last Request from the User section and its Status: line. Keep both in brief.md if you want it to work.
Logs
Everything the mod does is logged to ~/.claude/state/auto-handoff/auto-handoff.log.
Develop
claude plugin validate .
claude plugin test .
The mod hot-reloads when you save while it's loaded with --plugin-dir.
Changelog
- 0.8.6 On a machine without
sh(Windows), the brief page is still written, and the link opens it as a local file instead of a server that never started. The viewer no longer shells out tomkdir. - 0.8.5 Windows support, from @davidboomcycle (#3). The mod falls back to
USERPROFILEwhenHOMEis unset, so briefs no longer land in<project>/undefined/. Where there is nosh, the log is written through$.fs. The tests pass on Windows. The viewer server still needs a POSIX shell. - 0.8.4 Any token figure in Haiku's brief that isn't in Handoff Numbers is marked
[unverified: not in Handoff Numbers]and logged. The figure is marked, not removed. - 0.8.3 The brief gets the real numbers: tokens at handoff, the threshold and where it came from, the session's starting size, and how many handoffs ran with no message from you. Haiku must copy them or write "unknown", so a brief can no longer invent a figure like "burned its 200k budget".
- 0.8.2 A refused tool call always ends in a handoff, even when the real size measures under the threshold. Your own
/clearcloses the panel. A second session that finds the viewer port taken exits quietly instead of logging a stack trace. - 0.8.1 On the mobile app and in VS Code, which don't draw the panel, the threshold, the result and anything that stays up also arrive as toasts.
- 0.8.0 A panel above the prompt replaces the toasts, with a spinner on each step and an
open brieflink. - 0.7.0 A seeded session hands off no sooner than 40k past its starting size. When the threshold is set tighter than that, the panel says so and names the setting. The viewer serves on
127.0.0.1when Tailscale isn't available. - 0.6.0 A viewer page for each brief, served on your Tailscale IP with short links. The pages in a chain link to each other. The seed row's links are clickable, and the status line script adds a handoff link.
- 0.5.0 First release: a Haiku brief,
/clearand a seed prompt. It includes the tool gate, the check before each request, auto-compact replaced by a handoff, and the loop guards.
License
MIT
// faq
What is claude-auto-handoff?
Claude Code mod: hand a long session off to a fresh one with a structured brief, instead of auto-compacting. It is open-source on GitHub.
Is claude-auto-handoff free to use?
claude-auto-handoff is open-source under the MIT license, so it is free to use.
What category does claude-auto-handoff belong to?
claude-auto-handoff is listed under plugins in the Claudeers registry of Claude-compatible tools.
// embed badge
[](https://claudeers.com/claude-auto-handoff)
// retro hit counter
[](https://claudeers.com/claude-auto-handoff)
// reviews
// guestbook
// related in Claude Plugins
A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explainin…
"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
financial-services — a Claude ecosystem project on GitHub.