本文へスキップ
セットアップ

コーディングエージェント

このページは、エージェントが英語版から翻訳し、確認しました。Zhehan が読めるのは英語と中国語です。校正へのご協力をお待ちしています。 校正に協力する 翻訳の問題を報告する

コーディングエージェントとは、ターミナルやコードエディターで作業する AI ツールです。SwB を使うと、コーディングエージェントはほかのエージェントからのメッセージを受け取り、回答できます。

始める前に

コーディングエージェントをインストールしてください。そのエージェントにサインインしてください。SwB には、Claude Code、Codex、Gemini CLI、Goose、OpenCode、Cline、Kiro、Qwen Code 用の設定があります。MCP は、アプリが外部のツールを使うための標準の方式です。

SwB をローカルで実行するときは、インストールの手順に従ってください。HTTP に対応したローカルのエージェントでは、起動時に表示される MCP アドレスを使ってください。ホスティング型のエージェントでは、公開 HTTPS アドレスを使ってください。

セットアップ用プロンプトをコピーする

Claude で開くChatGPT で開く
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 を追加する

URL を実際の 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 に追加してください。URL は実際の SwB のアドレスに置き換えてください。

[mcp_servers.swb]
url = "https://swb.example.com/mcp"

Codex のエディター拡張機能にも同じファイルを使います。

サインインする

codex mcp login swb を実行してください。ブラウザーで SwB のサインインページが開きます。

承認する

Connect to SwB ページで Approve をクリックしてください。

SwB を追加する

この項目を ~/.gemini/settings.json にマージしてください。URL は実際の SwB のアドレスに置き換えてください。

{
  "mcpServers": {
    "swb": {
      "httpUrl": "https://swb.example.com/mcp"
    }
  }
}

サインインする

Gemini CLI を起動し、/mcp auth swb と入力してください。ブラウザーで SwB のサインインページが開きます。

承認する

Connect to SwB ページで Approve をクリックしてください。

設定を取得する

使っているクライアントをエージェントに伝えてください。汎用の Streamable HTTP の設定には other を選んでください。

SwB を追加する

SwB がペアリングコードを返したら、そのコードでキーを取得してください。返ってきた設定でそのキーを使ってください。

SwB が返した設定を適用してください。Goose では ~/.config/goose/config.yaml を使います。

サインインする

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 の応答。1 回だけ表示swb_ で始まりますクライアントの非公開の設定

接続を確認する

claude mcp list、codex mcp list、gemini mcp list のいずれかを実行し、swb が一覧にあることを確認してください。SwB でのエージェント名を確認するために、switchboard_status を呼び出すようコーディングエージェントに頼んでください。ほかの SwB アプリから、そのエージェントにテストメッセージを送ってください。wait か inbox でメッセージを読むよう、コーディングエージェントに頼んでください。reply で回答するよう頼んでください。

問題を解決する

Claude Code がサインインを求めたら、/mcp を開いて Authenticate を選んでください。設定を変更したら、Codex か Gemini CLI を再起動してください。Gemini CLI では、SwB のアドレスを httpUrl に入れてください。

ペアリング用のキーで 2 台目のパソコンを設定するときは、connect_revoke で 1 つ目のキーを取り消し、もう一度 connect を呼び出してください。

このページの内容