/handoff:handofffrom handoff
Hand off the current Claude Code session to a fresh-context session without losing state: you write a structured working-state doc (HANDOFF.md), the glue opens a new session that resumes from it and names it "<topic> #<n>". Openers: a herdr tab on a Linux terminal server (HERDR_ENV=1), a new tab in the Cursor/VS Code extension, or a new terminal for the CLI (extension and terminal live-tested on Windows only); with no opener it saves the doc and says how to resume. Use on explicit user intent: "/handoff", "hand off", "continue in a fresh session", "przekaż sesję", "nowa sesja z czystym kontekstem", "odpal świeżą sesję", or when the usage nudge asks for a checkpoint. With the exo-compact plugin active, "context is getting full" alone is not a trigger: exo-compact handles that.
Ships in handoff. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Hand the current session to a fresh-context session with zero info loss. (Native /compact is lossy and keeps the same polluted session; this does NOT use it.)
When invoked:
Author the working state as JSON with exactly these keys (lists may be empty, but every key is required): goal (one sentence), specifics (files/symbols/branch/PR/URLs in play), state (what's done, past tense), nextStep (the ONE next action), constraints, gotchas, openQuestions, keepOnFail (irreducible facts), verify (exact build/lint/test commands). Optional title: the session topic in 2-4 words (defaults to the previous handoff's title, else the first words of goal). Optional spawn: "same-window" (default) | "herdr" (default when HERDR_ENV=1) | "window" | "terminal" | "none" | the legacy "uri-target". Optional callerCwd: the CURRENT window's workspace root (defaults to process.cwd(); pass it explicitly when you have already run EnterWorktree, since the session's cwd is then the worktree, not the window folder). Reflect honestly on THIS conversation; be concrete.
Refuse if you cannot fill goal and nextStep: ask the user instead.
Pick the spawn mode: leave spawn out and never ask (the glue picks herdr inside herdr, else same-window). Only ask the user which mode they want when they say something like "in a separate window" or "in a terminal"; then set spawn accordingly.
Run the glue once, piping the JSON to it (use a heredoc):
node "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/skills/handoff}/tools/handoff.cjs" <<'JSON'
{"title":"panel verdicts","goal":"...","specifics":["..."],"state":"...","nextStep":"...","constraints":["..."],"gotchas":["..."],"openQuestions":["..."],"keepOnFail":["..."],"verify":["..."],"callerCwd":"/path/to/current/window/root"}
JSON
spawn is optional (omit it for the default: herdr inside herdr, else same-window) and callerCwd is set to the workspace root of the CURRENT window, not the target project the handoff is about.
CLAUDE_PLUGIN_ROOT is set when the skill runs as a plugin; the default covers a copy in the user skills directory. If the skill lives elsewhere, substitute the directory containing this SKILL.md.
The result carries launched (true only when a fresh session was actually opened), spawn (spawn.mode, and spawn.message when nothing was opened), title (e.g. panel verdicts #3), generation, mode, sessionNamePrefix (e.g. agent-test-), resumeMessage and closeOld. ok: true only means the handoff doc was saved.
If your Claude Code exposes the ListAgents and SendMessage tools: Wake the fresh session (extension and CLI alike; skip it when launched is false, and when spawn.mode is herdr: that session got the resume prompt as its first message, and herdr agent read <spawn.agent> shows it):
sleep 15), then call ListAgents once. The fresh session is the row whose name starts with sessionNamePrefix and whose "started" age is the youngest (well under a minute). Confirm it before messaging: a transcript created after the spawn time must exist (find ~/.claude/projects -maxdepth 2 -name '*.jsonl' -newermt '<spawn HH:MM:SS>'; on Windows use Git Bash or skip this check) and its first message must start with the tab title. A row that is merely young can be one of the user's own tabs (observed 2026-09-02: a resume message went to a live user session by that mistake).SendMessage to that name with message = resumeMessage and notify_when_idle: true. A fresh session processes a cross-session message with no typing from the user (verified 2026-09-02: an idle tab with an unsubmitted prompt replied within seconds).resumeMessage and you consume the marker by renaming handoff.pending.json to handoff.consumed.json, or the user opens a new tab in the project window and the SessionStart hook resumes it.Relay the result, branching on launched:
launched: true: tell the user "Handoff is ready in the fresh session <title>, close this one to finish." (Closing the old session is the one manual step; nothing can close it automatically.) The idle notice from the fresh session arrives later on its own; do not poll for it.launched: false (spawn.mode is manual, or the opener ran but the session never started): nothing is running yet. Relay spawn.message (also in closeOld) as the next step, e.g. start a fresh claude in the named folder, where the hook resumes the handoff. Do NOT say the handoff is ready and do not tell the user to close this session before the new one runs.Resume is automatic: the fresh session's SessionStart hook injects a pointer and auto-sends the first message. The URI prompt is a backstop for when the hook is unavailable; both start with the tab title.
Same-window is the default, so there is nothing to stay put for. The URI fires immediately, with no focus step and no delay, so it lands in whichever window you were already talking to; the new session starts there (callerCwd), not in the target project. That is why its first message tells it to EnterWorktree (with path, never name) into the target root before reading HANDOFF.md, and why the "wrong window" check accepts either callerCwd or targetCwd as correct. When callerCwd is the target itself, both are skipped: the message just names the doc and the one folder. Ask for spawn:"window" or spawn:"terminal" only when the user asks for a separate window or a terminal; a genuinely parallel handoff (two spawns within about 20 s) can still land in the wrong tab, since spawns are not queued.
Same-window still works when the current window's folder is not a git repository (EnterWorktree needs one): the message instead tells the fresh session to work on absolute paths under the target root, cd-ing into it for every shell command instead of entering a worktree.
First-time setup: none when installed as a plugin. The plugin install wires both hooks (the SessionStart resume hook and the PostToolUse auto-trigger) through hooks/hooks.json; restart Claude Code once after installing so they activate. Run node "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/skills/handoff}/tools/install.cjs" only when you installed by copying this directory into ~/.claude/skills and the hooks do not fire: it merges both hooks into ~/.claude/settings.json with a timeout on each (10 s SessionStart, 5 s PostToolUse; re-running it adds the timeout to an older install), secret-safe, idempotent, preserving existing hooks; then restart Claude Code.
<title> #<generation> automatically: the hook puts it at the front of the first message and writes the custom-title sidecar next to the transcript.node "${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/skills/handoff}/tools/session-title.cjs" "<topic in 2-4 words>" (reads CLAUDE_CODE_SESSION_ID, writes the sidecar only, never touches the transcript). The open tab may keep its old label until it is reopened; the session picker shows the new one. Do not append #n by hand: the handoff glue owns the generation counter.tools/handoff.cjs captures the 9 fields (+ title), redacts secrets, writes .claude/handoff/HANDOFF.md (frontmatter carries title and generation, bumped from the previous doc) plus an atomic single-shot marker in the TARGET project, then dispatches tools/spawn-tab.cjs per the chosen mode and, for every mode but none, writes a registry entry under ~/.claude/handoff/pending/ so the hook can find the marker even from a different window.tools/spawn-tab.cjs runs every editor launch WITHOUT ELECTRON_RUN_AS_NODE: a session started by the Cursor extension inherits that variable, and with it the editor binary boots as plain node and rejects --open-url, so the URI used to be a silent no-op (root cause found 2026-09-02).hooks/sessionstart-handoff.cjs runs on the fresh session: first checks for a local pending marker at this cwd (the window/terminal/uri-target case); if none, and the session just started, scans the registry for an entry matching this cwd as either callerCwd or targetCwd (the same-window case), sweeping stale or invalid entries as it goes. Either way it injects the pointer, auto-sends the resume message, names the tab, and consumes the marker (so normal sessions are untouched and it never re-fires).hooks/usage-monitor.cjs (PostToolUse auto-trigger) reads rate_limits.five_hour.used_percentage from the hook payload and, when 5-hour usage crosses a threshold, injects an additionalContext nudge telling you (the agent) to save a checkpoint with /handoff and spawn: "none": a fresh session would draw on the same 5-hour quota, so the work resumes in the next session started in the project after the limit resets (the marker lasts 24 h). It is a tripwire, not a capture: a PostToolUse hook can't author the working state, so it asks the agent to. Fires each level at most once per session (.claude/handoff/.last-warned.json).90% gentle nudge; 95% urgent nudge. Single-shot per session+level (no per-tool-call spam).HANDOFF_AUTO_SAVE_PERCENT and HANDOFF_URGENT_PERCENT accept a number (e.g. 85) or disabled.rate_limits is exposed to hook stdin only on newer Claude Code for Pro/Max; where it's absent the hook silently no-ops. It never blocks a tool call (fail-open).spawn: "none", because a new session spends the same 5-hour quota. When the user asks for a fresh session anyway, hand off as usual.tools/rotate.cjs is a launcher that accepts JSON on stdin, returns JSON on stdout, and exits 0 only when ok is true. The exo-vault hook calls it through EXOVAULT_ROTATE_LAUNCHER, then $CLAUDE_PLUGIN_ROOT/tools/rotate.cjs, then the plugin cache at version 1.1.0 or newer. Rotation is opt-in on the exo-vault side with EXOVAULT_ROTATION=1; this plugin ships no PreCompact or Stop guard. Cursor refuses to launch when more than one Cursor window has the directory open.
On Linux and macOS, CLI rotation without herdr returns halt:launch_failed no_terminal; run inside herdr or rotate by hand with /handoff.
.git (never CLAUDE_PROJECT_DIR), so the write-path and read-path can't diverge.verify/nextStep commands itself; the fresh session checks the doc against the live repo, continues from nextStep on its own, and asks the user only before a destructive or irreversible step.HANDOFF_SPAWN (same-window | herdr | window | terminal | none | uri-target, legacy auto/uri map to uri-target; unset means herdr when HERDR_ENV=1, else same-window), HANDOFF_URI_SCHEME (default cursor), HANDOFF_EDITOR_EXE (editor binary used to focus or open the project window), HANDOFF_TERMINAL_EXE (terminal binary for terminal mode, default wt.exe from WindowsApps when present), HANDOFF_HOME (registry root and the append-only log index.jsonl, default ~/.claude/handoff).What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub marcinsufa/claude-handoff --plugin handoff