Documentation
How it works
flowchart LR
subgraph here["this machine: the client"]
you([You]) --> agent["agent session<br/>Claude Code · Codex · Gemini · Grok"]
agent --> cli["agent-bridge client<br/>bin/agent-bridge · bin/agent-bridge.ps1"]
agent -. hooks .-> jhere[("activity journal")]
cli --- mhere[(".git/agent-bridge-mail<br/>outbox · inbox")]
end
subgraph peer["a peer: over SSH, key-only, LAN-only"]
side["peer side<br/>one script per command, on SSH's stdin"]
wt["job worktree + branch<br/>.claude/worktrees/bridge-<me>-<job>"]
runner["job runner, detached<br/>steps · logs · exit codes · summaries"]
mpeer[(".git/agent-bridge-mail")]
jpeer[("activity journal")]
side --> wt --> runner
side --- mpeer
side --- jpeer
end
cli == "sync: git bundle of what the peer lacks" ==> side
cli == "job · wait · logs · stop · done" ==> side
side -. "fetch: new commits, as a bundle" .-> cli
mhere <== "exchange: messages and tasks" ==> mpeer
jpeer -. "monitor: what happens there" .-> cliNo server, no extra port, no cloud relay: SSH with a key that only works from your machine's addresses, and git on both sides.
A request, end to end
What happens when you ask the agent on your laptop to run the tests on another machine:
sequenceDiagram
autonumber
actor You
participant A as Claude Code (laptop)
participant C as agent-bridge client (laptop)
participant P as peer side (buildbox, over SSH)
participant R as job runner (buildbox)
You->>A: "Run the tests on the Windows machine"
A->>C: agent-bridge buildbox sync tests
C->>P: which commits do you have?
P-->>C: its branches
C->>P: a git bundle of only the missing commits
P->>P: worktree bridge-laptop-tests, on its own branch
A->>C: agent-bridge buildbox job tests -c 'cargo test --workspace'
C->>P: the job's steps
P->>R: start, detached from the SSH session
loop each step
R->>R: run it: its own log, exit code, one-line summary
R-->>C: the step's result
end
C-->>A: 01-cargo-test ✓ 214 passed
A-->>You: "The tests pass on Windows"
opt the job made commits
A->>C: agent-bridge buildbox fetch tests
P-->>C: a bundle, as branch from-buildbox/tests
end
A->>C: agent-bridge buildbox done tests
C->>P: remove the worktree and its build folderClient and peer
Every machine is both: a client when it starts work
elsewhere, a peer when it runs work for another. The
client is bin/agent-bridge (bash 3.2+ and jq, on macOS and
Linux) or bin/agent-bridge.ps1 (PowerShell 7.4+, on
Windows); both take the same commands and options, and any client talks
to any peer, in any mix of macOS, Linux and Windows, and to several
peers by name.
The peer side needs nothing installed beyond git, SSH and its shell.
Each command sends one self-contained script (the peer side lives in
lib/peer/posix.sh and lib/peer/windows.ps1,
plus the activity journal's functions), base64-encoded on SSH's stdin,
so no quoting layer can break it and nothing lands on a command line.
With the bash client (macOS and Linux) one SSH connection per peer is
kept open for a minute and shared by every call
(ControlMaster; when the cache folder's path is short
enough for a socket), so a sync-job-fetch round is one handshake.
Windows' OpenSSH can't share one (it has no ControlMaster),
so there every call logs in.
Files (git bundles, get) go over the same SSH stream as
one ordinary command (cat on macOS/Linux, PowerShell on
Windows), not scp: the peer needs no sftp subsystem, and a file that
isn't there fails at once. Each lands under a .part name
and is renamed when whole.
AGENT_BRIDGE_TRACE=<file> appends one line per
call to a peer,
<epoch> <peer> <operation> <exit> <ms>
(the operation's name only), to measure the link. doctor
reports the link itself: each side's OpenSSH, the key exchange they
chose (post-quantum or not), how long a login and an operation take, and
whether the connection is shared. See the link's
design for why it is SSH, and what was weighed against it.
Code: git bundles cut against what the peer has
sync sends a git bundle with only the commits the peer
lacks: the peer first lists the commits it has (its view of the remote's
branches, its own main, the job's branches), and the bundle is cut
against those. fetch does the same the other way. Nothing
is pushed to a remote and nothing depends on the peer reaching one,
which matters because a peer often can't fetch over SSH (git credential
helpers and keychains can need the owner's desktop session).
update-checkout brings the peer owner's own checkout up to
the remote's default branch the same way, fast-forward only.
Jobs: worktrees, detached runners
A job gets its own worktree and branch in the peer's clone
(.claude/worktrees/bridge-<origin>-<job>) and
its own build folder, so jobs from different machines and the owner's
checkout never interfere. The runner (lib/job/runner.sh,
runner.ps1) starts detached from the SSH session (on
Windows through WMI, outside the session), keeps the machine awake, runs
each step with its own log and exit code, adds a one-line summary
(lib/job/summary.awk, summary.ps1) and a
metrics line, honors max_jobs with a machine-wide queue,
and posts a done message when it's a background job. See Jobs.
Messages: a file mailbox
Each clone of a project has a mailbox in its own git folder,
.git/agent-bridge-mail/ (git never tracks or cleans what is
in there, and no repository can deliver a file into it; the worktrees of
a clone share it). Sending writes to outbox/<peer>/,
and an exchange (one SSH call, and a second to confirm when something
came back) delivers that peer's queue and brings back its queue for this
machine, deduplicated by id at every step. Every message is checked
against one rule (lib/msg/) where it is taken in, and again
by the receiving machine's own client before anything reads it. Tasks
are messages too: every change is an event both machines fold the same
way, so they agree on a task's state without a server. See Messages and tasks and the protocol.
Finding machines: mDNS
Pairing and advertise announce services on the LAN with
mDNS/DNS-SD: _agent-bridge-pair._tcp while pairing,
_agent-bridge._tcp while advertising, both pointing at the
SSH port (no new port). The backend is macOS's dns-sd,
Linux's avahi-publish/avahi-browse, or
agent-bridge's own small responder in PowerShell 7
(lib/discovery/mdns.ps1, used on Windows and anywhere pwsh
is installed). TXT records carry only names, OS, user, host name,
addresses and public keys. Pairing itself is commit-then-reveal over
those records; see Pairing.
What's in the plugin
| Part | What it is |
|---|---|
bin/agent-bridge, bin/agent-bridge.ps1,
bin/agent-bridge.cmd |
The client: every command. On Claude Code's PATH;
install-cli puts a wrapper on yours. |
lib/peer/ |
The peer side, sent over SSH for each command; and
serve, what a machine paired for messages only gets
instead. |
lib/job/ |
The job runner, step runner and summary parsers (sent with a job). |
lib/pair/, lib/discovery/ |
Pairing, fleet keys, advertising, mDNS. |
lib/activity/ |
The activity journal and the hooks that feed it. |
lib/msg/ |
The one rule for what a message is, in jq and in PowerShell. |
lib/integrate/ |
install-cli and integrate. |
setup/ |
The SSH server setup scripts (one per OS), run with administrator rights by pairing or by you. |
skills/agent-bridge/ |
The skill: how an agent uses agent-bridge, its rules, and references loaded when needed. |
commands/ |
The /agent-bridge:* slash commands, each a short guide
for the agent. |
hooks/hooks.json |
Claude Code hooks for the activity journal (asynchronous), and one at a session's start that says how many unread messages wait. |
.mcp.json, lib/integrate/mcp.sh |
The MCP server: tools for messages, tasks and sessions (none runs a command), and a two-way Claude Code channel in a session started with it as one (Messages and tasks). |
monitors/monitors.json |
Claude Code's monitors: watch --new --quiet, which
delivers the project's messages into the session, and the same with
--machine for mail that isn't about a project. |
Compared with Claude Code's Remote Control
Remote Control is two things now. A person drives Claude Code
sessions on their machine from a phone or a browser, and, since Claude
Code 2.1.224, an agent can message another of the same account's
sessions (SendMessage): on the same machine through a local
socket, on another machine through Anthropic's servers when both are
connected to Remote Control. That second part does what agent-bridge's
mailbox does, differently (as documented by Anthropic in November
2026):
| Claude Code's cross-session messaging | agent-bridge's mailbox | |
|---|---|---|
| Setup | A claude.ai sign-in and Remote Control on both machines | Pairing, an SSH server, administrator rights once per machine |
| Reach | Anywhere with internet | The LAN, or a VPN (pair --host) |
| Path | Anthropic's servers; the transcript is stored there while connected | Machine to machine over SSH; nothing leaves the LAN |
| Who can use it | Pro, Max, Ultra, Team, Enterprise; not API keys, Bedrock, Vertex, Foundry, ZDR or HIPAA | Anyone: it doesn't touch the model provider |
| Whose sessions | Your own account's, Claude Code only | Any paired machines, a teammate's included
(pair --messages-only: messages and tasks, no shell);
Claude Code, Codex, Gemini, Grok |
| Addressing | A live session by name, listed as busy, idle or offline | A session by name or id, or any, within one project or
machine to machine (--machine); sessions lists
who is live (working, waiting for approval, idle), for every agent
CLI |
| Receiver offline | Queued until that machine reconnects | Kept on disk in the outbox; goes with the next exchange |
| Content | Plain text | Text, a JSON object, attachments with checksums, threads, priority, a due time |
| Receipts | None documented across machines | Queued, delivered or refused; shown to a session; read |
| In the session | Arrives as a message; the agent answers with
SendMessage |
Arrives through the monitor, or as a channel event with the sender
and id as attributes; the agent answers with the reply tool
(MCP) |
| "Tell me when it's idle" | One notice, on the same machine only | One notice across machines (notify-idle, the
notify_when_idle tool), or wait for it
(wait-idle) |
| Two agents that keep answering each other | Repeats dropped; a session that keeps answering is paused until its owner types | Repeats dropped; a thread past its budget (20 messages since the owner's last prompt) waits, and resumes by itself at the next prompt or in 30 minutes |
| Who sent it | The sender's name; held by default when it runs without permission prompts and the receiver doesn't | The sender's machine (signed), session, agent CLI and permission mode, in the header |
| Tracked work | None | Tasks with a state both machines agree on; jobs report into them |
| Receiver's control | Accept, hold for the owner, or refuse; limits on bursts | Accept, hold for the owner, or refuse, per peer; a rate limit, a circuit breaker and the loop guard, all by themselves; everything is checked to be a message, and signed, first |
| The owner's view | Phone and web: read, answer, approve permission prompts | monitor in a terminal: every machine, session, job and
event |
| Code and builds | Not part of it | Git bundles both ways, jobs in worktrees with logs and exit codes |
Use Remote Control to reach a session from your phone, or for a quick word between two of your Claude Code sessions. Use agent-bridge when the work must stay on your LAN, when the other agent isn't Claude Code or isn't on your claude.ai account, when a message must carry a file or wait for a machine that is off, and for work that is tracked: a task, the job that does it, and the branch that comes back. They combine: drive a session from your phone, and let that session run the Windows checks on the build machine next to it through agent-bridge.