{
  "markdown": "<div align=\"center\">\n\n<img src=\"assets/logo.svg\" width=\"420\" alt=\"baton\">\n\n**Pass the baton between coding agents.**\n\nConvert any coding-agent session to any other. One command. Keep going where you left off.\n\n[![crates.io](https://img.shields.io/crates/v/baton-mcp)](https://crates.io/crates/baton-mcp)\n[![npm](https://img.shields.io/npm/v/%40kasabeh%2Fbaton-mcp)](https://www.npmjs.com/package/@kasabeh/baton-mcp)\n[![CI](https://github.com/Kaseban/baton/actions/workflows/ci.yml/badge.svg)](https://github.com/Kaseban/baton/actions/workflows/ci.yml)\n[![agents](https://img.shields.io/badge/agents-9-8B5CF6)](#supported-formats)\n[![license](https://img.shields.io/badge/license-MIT%20OR%20Apache--2.0-blue)](#license)\n\n<img src=\"assets/demo.gif\" width=\"800\" alt=\"baton converting a Claude Code session to opencode\">\n\nA passed transcript kept **14/17** concrete facts. A hand-written handoff summary kept **3/17**. [Benchmark ↓](#benchmark)\n\n</div>\n\n---\n\n## The 4 p.m. problem\n\nIt's 4 p.m. Claude Code says **\"usage limit reached — resets at 10 p.m.\"** You're three hours into a session: architecture decided, edge cases mapped, half the diff written.\n\n❌ **Without baton** — open another agent and start from zero. Re-explain the plan. Re-read the files. Re-litigate every decision you already made.\n\n✅ **With baton** — pass the session and keep going:\n\n```sh\nbaton convert --from claude-code --to opencode --latest --import\n# using latest claude-code session: 2026-07-09 15:58  Refactor the auth middleware to…\n# passed baton: claude-code → opencode (1388 messages) → handoff.json\n# Imported session: ses_8c4c973a521549e2\n\nopencode -s ses_8c4c973a521549e2   # same conversation, different runner\n```\n\nWorks in every direction: switch agents mid-task, try a second opinion on a hard bug, move a session from your editor agent to a terminal agent, or archive everything in one format.\n\n## Quick start\n\n```sh\n# zero-install run (downloads prebuilt binary)\nnpx @kasabeh/baton-mcp --help\n\n# convert your most recent session + auto-import into the target agent\nbaton convert --from claude-code --to opencode --latest --import\n\n# or omit the path to pick interactively — newest first,\n# each session previewed by its first user message\nbaton convert --from claude-code --to opencode --import\n\n# or pass an explicit session file\nbaton convert --from claude-code --to opencode <session.jsonl> --import\n\n# see every session on your machine, across all agents\nbaton list\n```\n\n### Where do session files live?\n\nYou never have to hunt these down (`--latest` and the interactive picker find them for you), but for reference — each agent stores its transcripts on disk:\n\n| Agent | Location |\n|---|---|\n| Claude Code | `~/.claude/projects/<encoded-cwd>/<session-uuid>.jsonl` |\n| Codex CLI | `~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-*.jsonl` |\n\n`baton list` prints the path of every session it can find, across all agents.\n\n## Supported formats\n\n| Agent | Read | Write | Auto-import |\n|---|:---:|:---:|:---:|\n| Claude Code | ✅ | ✅ | — |\n| OpenCode | ✅ | ✅ | ✅ `opencode import` |\n| Codex CLI | ✅ | ✅ | — |\n| Gemini CLI | ✅ | ✅ | — |\n| Zed | ✅ | ✅ | — |\n| Aider | ✅ | ✅ | — |\n| Cursor | ✅¹ | —² | — |\n| Continue | ✅ | — | — |\n| Cline / Roo | ✅ | —² | — |\n\n¹ Cursor reads from exported JSON (`sqlite3 state.vscdb \"SELECT value FROM ItemTable WHERE key='aiService:chats'\"`)\n\n² Not planned: Cursor and Cline keep session state inside editor databases (SQLite / VS Code globalState) with no file-level import path.\n\n## Benchmark\n\nDoes carrying the full transcript beat writing a handoff summary for the next agent? We measured both on a real 3.4 MB Claude Code session (same model both arms, only the context differs):\n\n| session size | baton transcript | handoff summary |\n|---|---:|---:|\n| sm (93 KB) | **3/3** details recalled | 1/3 |\n| md (198 KB) | **6/6** | 1/6 |\n| lg (599 KB) | **5/8** | 1/8 |\n| **total** | **14/17** | **3/17** |\n\nThe summary lost concrete facts (versions, line counts, MSRV) even on the smallest slice — the receiving agent had to re-read files and re-run commands to rediscover them. Mechanical fidelity: all 896 messages are written to every target; round-trip loss reflects each target format's expressiveness (claude-code 896/896, codex 736, gemini-cli 723, aider 111 — it stores chat text only).\n\nWe also measured **task continuation**: cut the session at three mid-task points, ask a fresh agent to state the task, state, and next steps. Result: parity (baton 10/12, handoff 10/12) — a good summary is enough for *what to do next*; the transcript is what answers the *specific factual questions* the summary's author didn't anticipate. And the summary only exists if an agent spends a full transcript read writing it — baton makes the transfer free.\n\nFull methodology, caveats, and reproduction steps: [benchmark/RESULTS.md](benchmark/RESULTS.md).\n\n## MCP server\n\nbaton is also an MCP server — your agent can pass the baton itself, mid-conversation:\n\n| Tool | Description |\n|---|---|\n| `list_sessions` | Scan all agents, return a unified list |\n| `convert_session` | Convert a session from one format to another |\n| `import_to_target` | Convert + run the target agent's import command |\n| `detect_format` | Sniff a file/dir and report which agent produced it |\n\n```sh\nbaton install     # registers baton in every detected agent's MCP config\nbaton doctor      # verify\nbaton uninstall   # remove from all agents\n```\n\n## How it works\n\n```\nClaude Code session (.jsonl)\n      │\n      ▼\n  baton read ──► canonical Session { messages: [Text, Reasoning, ToolCall, ToolResult] }\n      │\n      ▼\n  baton write ──► OpenCode import JSON (SessionV1 schema)\n```\n\nEvery agent format is read into a **canonical intermediate representation**, then written out in the target format. Adding a new format is O(1), not O(N×M) per-pair converters.\n\n## Install\n\n```sh\n# npm (prebuilt binary, no Rust needed)\nnpm install -g @kasabeh/baton-mcp\n\n# Homebrew\nbrew install kaseban/tap/baton-mcp\n\n# Cargo binstall (prebuilt binary)\ncargo binstall baton-mcp\n\n# Cargo (from source)\ncargo install baton-mcp\n\n# Shell installer (prebuilt binary)\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/Kaseban/baton/releases/latest/download/baton-mcp-installer.sh | sh\n```\n\nOr grab a binary from [GitHub Releases](https://github.com/Kaseban/baton/releases).\n\n## Building\n\n```sh\ngit clone https://github.com/Kaseban/baton.git\ncd baton\ncargo build --release\n./target/release/baton --help\n```\n\n## Contributing\n\nEach format lives in `src/formats/<name>.rs` and implements the `Format` trait (read + write). See `src/formats/claude_code.rs` for a complete reference implementation.\n\nAll nine formats have readers; Claude Code, OpenCode, Codex, Zed, Aider, and Gemini CLI also have writers. The most impactful contribution now is a **writer** for Continue.\n\n### Regenerating the demo\n\nThe README GIF is scripted with [VHS](https://github.com/charmbracelet/vhs): `vhs assets/demo.tape`. It records against a sandboxed `$HOME` (`/tmp/demo`) populated with fabricated sessions, so no real session data ends up in the GIF.\n\nDon't drop the baton.\n\n## License\n\nDual-licensed under MIT OR Apache-2.0.\n",
  "bytes": 7170,
  "sha": "ebbaced595fec97876fecec35891ccd5cc2a193c4f33fd08b73e1827bfe6fbc1",
  "repo_slug": "kaseban/baton",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_tech_kasabeh_baton_30073a13/readme"
}