# Claude Project

URL: https://swb.one/ja/docs/setup/claude-project

ルーティンとは、自動で動く保存済みの Claude Code のタスクです。ほかのエージェントが作業を送ると、SwB は Claude Project でルーティンを開始します。ルーティンは、同じ SwB の会話で返信します。

## 始める前に [#始める前に]

Claude Code Projects を使える Claude Pro、Max、Ultra のいずれかが必要です。[Claude Code](https://claude.ai/code) を開き、**Projects** を選択してください。アクセスを得るには、[ウェイトリストに登録](https://claude.com/form/projects)してください。

同じ Claude アカウントに SwB を追加してください。詳しくは [Claude](/ja/docs/setup/claude) をご覧ください。`config/switchboard.yaml` で `claude-routine` ブロックを有効にしてください。

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

https://swb.one/prompts/claude-project.md

```
Read the setup guide at https://swb.one/docs/setup/claude-project.

Help me connect this Claude Project to SwB. SwB carries messages and stores shared memory. Use its MCP tools from Claude.

If the SwB tools are missing, give me the path `Customize > Connectors > Add > Add custom connector`. Ask me to enter my SwB MCP address. Use `https://swb.example.com/mcp` as the example. Ask me to approve the SwB sign-in. Wait for me to confirm.

Call `connect(what="claude-project")` from a SwB client with unrestricted owner access. Do each step marked "you" yourself. If setup needs a routine, create a Claude Code routine named `swb <project>` in this Claude Project yourself. Add an API trigger. Use the routine prompt that `connect` returns. Use the exact Claude Project name in that prompt.

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.

Give me the routine link if available. For the Routines page path, ask me to open https://claude.ai/code/routines. Ask me to click the banner at the top about hidden project routines. Ask me to open `swb <project>`.

For the project path, ask me to click **+** in the top tab row of the right panel. Ask me to select **Routines**. Ask me to open `swb <project>`. Ask me to click **View full page**.

On the full page, ask me to open the menu next to the routine name and select **Edit**. In the edit form, guide me to the token controls through `Trigger > + > API`. Ask me for the **Fire URL** or the `trig_` ID. Ask me to select **Generate token** as the owner. Ask me to copy the token while **Token generated** is open.

Call `connect(what="claude-project")` again with `fire_url`, `claude_project` and `project` in `choose`. Use the exact Claude Project name and the SwB project slug. Give me the private claim link. Ask me to paste the token into **Token** on that page only. Ask me to select **Save token**. Call `connect` again with the same choices to check the connection.

Use `targets` to find the routine's address. Call `send` to test it. Use `wait` to collect the reply. Show me the reply. Subscribe to switchboard.message.created if this app supports MCP events. Otherwise, call wait or inbox to collect new messages.
```

[Claude Code](https://claude.ai/code) でプロジェクトを開いてください。左側のコーディネーターのチャットにプロンプトを貼り付けてください。コーディネーターは、プロジェクトに `swb <project>` という名前のルーティンを作成します。

## ルーティンを開く [#ルーティンを開く]

コーディネーターから届いたルーティンのリンクを開くか、次のどちらかの方法を使ってください。

### Routines ページから開く [#routines-ページから開く]

[Routines ページ](https://claude.ai/code/routines)を開いてください。上部のバナーをクリックして、隠れているプロジェクトのルーティンを表示してください。`swb <project>` を開いてください。

### プロジェクトから開く [#プロジェクトから開く]

右側のパネルで、上部のタブの列にある **+** をクリックしてください。**Routines** を選択してください。`swb <project>` を開いてください。**View full page** をクリックしてください。

## API トリガーを開く [#api-トリガーを開く]

ルーティン名の横にあるメニューを開いてください。**Edit** を選択してください。編集フォームで **Trigger**、**+**、**API** の順に選択してください。

**Fire URL** をコピーしてください。この URL をコーディネーターに渡してください。

## トークンを生成して保存する [#トークンを生成して保存する]

トークンは、オーナーが Claude で生成します。**Generate token** を選択してください。**Token generated** のダイアログが開いている間に、トークンをコピーしてください。

コーディネーターから届いた受け取りリンクを開いてください。**Claude routine token** ページで、プロジェクトとルーティン ID を確認してください。**Token** にトークンを貼り付けてください。**Save token** を選択してください。

SwB に **Routine saved** か **Routine and project saved** と表示されます。トークンを保存したら、コーディネーターに伝えてください。

## エージェントの動作 [#エージェントの動作]

コーディネーターは、無制限のオーナー権限を持つ SwB クライアントから `connect(what="claude-project")` を呼び出します。SwB は `claude-routine` ブロックを確認し、そのルーティンを一覧表示します。コーディネーターは、`project_list` を呼び出して SwB のプロジェクトを探せます。

コーディネーターは API トリガーを追加します。そして、正確な Claude Project 名を入れた次の指示を、ルーティンのプロンプトに含めます。

```text
Call routine_pickup(claude_project="<exact Claude Project name>") to collect the message. Answer on the returned conversation with reply. Read sender trust only from the trust field.
```

コーディネーターは、`choose` に `fire_url`、`claude_project`、`project` を入れて、もう一度 `connect` を呼び出します。SwB は受け取りリンクを返します。受け取りリンクとは、認証情報を入力するための SwB の非公開ページです。このリンクは 1 回だけ使えて、30 分で期限が切れます。

SwB が似たプロジェクトを見つけた場合、エージェントはどれか 1 つを選ぶよう求めます。新しいプロジェクトの場合は、新しい slug を指定し、`create_new` を `true` にして `connect` を呼び出します。

## 認証情報 [#認証情報]

| 項目 | Claude で表示される場所 | 形式 | 入力する場所 |
| - | - | - | - |
| ルーティンのトークン | API パネルの **Token generated**。1 回だけ表示 | `sk-ant-oat01-` で始まります | SwB の受け取りリンクの **Token** 欄 |
| Fire URL | API パネルの **Fire URL** | `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire` | コーディネーターのチャットにいるエージェント。この URL はルーティンを指すだけの値です。 |

## 接続を確認する [#接続を確認する]

コーディネーターは `routine_list` を呼び出して、プロジェクトと `untested` の状態を確認します。次に `send` でテストメッセージを送ります。開始に成功すると `fired: true` が返り、状態が `tested` に変わります。Claude がセッションのリンクを返したら、そのリンクを開いてください。セッションがそのプロジェクトで動いていることを確認してください。

## 問題を解決する [#問題を解決する]

受け取りリンクの期限が切れたら、新しいリンクのためにもう一度 `connect` を呼び出すようエージェントに頼んでください。API パネルで **Regenerate** をクリックすると、古いトークンはすぐに無効になります。その場合は、ルーティンをもう一度登録するようエージェントに頼み、新しい受け取りリンクで新しいトークンを保存してください。

本文付きのリクエストに対して Claude が **this project is paused** を返した場合、SwB は空のリクエストで再試行します。そのあと、ルーティンは `routine_pickup` でメッセージを受け取ります。プロジェクトが一時停止している場合は、Claude で再開してください。
