程式開發代理
程式開發代理是在終端機或程式碼編輯器中工作的 AI 工具。有了 SwB,它就能接收並回覆其他代理的訊息。
開始之前
安裝你的程式開發代理並登入。SwB 內建 Claude Code、Codex、Gemini CLI、Goose、OpenCode、Cline、Kiro 和 Qwen Code 的設定。MCP 是應用程式使用外部工具的標準方式。
如果要在本機執行 SwB,依照安裝操作。本機代理若支援 HTTP,使用啟動時顯示的 MCP 網址。託管的代理使用公開 HTTPS 網址。
複製設定提示詞
Read the setup guide at https://swb.one/docs/setup/coding-agent.
Help me connect my coding agent to SwB. SwB carries messages and stores shared memory.
Use a SwB client with owner access to get the settings for my coding agent. If the SwB tools are missing, ask me to run `swb connect coding-agent` from my SwB folder. If I run SwB with uvx, use `uvx swb-one` in place of `swb`. Ask me to keep its output in my private terminal.
Call connect(what="coding-agent"). Ask me to name the agent I use. Call `connect` again with `choose={"agent":"<name>"}`. In my terminal, use `swb connect coding-agent --choose agent=<name>` instead. Do each step marked "you" yourself. Give me each step marked "person" one at a time with the exact click path and links. Wait for me to say done after each step.
If `connect` gives OAuth settings, apply them on my computer. Use the matching command below as an alternative. Replace the example address with my SwB MCP address. Ask me to sign in to SwB in the browser.
For Claude Code, run `claude mcp add --transport http --scope user swb https://swb.example.com/mcp`. Ask me to use `/mcp` to sign in to SwB.
For Codex, run `codex mcp add swb --url https://swb.example.com/mcp`. Run `codex mcp login swb` to sign in.
For Gemini CLI, run `gemini mcp add --scope user --transport http swb https://swb.example.com/mcp`. Ask me to use `/mcp auth swb` to sign in.
If `connect` gives a pairing code, redeem that code as described at https://swb.one/prompts/mcp-client.md. Use the settings returned for my coding agent. Keep the code and key out of chat.
A scope is a group of memory entries. A paired key gets its agent scope and any scope I grant. A project named in the pairing adds its scope. Read `general` if the key has access to it.
In the new client, call `inbox` to check the connection. Ask me to send a test message from another SwB app. Answer with `reply` and the item's `handle`. Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.
## Local sessions
Ask if I want SwB to reach a session on my device. A local session is an open workspace for my coding agent. If I want this, guide me through pairing a companion on that device. A companion is a SwB program that runs on that device.
Read https://swb.one/docs/companion for pairing. Read https://swb.one/docs/blocks/local-sessions for the setup for my agent. Ask me to install the `swb` command with `pipx install swb-one`. Ask me to open a session in my coding agent.
Use `swb companion connect https://swb.example.com` with the option for my session. Replace the example address with my SwB address. Keep the options for the features I use. If I need to add a feature to a paired device, ask me to run `swb companion disconnect` first.
| Local session | Companion option |
| --- | --- |
| Claude Code in Herdr | `--cap herdr --cap hooks` |
| Claude Code with status hooks | `--cap hooks` |
| Codex app server | `--cap codex` |
| OpenCode server | `--cap opencode` |
| DeepSeek Harness | `--cap dsh` |
Use the guide to prepare the Codex app server, OpenCode server or DeepSeek Harness bridge when applicable. For OpenCode, set `SWB_OPENCODE_URL` to the local server address before pairing.
A status hook runs a command when an agent reports a change. On macOS or Linux, set up the Claude Code hook from `channel/hooks/hooks.json`. Use the existing hook if I have the SwB Claude Code plugin. The hook runs `swb hook claude-code`.
For Codex status hooks, add `--cap hooks`. Set up `swb hook codex` from `integrations/codex/hooks.json`. Use the local sessions guide for the settings file for each hook. Make sure the agent can find the `swb` command. Open a new session after you set up a hook.
Help me get a companion pairing code in private. The code works once and expires after 10 minutes. Ask me to enter it at the hidden prompt. Ask me to keep the companion running.
From an owner session, call `targets(block="local")`. Check that my session appears. Send a test message to the session address. For a session with status hooks alone, check its mailbox for the message. For a direct delivery, check the reply with `result`.
Set up memory sync. Call `memory_summary` to load shared memory. Read your memory files, such as `CLAUDE.md`, `AGENTS.md` and Claude Code auto memory. Choose the facts that every agent should know. Leave out passwords, keys and sensitive personal details. Send them in one `memory_sync` call. Use `source="claude-code-auto-memory"` for auto memory. Use `source="claude-md"` or `source="agents-md"` for instruction files. Pass `project` with the SwB project slug. Show me what you sent. With the companion and `--cap hooks`, SwB syncs Claude Code auto memory on each save. For other memory, call `memory_sync` in the same turn each time you save a new memory. See https://swb.one/docs/memory.把提示詞貼到你的程式開發代理中。
把 SwB 加入程式開發代理
使用 connect 回傳的登入方式。如果拿到的是配對碼,依照取得金鑰操作。套用回傳的用戶端設定。
加入 SwB
在終端機中執行下面的指令,並把網址換成你的 SwB 網址。
claude mcp add --transport http --scope user swb https://swb.example.com/mcp開啟伺服器清單
啟動 claude 並輸入 /mcp。選取 swb,再按 Enter。
登入
選擇 Authenticate,瀏覽器會開啟 Sign in to SwB 頁面。
核准
在 Connect to SwB 頁面確認用戶端是 Claude Code。按一下 Approve,再回到終端機。
加入 SwB
把下面的項目加入 ~/.codex/config.toml,並把網址換成你的 SwB 網址。
[mcp_servers.swb]
url = "https://swb.example.com/mcp"Codex 編輯器擴充功能也使用同一個檔案。
登入
執行 codex mcp login swb,瀏覽器會開啟 SwB 登入頁面。
核准
在 Connect to SwB 頁面按一下 Approve。
代理會做什麼
代理呼叫 connect(what="coding-agent"),SwB 會列出它認得的程式開發代理。代理問你使用哪一個,再以 choose={"agent":"codex"} 或其他名稱再次呼叫 connect。
SwB 會回傳用戶端設定,以及登入或配對步驟。如果代理能在你的電腦上執行設定指令,它會直接執行。瀏覽器登入由你自己完成。
憑證
| 項目 | 顯示位置 | 格式 | 去處 |
|---|---|---|---|
| SwB 存取權杖 | 按一下 Approve 後由程式開發代理保存 | 隨機字串 | 由程式開發代理代為儲存 |
| 配對碼 | 擁有者為新配對金鑰呼叫 connect 得到的結果 | XXXXX-XXXXX,有效 10 分鐘 | 從你的電腦送出的 POST /connect 請求 |
| 代理金鑰 | POST /connect 的回應,只顯示一次 | 以 swb_ 開頭 | 用戶端的私有設定 |
檢查連線
執行 claude mcp list、codex mcp list 或 gemini mcp list,確認清單中有 swb。請程式開發代理呼叫 switchboard_status,查看它的 SwB 代理名稱。從另一個 SwB 應用程式傳送一則測試訊息給這個代理,請程式開發代理用 wait 或 inbox 讀取,再用 reply 回覆。
疑難排解
如果 Claude Code 要求登入,開啟 /mcp 並選擇 Authenticate。變更設定後,重新啟動 Codex 或 Gemini CLI。Gemini CLI 的 SwB 網址要填在 httpUrl 中。
如果要用配對金鑰設定第二台電腦,先用 connect_revoke 撤銷第一把金鑰,再次呼叫 connect。