---
url: /harnesses/claude-code.md
---
# Claude Code

With Claude Code installed and signed in, `pandra run` needs no other setup:

```sh
pandra run github.com/acme/agents/reviewer --harness claude-code \
    --prompt "Review the uncommitted changes."
```

* **Settings.** Keys of Claude Code's `settings.json` go under `[harnesses.claude-code.settings]`; Pandra refuses the keys it sets itself, with the reason ([harness programs and runners](/configure/targets.md#harness-programs-and-runners)).
* **Permissions.** Runs use Claude Code's automatic permission review. Claude Code refuses to skip permission checks as root ([running as root](/harnesses/permissions.md#running-as-root)).

How Claude Code differs from the other harnesses is in the [comparison](/harnesses/choosing.md#how-the-harnesses-differ).

## Login

Pandra reuses Claude Code's own login and its API key and token environment variables. A [target's credential](/configure/targets.md#target-credentials) can supply a login instead, with the provider `anthropic`:

| `--login` | Variable | Value |
| --- | --- | --- |
| `api-key` | `ANTHROPIC_API_KEY` | an Anthropic API key |
| `subscription` | `CLAUDE_CODE_OAUTH_TOKEN` | a subscription token from `claude setup-token` |
| `gateway` | `ANTHROPIC_AUTH_TOKEN`, with `--base-url URL` written as `ANTHROPIC_BASE_URL` | an LLM gateway's token |

An `ANTHROPIC_BASE_URL` that only your shell sets is removed from a run whose target has a credential, so set a proxy or gateway URL on the target: `pandra config set --target NAME env.ANTHROPIC_BASE_URL URL`.

## Harness features

A target's `harness-features` lets a run reach these, which are off unless listed ([targets](/configure/targets.md#targets)):

| Feature | Lets the run reach |
| --- | --- |
| `other-sessions` | other sessions on this machine, through its `ListAgents` and `SendMessage` tools |
| `account-connectors` | the connectors of your claude.ai account, such as Gmail or Slack |
| `account-skills` | the skills synchronized from your claude.ai account |
| `user-browser` | your Chrome browser, with the sites you are signed in to, through Claude in Chrome |

## MCP servers

Claude Code expands `${NAME}` in a server's arguments, environment variables, and header values itself, so a value that is not secret and contains `${` cannot reach the server as written. Such a value stops the run before Claude Code starts, with `mcp_value_unsupported`, and `pandra run --dry-run` shows it. With `secret-proxy = false`, a secret header value that contains `${` stops the run too.

With `secret-proxy = false` ([harness programs and runners](/configure/targets.md#harness-programs-and-runners)), Claude Code gets the real secret values and follows redirects by its own rules. When a remote server redirects it to another origin, it drops only `Authorization`, so the server's other secret headers reach that origin.

## Instructions

When you [add the instructions your harness reads](/configure/instructions-and-skills.md#add-the-instructions-your-harness-reads), a Claude Code run gets these files:

* `home`: `CLAUDE.md` and the files of `rules/` in `~/.claude`, or in `$CLAUDE_CONFIG_DIR`.
* `repo`, in each directory from the repository's root down to the workspace: `CLAUDE.md`, `.claude/CLAUDE.md`, `CLAUDE.local.md`, the files of `.claude/rules/`, `AGENTS.md`, and `.claude/AGENTS.md`.

Claude Code's `@path` imports are not expanded, and a rule file with `paths` in its front matter is left out. Claude Code reads no `~/.agents/skills/`, so `skill-sources = ["home"]` gives a run nothing, and its dry run says `not supported by claude-code`.

With `instructions-mode = "replace"` ([settings of one agent](/configure/agent-settings.md#settings-of-one-agent)), the agent's instructions take the place of Claude Code's guidance on its tools and its safety instructions.

A resumed conversation keeps the instructions of its first launch until Claude Code compacts it, so an edit to an instructions file reaches it only after a compaction.

## Background work

In a headless run, the agent can start subagents, Bash commands, and Monitor watches in the background and end its turn. Claude Code takes another turn by itself when such work ends, and Pandra waits for those turns: the progress line says `waiting for background work`. The run's answer is the result of its last turn, and the earlier turns stay in the session's log ([see what an agent did](/run/workspaces.md#see-what-an-agent-did)).

The wait stops after 10 minutes without a turn. Pandra then stops the agent and its background work, prints the answer so far, and warns with `background_work_stopped`. The run still ends `completed` with exit code 0, so only the warning shows that the results of the stopped work are missing. A Bash command or Monitor watch that the main conversation started keeps the run going past the limit until it ends.

* With `--output-schema`, the answer is the latest one that matches the schema, so a later plain-text answer does not replace it.
* Ctrl-C or `pandra session stop` during the wait stops the agent and its background work, and the run ends `interrupted` with exit code 130.
* Runs that an agent starts, guild and quest runs, and detached runs wait the same way. An agent's run also waits, without a limit, for a run it started with `--detach` ([running several agents at once](/automate/ai-agents.md#running-several-agents-at-once)).
