> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runagain.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Agent SDK

> Wrap a Claude Agent SDK harness with RunAgain tracing.

Trace an agent built on `@anthropic-ai/claude-agent-sdk` by wrapping it with
`trace()` from `runagain`. Every run, tool call, token and cost is streamed to
your project.

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm i runagain @anthropic-ai/claude-agent-sdk
  ```

  ```bash pnpm theme={null}
  pnpm add runagain @anthropic-ai/claude-agent-sdk
  ```

  ```bash yarn theme={null}
  yarn add runagain @anthropic-ai/claude-agent-sdk
  ```

  ```bash bun theme={null}
  bun add runagain @anthropic-ai/claude-agent-sdk
  ```
</CodeGroup>

## Configure

```bash .env.local theme={null}
RUNAGAIN_API_KEY=sk_…
RUNAGAIN_INGEST_URL=https://ingest.runagain.ai
```

## Wrap your agent

```ts agent.ts theme={null}
import { query } from "@anthropic-ai/claude-agent-sdk";
import { trace } from "runagain";

// trace() streams every run, tool call, token and cost to RunAgain.
export const runAgent = trace(
  (prompt: string) =>
    query({ prompt, options: { model: "claude-opus-4-8", maxTurns: 5 } }),
  { name: "support-bot" },
);
```

## Run

```bash theme={null}
npx runagain eval --watch --loops 5
```

Open your project's [Traces](/app/traces) page to see the runs stream in.

<Tip>
  Prefer to let your coding agent wire this up? Paste this into Claude Code or
  Cursor: *"Integrate RunAgain into this Claude Agent SDK project — install
  `runagain`, wrap my `query()` calls with `trace()`, and read
  `RUNAGAIN_API_KEY`/`RUNAGAIN_INGEST_URL` from env. Keep my agent logic
  unchanged."*
</Tip>
