Baton

tech.kasabeh由 kasabeh.tech 發布v0.3.0更新於 Oct 27, 2026

Pass the baton between coding agents: convert sessions across Claude Code, OpenCode, Codex & more.

已驗證STDIO僅桌面檔案與儲存開發者工具

概覽

AI 產生的概覽

Baton 在 Claude Code、OpenCode、Codex 等編碼代理之間轉換工作階段,讓助理列出、轉換並匯入對話紀錄。

可以做什麼
  • 列出所有支援編碼代理的工作階段及其檔案路徑
  • 把工作階段從一種代理格式轉換成另一種格式
  • 轉換並執行目標代理的匯入指令
  • 辨識某個工作階段檔案或目錄由哪個代理產生
適用情境
適合在遇到用量上限或想中途更換代理時使用,保留完整對話紀錄而不必重新說明計畫。也適合對疑難問題尋求第二意見,或把工作階段統一歸檔成一種格式。
執行需求
以本機 stdio 程序執行,通常透過 npx 呼叫 npm 套件並下載預先編譯的執行檔;也可用 npm、Homebrew、Cargo 或 shell 安裝腳本安裝。僅限桌面環境,未宣告驗證、環境變數或請求標頭。工作階段檔案從本機代理目錄讀取,例如 Claude Code 與 Codex CLI 的資料夾。
安裝前請注意
它會讀取本機代理對話紀錄,其中可能包含程式碼、提示詞與金鑰,並寫出轉換後的檔案、執行目標代理的匯入指令,因此工作階段會被複製到另一個代理的儲存空間。npx 與 shell 安裝方式會從網路下載並執行預先編譯的執行檔。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Baton,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

[baton]

Pass the baton between coding agents.

Convert any coding-agent session to any other. One command. Keep going where you left off.

[crates.io] [npm] [CI] [agents] [license]

[baton converting a Claude Code session to opencode]

A passed transcript kept 14/17 concrete facts. A hand-written handoff summary kept 3/17. Benchmark ↓


The 4 p.m. problem

It'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.

❌ Without baton — open another agent and start from zero. Re-explain the plan. Re-read the files. Re-litigate every decision you already made.

✅ With baton — pass the session and keep going:

sh
baton convert --from claude-code --to opencode --latest --import# using latest claude-code session: 2026-07-09 15:58  Refactor the auth middleware to…# passed baton: claude-code → opencode (1388 messages) → handoff.json# Imported session: ses_8c4c973a521549e2
opencode -s ses_8c4c973a521549e2   # same conversation, different runner

Works 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.

Quick start

sh
# zero-install run (downloads prebuilt binary)npx @kasabeh/baton-mcp --help
# convert your most recent session + auto-import into the target agentbaton convert --from claude-code --to opencode --latest --import
# or omit the path to pick interactively — newest first,# each session previewed by its first user messagebaton convert --from claude-code --to opencode --import
# or pass an explicit session filebaton convert --from claude-code --to opencode <session.jsonl> --import
# see every session on your machine, across all agentsbaton list

Where do session files live?

You 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:

AgentLocation
Claude Code~/.claude/projects/<encoded-cwd>/<session-uuid>.jsonl
Codex CLI~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-*.jsonl

baton list prints the path of every session it can find, across all agents.

Supported formats

AgentReadWriteAuto-import
Claude Code✅✅—
OpenCode✅✅✅ opencode import
Codex CLI✅✅—
Gemini CLI✅✅—
Zed✅✅—
Aider✅✅—
Cursor✅¹—²—
Continue✅——
Cline / Roo✅—²—

¹ Cursor reads from exported JSON (sqlite3 state.vscdb "SELECT value FROM ItemTable WHERE key='aiService:chats'")

² Not planned: Cursor and Cline keep session state inside editor databases (SQLite / VS Code globalState) with no file-level import path.

Benchmark

Does 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):

session sizebaton transcripthandoff summary
sm (93 KB)3/3 details recalled1/3
md (198 KB)6/61/6
lg (599 KB)5/81/8
total14/173/17

The 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).

We 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.

Full methodology, caveats, and reproduction steps: benchmark/RESULTS.md.

MCP server

baton is also an MCP server — your agent can pass the baton itself, mid-conversation:

ToolDescription
list_sessionsScan all agents, return a unified list
convert_sessionConvert a session from one format to another
import_to_targetConvert + run the target agent's import command
detect_formatSniff a file/dir and report which agent produced it
sh
baton install     # registers baton in every detected agent's MCP configbaton doctor      # verifybaton uninstall   # remove from all agents

How it works

Claude Code session (.jsonl)      │      ▼  baton read ──► canonical Session { messages: [Text, Reasoning, ToolCall, ToolResult] }      │      ▼  baton write ──► OpenCode import JSON (SessionV1 schema)

Every 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.

Install

sh
# npm (prebuilt binary, no Rust needed)npm install -g @kasabeh/baton-mcp
# Homebrewbrew install kaseban/tap/baton-mcp
# Cargo binstall (prebuilt binary)cargo binstall baton-mcp
# Cargo (from source)cargo install baton-mcp
# Shell installer (prebuilt binary)curl --proto '=https' --tlsv1.2 -LsSf https://github.com/Kaseban/baton/releases/latest/download/baton-mcp-installer.sh | sh

Or grab a binary from GitHub Releases.

Building

sh
git clone https://github.com/Kaseban/baton.gitcd batoncargo build --release./target/release/baton --help

Contributing

Each 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.

All 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.

Regenerating the demo

The README GIF is scripted with 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.

Don't drop the baton.

License

Dual-licensed under MIT OR Apache-2.0.

來源:README.md,提交 4526159

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.3.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分