---
title: Claude Code harness
description: >-
  The Claude Code harness runs Claude Code in the sandbox on an Anthropic API
  key and records its events.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reeval.ai/llms.txt
> Use this file to discover all available pages before exploring further.

`claudeCode()` runs Claude Code in the sandbox. For more information about the sandbox, see [Choose a sandbox](/configuration/sandboxes).

## `ANTHROPIC_API_KEY`

`claudeCode()` reads `ANTHROPIC_API_KEY` from the environment or the `.env.local` file. A run exits with code 2 when the variable is unset, or when the value contains whitespace or a line break.

The gateway swaps the key in only on these requests to `api.anthropic.com`:

- `POST /v1/messages`
- `POST /v1/messages/count_tokens`
- `GET /api/claude_code/settings`
- `GET /api/claude_code/policy_limits`

The gateway answers HTTP 403 when a request carries the key and is not one of those endpoints. A restricted egress policy allows `api.anthropic.com` and `*.anthropic.com`.

When the API rejects the key, the attempt error begins with `The API rejected ANTHROPIC_API_KEY: set a valid key in the environment or .env.local`.

For more information about keeping API keys on the host, see [Keep API keys on the host](/configuration/environments/secrets#keep-api-keys-on-the-host).

For more information about the variable, see [`ANTHROPIC_API_KEY`](/reference/environment-variables#anthropicapikey).

## `claudeCode()`

`claudeCode()` is exported from `{{ pkg }}/harness`. The `reeval.config.ts` file passes it as the `harness` option:

```ts title="reeval.config.ts"
import { defineConfig } from '{{ pkg }}'
import { claudeCode } from '{{ pkg }}/harness'

export default defineConfig({
  harness: claudeCode({
    model: 'claude-sonnet-5',
    effort: 'high',
  }),
})
```

`model` is required. reeval exits with code 2 for a missing `model`, an `effort` outside the allowed values, or an unknown option. For what each field takes, see [Harness factory options](/reference/options#harness-factory-options).



reeval turns `askUserQuestions` off, so Claude Code asks in its reply. reeval sets `IS_SANDBOX` to `1`, so Claude Code skips permission prompts as root. The adapter also sets `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` to `1`, so a turn sends no telemetry, error reports, or feature-flag requests.

For more information about model ids and effort values, see [Set the agent's model](/configuration/agents/model). For rules, skills, MCP servers, usage, served models, and web events, see [Harness behavior](/reference/options#harness-behavior).

## `plugins`

reeval copies the plugins into a generated marketplace named `reeval` and enables each as `<plugin>@reeval` in `~/.claude/settings.json`, merging into a settings file the environment wrote there. Claude Code installs and loads them as it starts, and loads each plugin's MCP servers itself.

[//]: # (generated:harness-plugins:claude-code)

- Takes `skills`, `agents`, `commands`, `hooks` and `mcp`, and refuses a plugin that keeps `rules`: narrow it with `only`, or leave it out of the cell.

[//]: # (/generated:harness-plugins:claude-code)

For more information about plugins, see [Environment helpers reference](/reference/environment-helpers#pluginlocal).
