# Use Prized from your coding agent

> Teach Claude Code, Codex, Cursor, or another coding agent to run code in Prized sandboxes: install the Prized skill, or paste a short section into AGENTS.md.

URL: https://prized.dev/docs/sandboxes-coding-agents

With the skill, your agent runs untrusted or heavy code in a [sandbox](https://prized.dev/docs/sandboxes) instead of on your machine. It loads only when a task calls for it.

## 1. Export an API key [#1-export-an-api-key]

Make a key with **Sandboxes: Write** on the [API keys page](https://prized.dev/dashboard/workspace/api-keys), and export it in the shell you start the agent from. New to Prized? [Open Sandboxes](https://prized.dev/onboarding/sandboxes) signs you up with free credit, no card.

```bash
export PRIZED_API_KEY=dcp_…
```

## 2. Install the skill [#2-install-the-skill]

**Any agent**

```bash
npx skills add https://prized.dev
```

**Claude Code**

```bash
mkdir -p ~/.claude/skills/prized-sandboxes && curl -fsSL https://prized.dev/skills/prized-sandboxes.tar.gz | tar -xz -C ~/.claude/skills/prized-sandboxes
```

**Codex**

```bash
mkdir -p ~/.agents/skills/prized-sandboxes && curl -fsSL https://prized.dev/skills/prized-sandboxes.tar.gz | tar -xz -C ~/.agents/skills/prized-sandboxes
```

`npx skills add` asks which agents get it (Claude Code, Codex, Cursor, and others) and installs it in the current project; add `-g` for every project. The other tabs install it for your user; for one repo, unpack it into the repo's `.claude/skills/` or `.agents/skills/` instead. The skill is [/SKILL.md](https://prized.dev/SKILL.md), with a standard-library Python helper beside it.

## 3. Try it [#3-try-it]

Start the agent in a new session and ask:

```text title="Prompt"
Run python3 --version in a Prized sandbox.
```

It creates a sandbox, prints `Python 3.12.3`, and deletes the sandbox.

## Add it to AGENTS.md [#add-it-to-agentsmd]

To make sandboxes the rule in a repo, for every agent that works there, paste this section into its `AGENTS.md`. Claude Code reads `CLAUDE.md`, so add the line `@AGENTS.md` to that file.

```markdown title="AGENTS.md"
## Running code in sandboxes (Prized)

Run untrusted, model-generated or heavy code in a Prized sandbox, never on this machine or the API server.

- Key: `PRIZED_API_KEY` (starts with `dcp_`) from the environment. Never commit it or put it in a command line. Missing? Ask the user to make one at https://prized.dev/dashboard/workspace/api-keys.
- Shell: `ID=$(prized sandbox create --max-runtime 30m)`, then `prized sandbox exec "$ID" -- <command>`, `prized sandbox cp ./file "$ID:file"` (one file; tar a directory first), and `prized sandbox rm "$ID" -y`.
- Code: no SDK package. Plain HTTPS with `Authorization: Bearer $PRIZED_API_KEY`:
  1. `POST https://api.prized.dev/api/v1/sandboxes?wait=running` with `{"template":"prized-base-v1","maxRuntimeMin":30}` returns `{"sandbox":{"id","state","toolboxBase"}}`. While `state` is `starting`, poll `GET /api/v1/sandboxes/{id}`.
  2. `POST {toolboxBase}/process/execute` with `{"command":"python3 main.py","cwd":"/home/prized/work","timeout":300}` returns `{"stdout","stderr","exitCode"}`. Send `{"command":"true"}` first and retry it on 409, 502 or 503. A failed command still returns 200: check `exitCode`.
  3. `POST {toolboxBase}/files/upload?path=/home/prized/work/main.py` with the raw bytes; `GET {toolboxBase}/files/download?path=...`.
  4. `DELETE https://api.prized.dev/api/v1/sandboxes/{id}` in a `finally`.
- Use `toolboxBase` from the response, never a URL you build. Stdlib Python and TypeScript helpers: https://prized.dev/docs/sandboxes-python-typescript.md. Everything else: https://prized.dev/llms.txt
```
