# Run Claude Code in a Daytona Sandbox via CLI (/docs/guides/claude/claude-code-run-cli-sandbox)

This guide walks you through running Claude Code inside a Daytona sandbox using the Daytona CLI.

### Prerequisites [#prerequisites]

- Daytona account and API key (Get it from [Daytona Dashboard](https://app.daytona.com/dashboard/keys))
- Local terminal (macOS, Linux, or Windows)

### Install the Daytona CLI [#install-the-daytona-cli]

<Tabs syncKey="os">
  <TabItem label="Mac/Linux">
    ```bash 
    brew install daytonaio/cli/daytona
    ```
  </TabItem>
  <TabItem label="Windows">
    ```bash
    powershell -Command "irm https://get.daytona.io/windows | iex" 
    ```
  </TabItem>
</Tabs>

<Callout type="note">
Already have the CLI? Check your version with `daytona --version`. If it's below **0.135.0**, [upgrade to the latest version](https://www.daytona.io/docs/cli/).
</Callout>

### Authenticate with Daytona [#authenticate-with-daytona]

Log in to your Daytona account using your API key:

```bash
daytona login --api-key=YOUR_API_KEY
```

Replace `YOUR_API_KEY` with your actual Daytona API key.

### Create a Sandbox [#create-a-sandbox]

Create a new sandbox for running Claude Code:

```bash
daytona sandbox create --name claude-sandbox
```

This creates a sandbox named `claude-sandbox`, visible in your [Dashboard](https://app.daytona.com/dashboard/sandboxes). The default Daytona snapshot includes Claude Code, so the command above is all you need.

<Callout type="tip">
Need more power? Pass `--snapshot daytona-large` or `--snapshot daytona-medium` flag to increase your sandbox resources. See [default snapshots](https://www.daytona.io/docs/snapshots/#default-snapshots) for resource details.
</Callout>

### Connect to the Sandbox [#connect-to-the-sandbox]

SSH into your sandbox:

```bash
daytona ssh claude-sandbox
```

You now have an interactive terminal session inside the sandbox.

### Run Claude Code [#run-claude-code]

Inside the SSH session, start Claude Code:

```bash
claude
```

On first run, Claude Code will prompt you to authenticate:

1. Copy the authentication URL displayed in the terminal
2. Open the URL in your local browser
3. Complete the authentication flow
4. Copy the code provided by the browser
5. Paste the code back into the terminal

Once authenticated, you're all set. Claude Code runs inside the sandbox while you control it from your terminal.
