claude-handoff
Clean-context handoff for Claude Code. Move the current session into a fresh-context session with zero information loss: a new herdr tab on a Linux terminal server, a new tab in the Cursor / VS Code extension, or a new terminal for the CLI (see Verified live for what has been run end to end).

Native /compact summarizes detail away and keeps the same polluted session. /handoff instead has the agent write a structured working-state document, opens a genuinely new session that resumes from it, wakes that session with a cross-session message, and names its tab after the topic. A PostToolUse hook watches your 5-hour rate-limit usage and nudges the agent to save a checkpoint (a handoff with spawn: "none") that the next session resumes after the limit resets.
How it works
- Capture. The agent authors nine fields (goal, specifics, state, next step, constraints, gotchas, open questions, keep-on-fail facts, verify commands) plus a short title. Secrets are redacted, then
tools/handoff.cjs writes .claude/handoff/HANDOFF.md and an atomic single-shot marker next to it, in the TARGET project.
- Spawn. Default mode
same-window fires the editor URI (cursor://anthropic.claude-code/open, scheme via HANDOFF_URI_SCHEME) immediately, no window focus, no delay, so it lands in whichever window the user is already talking to; the new session starts there and is told to EnterWorktree into the target before reading the handoff (or, when the current window's folder is not a git repository, to work on absolute paths under the target root instead). window opens the target in a new editor window and waits (poll, up to ~15 s on Windows) for it to become the foreground window before firing the URI. terminal opens a new terminal running claude in the target. herdr (the default inside a herdr terminal workspace, where HERDR_ENV=1) opens a new herdr tab in the target and starts claude there with the resume prompt. uri-target keeps the old focus-then-URI behavior. none just prints an instruction. Every mode but none also writes an entry to the pending registry (~/.claude/handoff/pending/) so the resume hook can find the marker from whichever window the new session actually starts in.
- Resume. The fresh session's
SessionStart hook first checks for a local pending marker at its own cwd; if there isn't one, it looks itself up in the registry by cwd. Either way it injects a pointer to HANDOFF.md, auto-sends the first message and consumes the marker. Sessions without a marker or a matching registry entry are untouched and the hook never re-fires.
- Wake. The old session locates the fresh one by its name prefix, sends it the resume message, and tells you to close the old tab.
- Name. The new tab is titled
<topic> #<n>, where n is a generation counter bumped from the previous handoff in that project.
Install
A. As a plugin (recommended)
claude plugin marketplace add MarcinSufa/claude-handoff
claude plugin install handoff@claude-handoff
Restart Claude Code. The plugin's hooks/hooks.json wires both hooks (SessionStart resume and PostToolUse auto-trigger); nothing else to configure.
B. As a plain skill
git clone https://github.com/MarcinSufa/claude-handoff ~/.claude/skills/handoff
Restart Claude Code. If the hooks do not fire in your setup, wire them into ~/.claude/settings.json once:
node ~/.claude/skills/handoff/tools/install.cjs
The installer is idempotent, keeps a temporary backup of settings.json (file mode 0600 on POSIX; plain file on Windows) that is deleted on success and preserves any existing hooks, so it works alongside other SessionStart hooks. Restart Claude Code afterwards.
Usage
Type /handoff (or "hand off", "continue in a fresh session", "przekaż sesję", "nowa sesja z czystym kontekstem", "odpal świeżą sesję") when you want a clean context. With the exo-compact plugin active, a full context alone is not a reason to hand off: exo-compact cuts the context itself, so hand off only when you ask for it. The agent authors the working state, refuses if it cannot name a goal and a next step, runs the glue, wakes the fresh session and tells you: "Handoff is ready in the fresh session <title>, close this one to finish." Closing the old session is the one manual step. When no session could be opened (the result has launched: false), it tells you how to start one instead and does not claim the handoff is ready.
Name the current session as soon as its topic is clear, so the tab is findable among many: