baton utility moves a session between 5 CLI AI agents without losing context
The author of the Go utility baton taught the CLI agents Claude Code, Codex, Antigravity CLI, Pi and Hermes to pick up each other's sessions when one of them hits its five-hour quota. The tool reads the logs on disk instead of asking the model to summarize its own history. That avoids burning expensive output tokens and preserves line numbers and rejected hypotheses. The new agent receives the summary from the last /compact, and the full dump sits in a temporary folder. • Encrypted snapshot for another PC: AES-256-GCM, the key never goes to the server • A SKILL.md skill instead of an MCP server: only a single description line in context • Code uses only the Go standard library, MIT license, three-command build
AI-processed from Habr AI; edited by Hamidun News
Five-hour quotas on $20 plans usually run out mid-debugging, and there is no official bridge between Claude Code, Codex, Antigravity CLI (agy), Pi and Hermes. The author of baton wrote a CLI tool in Go that takes a session from one agent's local logs and hands it to another, either on the same machine or over the network to a different computer. The source code is on GitHub under the MIT license.
Why HANDOFF.md doesn't solve it
The standard advice is to ask the agent, before you leave, to write the task state, steps and plan into a HANDOFF.md file. The author names three problems.
First, once the limit is exhausted, the agent stops responding, so nobody is left to write the summary. Second, even if you catch the moment early, the model retells its own history from memory. The context window holds from 200 thousand to a million tokens, while a single response is capped at a few tens of thousands, so the retelling is necessarily compressed.
Exact command arguments, line numbers, rejected hypotheses and small edits get lost. Third, providers charge roughly five times more for output tokens than for input tokens, and output tokens burn through the remaining quota faster.
Claude Code has a --resume flag for use with multiple accounts, but switching accounts resets the server-side prompt cache, and re-feeding a long history eats a noticeable share of the new quota. The flag cannot move you to an agent from a different vendor.
How baton builds a summary from logs
Every agent already writes a detailed log to disk. Claude Code stores JSONL in ~/.claude/projects, Codex keeps rollout files in ~/.codex/sessions, agy uses transcript.jsonl and Protobuf snapshots in ~/.gemini/antigravity-cli, Pi writes tree-structured JSONL v3 with id and parentId fields, and Hermes uses a SQLite database, state.db. The /compact command erases nothing: the logs are append-only, and a record containing a summary of the earlier conversation is added to the stream.
baton walks the log from the first record (in Pi, along the active branch of the tree; in Hermes, along the parent_session_id chain). It collects a list of changed files and executed commands, and at each compaction marker it flushes the buffer of older messages. The working summary contains the text of the last compaction and all subsequent messages in full.
The complete history and long command outputs go to /tmp/baton-handoff/<session-id>/ (on Windows, %TEMP%). Folders older than a day are deleted, and the working tree stays clean for git status. The chat shows metadata, repository state, affected files, recent commands and paths to the dumps.
The agent pulls any detail it needs from full_dialogue.md or with the baton turn command.
The workflow revolves around a save and load pair. You name the session with the agent's built-in command or via baton save, then tell another agent "Continue session auth-refactor" or "Pick up the last session." If you didn't set a name, baton list shows numbered candidates with the working directory, modification time and first prompt.
The author deliberately chose not to build an MCP server. Such a server starts with every session and sits in memory, and its function descriptions end up in the system prompt and spend input tokens even when sessions go weeks without being transferred. A SKILL.md skill keeps a single line in context, and the utility runs once and exits immediately. All five agents can load skills on demand.
Moving to another laptop without commits
The second scenario is leaving your home PC and continuing on a laptop without pushing raw code to a shared branch. The baton push command packs the following into a tar.gz: the session history, changed and new untracked files (based on the agent's write history and the status in Git, Fossil or SVN), local rules files (CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, .agents/rules/) and a copy of the global instructions.
The archive is encrypted on the client with AES-256-GCM using a random 256-bit key. It is uploaded to paste.rs (up to 10 MiB), falling back to dpaste.org on failure and then to termbin.com:9999. There is also a local sync-folder option: Dropbox, Nextcloud, Syncthing. The key, which is the tail of the token after the # character, never reaches the paste service's server, and without it the package looks like random noise.
On the second computer, you only need to paste the generated prompt into any agent. It reads INSTALL.md, builds the utility and restores the session. If a local file differs from the one being overwritten, a copy with the .baton.bak extension is created next to it. Global rules are unpacked into a temporary directory and do not touch the second machine's system configs.
Installation, updates and limitations
The build takes three commands: git clone, go build -ldflags="-s -w" and baton install. There are no external dependencies, only the Go standard library. baton install copies SKILL.md into the skill directories of all five agents and adds a /baton slash command. The author recommends building from source rather than using prebuilt releases. A background process checks for updates no more than once a day. baton update either rebuilds the utility via go install, verifying against sum.golang.org, or downloads a binary from GitHub Releases and checks its SHA-256.
There are limitations too. Public pastebins remain someone else's infrastructure, and the transfer token is effectively a secret because it contains the decryption key. The log formats are internal and may change when any of the agents is updated. The "fraction of a second" speed is the author's own estimate, and there are no independent measurements. The author himself admits that a similar tool could be built in a day, and suggests that the main value lies in the reverse-engineered session storage formats.
- Nov 1, 2026Local models lose to Opus and Codex: 0.21 on a MacBook versus 1.00 for Codex
- Nov 1, 2026Kimi scores 96.2% on a 1C database analytics test and emerges as a fallback if Claude access is blocked
- Nov 1, 2026OpenAI Rewrites GPT Behavior Rules: Five Values and a Chain of Command
- Nov 1, 2026Google admits AI Mode cuts search revenue, shares fall 15%
Key Questions Answered
Why HANDOFF.md doesn't solve it?
The standard advice is to ask the agent, before you leave, to write the task state, steps and plan into a HANDOFF.md file. The author names three problems. First, once the limit is exhausted, the agent stops responding, so nobody is left to write the summary. Second, even if you catch the moment early, the model retells its own history from memory. The context window holds from 200 thousand to a million tokens, while a single response is capped at a few tens of thousands, so the retelling is necessarily compressed. Exact command arguments, line numbers, rejected hypotheses
How baton builds a summary from logs?
Every agent already writes a detailed log to disk. Claude Code stores JSONL in ~/.claude/projects, Codex keeps rollout files in ~/.codex/sessions, agy uses transcript.jsonl and Protobuf snapshots in ~/.gemini/antigravity-cli, Pi writes tree-structured JSONL v3 with id and parentId fields, and Hermes uses a SQLite database, state.db. The /compact command erases nothing: the logs are append-only, and a record containing a summary of the earlier conversation is added to the stream. baton walks the log from the first record (in Pi, along the active branch of the tree; in Hermes
What are the key details on Moving to another laptop without commits?
The second scenario is leaving your home PC and continuing on a laptop without pushing raw code to a shared branch. The baton push command packs the following into a tar.gz: the session history, changed and new untracked files (based on the agent's write history and the status in Git, Fossil or SVN), local rules files (CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules, .agents/rules/) and a copy of the global instructions. The archive is encrypted on the client with AES-256-GCM using a random 256-bit key. It is uploaded to paste.rs (up to 10 MiB), falling back to dpaste.org on
Build & Ship Production AI Agents Without Boilerplate Code
Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.