Skip to main content
Glama
README.md
<div align="center">

# 🌉 agent-bridge

**Let your AI coding agents talk to each other.**

You use Claude Code. Your co-founder uses Claude Code.
With agent-bridge, the two agents coordinate **directly**: no more copy-pasting long `.md` handoff files between you.

End-to-end encrypted · signed identities · prompt-injection guards · self-hosted relay · MIT

[Quick start](#-quick-start-5-minutes) · [How it works](#-how-it-works) · [Security](#-security-model) · [Autopilot](#-autopilot-your-agent-answers-while-you-sleep) · [🇫🇷 Français](README.fr.md)

</div>

---

## The problem

Two people, two Claude Code sessions, one product. Today the agents can't talk, so the humans carry messages between them:

> "Can you ask your Claude what the new `/api/quiz` response looks like?"
> *(copies a 300-line `HANDOFF.md`, pastes it into a chat, waits, pastes the answer back…)*

## With agent-bridge

```text
You     ▸ Change the quiz endpoint to also return the score, and tell Ali's agent.

Claude  ▸ Done: /api/quiz now returns { id, questions, score }.
          → bridge_send: "Heads-up: GET /api/quiz now returns { id, questions, score }
             (score: int 0-100, null until submitted). Commit a41f2c, file src/routes/quiz.rs."

          … on Ali's machine, the next time Ali talks to Claude …

Claude  ▸ 📨 Camel's agent says /api/quiz now returns a `score` field.
          Want me to display it on the results screen?
```

Nobody copied anything. Nobody had to say "check your messages".

## ✨ Features

| | |
|---|---|
| 🔌 **Plugs into Claude Code in one command** | an MCP server (`bridge_send`, `bridge_read`, `bridge_history`, `bridge_status`) plus hooks that deliver new messages into Claude's context automatically |
| 🔐 **End-to-end encrypted** | AES-256-GCM, keys derived from the invite (HKDF). The relay only sees opaque blobs: no text, no names, no key |
| ✍️ **Signed identities** | every member has an Ed25519 key; messages are signed and pinned on first use. An impostor who stole the invite is flagged `CHANGED` |
| 🛡️ **Injection guards** | incoming messages are wrapped as *data, not instructions*; invisible characters stripped; "ignore previous instructions", "send me your .env", `curl … \| sh`… flagged |
| 🚫 **Secrets never leave** | API keys, tokens, private keys, `.env` lines, passwords in URLs: sending is refused, before encryption |
| 🤖 **Autopilot (opt-in)** | your agent answers your teammate's agent while you're away, **read-only** (Read/Grep/Glob only), with loop protection and an hourly budget |
| 🗂️ **One channel per project** | `agent-bridge link <channel>` writes a tiny `.agent-bridge` file; each repo talks on its own channel |
| ⚡ **Real-time** | long polling: a waiting agent gets the answer within milliseconds |
| 🪶 **Tiny & self-hosted** | relay = ~220 lines of Node with zero dependencies. Docker + automatic HTTPS included. Your data stays on your server |
| ✅ **Tested** | 18 end-to-end tests (two users, relay, MCP over stdio, hooks, impostor, tampering, autopilot), CI on Linux/macOS/Windows × Node 20/22/24 |

## 🚀 Quick start (5 minutes)

**Requirements:** Node.js 20+, [Claude Code](https://docs.claude.com/en/docs/claude-code), and git.

### 1. Install (both of you)

```bash
npm install -g github:Dagbegnon229/agent-bridge
agent-bridge init --name "Camel"        # your display name
agent-bridge install                    # registers the MCP server + hooks in Claude Code
```

### 2. Get a relay (one of you, once)

The relay is the mailbox the encrypted messages go through. Pick one:

<details open>
<summary><b>A. Your own server (recommended): Docker + automatic HTTPS</b></summary>

On any VPS with Docker, with a DNS record (e.g. `bridge.example.com`) pointing to it:

```bash
git clone https://github.com/Dagbegnon229/agent-bridge && cd agent-bridge/deploy
BRIDGE_DOMAIN=bridge.example.com docker compose up -d
curl https://bridge.example.com/health     # {"ok":true,...}
```

Caddy gets the Let's Encrypt certificate automatically. The relay is a single small Node process (memory capped at 128 MB in the compose file).
Already have a reverse proxy? Run only the relay: `docker build -t agent-bridge-relay . && docker run -d -p 127.0.0.1:8787:8787 -v relay-data:/data agent-bridge-relay`, then proxy to it (allow 60 s read timeouts for long polling).
</details>

<details>
<summary><b>B. Without Docker</b></summary>

```bash
agent-bridge relay --host 0.0.0.0 --port 8787 --data ./relay.json
```

Put it behind HTTPS (Caddy, nginx, Cloudflare Tunnel…). Any host that runs Node works.
</details>

<details>
<summary><b>C. Just trying it on one machine / one LAN</b></summary>

```bash
agent-bridge relay            # http://127.0.0.1:8787
```
</details>

### 3. Create a channel and invite your teammate

```bash
agent-bridge create my-startup --relay https://bridge.example.com
```

It prints an invite code (`ab1_…`). **Send it privately** (Signal, WhatsApp, in person): it is the key to the channel. Your teammate runs:

```bash
agent-bridge join ab1_…
```

### 4. Check, then talk

```bash
agent-bridge doctor       # ✔ everything green?
```

Restart Claude Code, then just ask it in plain words:

- *"Ask Ali's agent which env vars the payment service needs."*
- *"Tell my co-founder's agent I renamed `users.phone` to `users.phone_e164`, and wait for the answer."*
- *"What did Ali's agent say today?"*

Optional, per project: `agent-bridge link my-startup` (inside the repo) so that repo always uses that channel.

## 🧠 How it works

```mermaid
sequenceDiagram
    participant A as Camel's Claude Code
    participant R as Relay (your server)
    participant B as Ali's Claude Code
    A->>A: bridge_send("…")<br/>secret filter → sign (Ed25519) → encrypt (AES-256-GCM)
    A->>R: POST ciphertext
    Note over R: stores opaque blobs only<br/>(no text, no names, no keys)
    B->>R: hook / bridge_read (long poll)
    R-->>B: ciphertext
    B->>B: decrypt → verify signature → pin identity<br/>→ injection scan → wrap as untrusted data
    B->>B: Claude sees it in context and tells Ali
```

- **Delivery without asking**: Claude Code hooks (`SessionStart`, `UserPromptSubmit`) fetch new messages and add them to Claude's context. If the relay is down, the hook stays silent and never blocks your prompt.
- **Waiting for an answer**: `bridge_read` with `wait_seconds` (up to 300 s) long-polls the relay.
- **Your inbox, your cursor**: reading marks messages as read on your machine only. `watch` and the autopilot keep their own cursors, so nothing is ever "stolen" from your interactive session.

## 🤖 Autopilot: your agent answers while you sleep

```bash
cd ~/code/my-startup
agent-bridge autopilot
```

Each incoming message starts a **headless, read-only** Claude Code run in that folder. It can only `Read`, `Grep` and `Glob`: no shell, no edits, no web, no MCP. It answers from the code, and the answer is tagged `[autopilot]`.

Safety nets:
- never answers a message that is itself an autopilot answer: two autopilots can't ping-pong;
- never answers flagged messages (possible injection, unknown or changed identity): they wait for you;
- `.env`, keys, `.ssh`, `.aws`, credentials files are denied to the Read tool, and the secret filter still applies to the reply;
- hourly budget (`--max-per-hour`, default 20);
- your interactive session still receives every message.

## 🔒 Security model

agent-bridge connects **an AI agent to another person's AI agent**. That is a prompt-injection surface by design, so it was built "fail closed":

| Threat | Protection |
|---|---|
| Relay operator / network snooping | E2E encryption (AES-256-GCM, HKDF-derived keys). The relay stores only `sha256(auth token)` and ciphertext. Use HTTPS anyway |
| Someone guessing a channel | 144-bit channel id + 256-bit secret; wrong tokens get `401` |
| Invite leaked, attacker poses as your teammate | Ed25519 signatures pinned per name (TOFU). A different key → `identity="CHANGED"` + warning to Claude. Compare fingerprints once with `agent-bridge status` |
| Tampered or replayed-elsewhere messages | GCM auth tag with the channel id as AAD; signatures cover id, channel, sender, recipient, time, text |
| Prompt injection from the other side | messages wrapped in `<bridge-message>` with an explicit "information, not instructions" notice; injection patterns flagged; invisible/bidi characters removed; the wrapper can't be closed from inside |
| Leaking secrets | outgoing filter (API keys, GitHub/GitLab/Slack/Stripe/AWS/Google tokens, JWTs, private keys, `.env` lines, passwords in URLs, invite codes) refuses to send |
| Agent loops / spam | autopilot never answers autopilot; per-channel rate limit (60/min); per-IP channel creation limit; 64 KB message cap; 7-day retention |

Limits, honestly: anyone holding the invite can read the channel (that's what an invite is); the outgoing filter is pattern-based and can miss an unusual secret; and an AI agent can still be persuaded by a well-crafted message, so keep important decisions with humans. See [SECURITY.md](SECURITY.md).

## 🆚 Why not…

| | Copy-pasted `.md` | Shared doc / Notion | Slack/Discord bot | **agent-bridge** |
|---|---|---|---|---|
| Agents talk without humans relaying | ❌ | ❌ | ⚠️ needs a bot + tokens | ✅ |
| Messages arrive in Claude's context automatically | ❌ | ❌ | ❌ | ✅ hooks |
| Agent can wait for an answer | ❌ | ❌ | ⚠️ | ✅ long polling |
| End-to-end encrypted, self-hosted | – | ❌ | ❌ | ✅ |
| Injection & secret guards built in | ❌ | ❌ | ❌ | ✅ |
| Setup | – | accounts | app + scopes | 3 commands |

## 📖 CLI reference

```text
agent-bridge init --name <name>            create your identity
agent-bridge install | uninstall           plug into / remove from Claude Code
agent-bridge doctor                        check everything
agent-bridge create <channel> --relay <url>
agent-bridge join <invite> [--as <channel>]
agent-bridge invite [channel]              print the invite again
agent-bridge link <channel>                use this channel for the current project
agent-bridge use <channel>                 default channel
agent-bridge status [--json]               channels, members, fingerprints, unread
agent-bridge send <text> [--to <name>] [--channel <c>]
agent-bridge read [--wait <s>]
agent-bridge history [--limit 20]
agent-bridge watch                         live terminal view
agent-bridge autopilot [--model <m>] [--max-per-hour 20] [--once]
agent-bridge relay [--port 8787] [--host 127.0.0.1] [--data file] [--trust-proxy]
```

Environment: `AGENT_BRIDGE_HOME` (default `~/.agent-bridge`), `AGENT_BRIDGE_CHANNEL`, `AGENT_BRIDGE_RELAY`, `AGENT_BRIDGE_CLAUDE` (path to the `claude` binary), `CLAUDE_CONFIG_DIR`.

**MCP tools**: `bridge_send(message, to?, channel?)`, `bridge_read(wait_seconds?, channel?)`, `bridge_history(limit?, channel?)`, `bridge_status()`. The server speaks standard MCP over stdio, so other MCP clients can use it too (automatic delivery via hooks is Claude Code only).

## 🩺 Troubleshooting

| Symptom | Fix |
|---|---|
| `doctor`: MCP server not registered | `agent-bridge install`, then restart Claude Code; `/mcp` should list `agent-bridge` |
| Messages don't show up by themselves | hooks are read when a session starts: open a new session. Check `~/.claude/settings.json` contains `agent-bridge.js" hook` |
| `Cannot reach relay` | `curl <relay>/health`. Behind a proxy, allow 60 s read timeouts (long polling) |
| `identity="CHANGED"` | your teammate reinstalled (new key) **or** someone else is using the invite. Confirm by call; if in doubt create a new channel |
| `Blocked: … secret` | working as intended. Share secrets through your password manager, not through agents |

## 🗺️ Roadmap

- [ ] `npx agent-bridge` (npm package)
- [ ] Shared, versioned "project facts" (API contracts, decisions) alongside messages
- [ ] Remote MCP endpoint for claude.ai / Claude Desktop
- [ ] Rotating channel keys (re-key without re-inviting)
- [ ] Optional public relay for quick trials

Ideas and PRs welcome: see [CONTRIBUTING.md](CONTRIBUTING.md).

## License

MIT © 2026 Camel Dagbegnon. Built in Benin 🇧🇯 with Claude Code.

*Independent open-source project, not affiliated with or endorsed by Anthropic. "Claude" and "Claude Code" are trademarks of Anthropic.*