# Connect your agent

> Connect Claude Code or Codex to Castle with one press, or with one command. Restart the agent, check the connection, and what to do if it is not found.

By the end of this page Claude Code or Codex will be connected to Castle, and ready to ask for devices.

You need Claude Code or Codex installed and signed in. Castle works with both by name. [Agents that work with Castle](https://castle.cx/docs/agents/agents-that-work-with-castle.md) covers other agent apps.

## In the app

1. Open the **Connect Your Agent** sheet. On the first window, press the button on the agent door. Any time later, open Settings › Agents and press **Connect…** under **Connect your agent**.
2. Castle tells you which agent apps it found on your Mac, for example Claude Code. **Use another agent** switches to another one.
3. Press **Connect Claude Code** (or Codex). To see what changes first, press **Show what changes**. Castle adds its tools and a short guide to the agent, and a `castle` command to your terminal. You can remove them in Settings.
4. Restart the agent if it is open.

<figure class="doc-shot" style="max-width:561px"><img class="ld" src="https://castle.cx/assets/docs/docs-connect-light.webp" width="1122" height="532" loading="lazy" alt="The lower part of the Connect Your Agent sheet: Claude Code is on this Mac, Show what changes, Use another agent, Other agent app? Copy a prompt for it, and the buttons Not Now and Connect Claude Code"><img class="ln" src="https://castle.cx/assets/docs/docs-connect-dark.webp" width="1122" height="532" loading="lazy" alt="The lower part of the Connect Your Agent sheet: Claude Code is on this Mac, Show what changes, Use another agent, Other agent app? Copy a prompt for it, and the buttons Not Now and Connect Claude Code, in the dark appearance"><figcaption>The Connect Your Agent sheet, lower part. From Castle’s design prototype. The finished app may look different.</figcaption></figure>

If Castle does not find your agent, it says so: install it, then press **Check Again**. If the agent is not signed in yet, sign in to it first.

## Or with a command

In Terminal:

```
castle integrate claude
castle integrate codex
```

Then restart the agent. [The castle command](https://castle.cx/docs/command-line/the-castle-command.md) has more. Connecting gives your agent a short Castle skill, and a guide for each system and each job, which it reads only when a job needs it.

## Check that it worked

- In Settings › Agents, the agent shows **Added**, with a **Remove** button beside it.
- In Terminal, `castle integrate` with no name lists each agent app it finds and whether Castle is connected.
- `castle agents` shows whether agents may use your devices.

> [!NOTE]
> **Two things decide if an agent may use a device.** **Allow agents** is a switch in Settings › Agents, and each device has its own level in its Settings › Agents. If an agent is told that agents are off, check them. [What agents may do](https://castle.cx/docs/agents/what-agents-may-do.md) has the detail.

If your agent cannot see Castle, see [Claude Code or Codex is not connected](https://castle.cx/docs/help/agent-is-not-connected.md).

## Another agent app

An agent app that can use MCP or a command line can use Castle too. The Connect sheet has **Other agent app? Copy a prompt for it.**, and Settings › Agents has the same.

## Remove it

Press **Remove** beside the agent in Settings › Agents.

## Next

[Your agent's first task](https://castle.cx/docs/get-started/your-agents-first-task.md).

---
Section: Get started · Last updated: 2026-11-20 · Source: https://castle.cx/docs/get-started/connect-your-agent
