---
title: "Claude Agent SDK integration"
description: "Keep the Claude Agent SDK loop in your own process and run Claude Code itself inside a Promigence sandbox. Anything the agent edits, installs or deletes…"
url: "https://www.promigence.ai/integrations/claude-agent-sdk"
site: "Promigence"
---

# Claude Agent SDK integration

Keep the Claude Agent SDK loop in your own process and run Claude Code itself inside a Promigence sandbox. Anything the agent edits, installs or deletes stays in the sandbox.

The package is `promigence-claude-agent-sdk` on npm, for TypeScript.

## Install

Install it and set your key.

```bash
npm install promigence-claude-agent-sdk @anthropic-ai/claude-agent-sdk promigence
export PROMIGENCE_API_KEY=prom_api_...
promigence secrets set ANTHROPIC_API_KEY --from-env ANTHROPIC_API_KEY
```

## Example

From the guide [Run Claude Agent SDK agents in a Promigence sandbox](https://www.promigence.ai/docs/guides/claude-agent-sdk), which goes on to the spend cap, cleaning up, and what the package does not support.

```ts
import { query } from "@anthropic-ai/claude-agent-sdk";
import { PromigenceClient, Sandbox } from "promigence";
import { spawnInPromigence } from "promigence-claude-agent-sdk";

const client = new PromigenceClient();
const sandbox = await Sandbox.create({ client, timeoutMs: 15 * 60_000, spendCap: 5 });
await sandbox.commands.run("command -v claude || npm install -g @anthropic-ai/claude-code");

try {
  for await (const message of query({
    prompt: "Fix the failing test in src/parser.ts",
    options: {
      pathToClaudeCodeExecutable: "/usr/local/bin/claude",
      spawnClaudeCodeProcess: spawnInPromigence({
        client,
        sandboxId: sandbox.sandboxId,
        cwd: "/workspace",
        secrets: ["ANTHROPIC_API_KEY"],
        onStderr: (text) => process.stderr.write(text),
      }),
    },
  })) {
    if (message.type === "result") console.error(`[${message.subtype}]`);
  }
} finally {
  await sandbox.kill();
}
```

## Next

- [Run Claude Agent SDK agents in a Promigence sandbox](https://www.promigence.ai/docs/guides/claude-agent-sdk)
- [promigence-claude-agent-sdk on npm](https://www.npmjs.com/package/promigence-claude-agent-sdk)
- [All integrations](https://www.promigence.ai/integrations)

