# Claude

URL: https://swb.one/docs/blocks/claude

## Add the connector [#add-the-connector]

Follow [Claude setup](/docs/setup/claude) to add your SwB MCP address as a custom connector. Turn on the connector in your Project or chat. Claude signs in with OAuth as `claude`.

## Connect a Claude Project [#connect-a-claude-project]

Paste the [Claude Project setup prompt](/docs/setup/claude-project) into a chat in the Project.

The agent finds the SwB project and sets up a routine with an API trigger. It calls `connect` to get a single-use claim link that expires after 30 minutes. Open the link. Paste the routine token into the form. Save the token. The agent sends a test message and checks the reply.

## Routines [#routines]

A **routine** is a Claude Code task that SwB can start. SwB also leaves the message in Claude's mailbox. The routine uses `reply` to answer the sender.

| Send to | Destination |
| - | - |
| `claude` with `project=<slug>` | The main routine of the project |
| `claude:<slug>` | The main routine of the project |
| `<routine name>` | That routine |
| `agent:claude` | The mailbox only |

A project can have many routines. By default, SwB selects the first routine for that agent and project. Set `primary=true` when you register a routine to select it first.

If Claude reports a paused project, SwB tries again with an empty request. The routine reads the message with `routine_pickup`.

## Config [#config]

```yaml
blocks:
  claude-routine:
    routines:
      claude: {routine_id: trig_..., token_env: SWB_EXAMPLE_CLAUDE_TOKEN, agent: claude}
```

For manual setup, set `token_env` to a variable that holds the routine token. The example uses `SWB_EXAMPLE_CLAUDE_TOKEN`.

| Key | Use |
| - | - |
| `blocks.claude-routine` | Settings for waking Claude Code routines |
| `blocks.claude-routine.use` | Block type. Use `claude-routine` |
| `blocks.claude-routine.enabled` | Set `false` to skip this block |
| `blocks.claude-routine.routines` | Map from routine names to settings |
| `blocks.claude-routine.routines.*.agent` | Agent that receives the message. Default `claude` |
| `blocks.claude-routine.routines.*.kind` | Use `project` for a routine with a project. Use `general` for a general routine |
| `blocks.claude-routine.routines.*.project` | SwB project name for a project routine |
| `blocks.claude-routine.routines.*.name` | Display name for the routine |
| `blocks.claude-routine.routines.*.primary` | Set `true` to choose this routine first for its agent and project |
| `blocks.claude-routine.routines.*.routine_id` | Claude API trigger ID, such as `trig_...` |
| `blocks.claude-routine.routines.*.slugs` | Extra short names you can send to |
| `blocks.claude-routine.routines.*.token_env` | Name of the variable that holds the routine token |
