# Coding agents Point any coding agent at our docs, and run Claude Code in a sandbox, away from your computer. ## Tell your agent to use Foundational Compute Paste this into Claude Code, Cursor or another agent. It reads our docs and asks you before it runs anything. ``` I want to use Foundational Compute (https://fdtn.dev) to run code in cloud sandboxes. Read https://fdtn.dev/llms.txt first, and follow only what it says. Explain each command before you run it, and ask me before you install anything. I will sign in myself with fdtn auth. Never ask me to paste my API key into this chat. ``` To make it permanent, add to `CLAUDE.md` or `AGENTS.md`: (CLAUDE.md): ``` Before you write code that starts a sandbox, read https://fdtn.dev/llms.txt. Use the fdtn command and the fdtn SDK. Never ask for the API key in chat. ``` ## 1. Start Claude Code in a sandbox Install `fdtn` and run `fdtn auth` first ([Quickstart](https://fdtn.dev/docs/quickstart.md)). ```bash $ fdtn claude Starting a sandbox with Claude Code Opening Claude Code in sandbox i... ``` The CLI starts a `claude` sandbox on our machines with private ports, copies `ANTHROPIC_API_KEY` in if set, and opens Claude Code. When you leave, it kills the sandbox. In a script, use `fdtn create claude -d` with `fdtn exec`, or an SDK. ## 2. Keep the sandbox after you leave | (none) | Stops when you leave or close the terminal | |---|---| | `--keep` | Runs 1 hour after you leave | | `--keep --timeout ` | Runs that long after you leave (30 to 86,400) | ```bash $ fdtn claude --keep --timeout 7200 $ fdtn connect # later: a shell in the same sandbox; type claude $ fdtn kill ``` ## Your key or your sign-in - **Anthropic API key:** `export ANTHROPIC_API_KEY=sk-ant-...` first. It goes only into the sandbox environment, never a command line or log. Anthropic bills the model. - **Claude sign-in:** without the key, sign in from Claude Code in the sandbox. The sign-in ends with the sandbox. A key or sign-in lives in sandbox memory, so the `claude` template runs only on machines we own. To keep the key out of the sandbox, save it once and run `fdtn claude --secret anthropic`. [Secrets](https://fdtn.dev/docs/secrets.md) ## The claude template | Size | 2 vCPU, 2 GiB, 20 GiB disk: $0.048 an hour | |---|---| | Installed | Debian, Claude Code, Node.js 24, npm, Python 3, pip (no venv needed), git, curl, ripgrep | ## Run Claude Code from code Give Claude Code one task in print mode (`claude -p`) and read the result. Set the command timeout and the lifetime longer than the task. Python (agent.py): ```python import os from fdtn import Sandbox sbx = Sandbox.create( "claude", timeout=1800, # the sandbox lives 30 minutes request_timeout=300, # wait up to 5 minutes for the start envs={"ANTHROPIC_API_KEY": os.environ["ANTHROPIC_API_KEY"]}, ) try: sbx.files.write("/home/user/app/README.md", "# Demo\n") result = sbx.commands.run( "cd /home/user/app && claude -p 'Add a hello.py that prints hello, then run it.'", timeout=600, # this command may run 10 minutes ) print(result.stdout) print(sbx.files.read("/home/user/app/hello.py")) finally: sbx.kill() ``` TypeScript (agent.mjs): ```typescript import { Sandbox } from '@fdtn/sdk' const sbx = await Sandbox.create('claude', { timeoutMs: 1_800_000, // the sandbox lives 30 minutes requestTimeoutMs: 300_000, // wait up to 5 minutes for the start envs: { ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY }, }) try { await sbx.files.write('/home/user/app/README.md', '# Demo\n') const result = await sbx.commands.run( "cd /home/user/app && claude -p 'Add a hello.py that prints hello, then run it.'", { timeoutMs: 600_000 }, // this command may run 10 minutes ) console.log(result.stdout) console.log(await sbx.files.read('/home/user/app/hello.py')) } finally { await sbx.kill() } ``` ## Other coding agents Ready templates exist for `codex` and `opencode`, also in larger sizes ([Templates](https://fdtn.dev/docs/templates.md)). For another agent, build a template that installs it. Pass its key with `-e` (CLI) or `envs` (SDK). [Templates](https://fdtn.dev/docs/templates.md) ## Next - [**Security**: Where sandboxes run.](https://fdtn.dev/docs/security.md) - [**Parallel work**: Run many agents at once.](https://fdtn.dev/docs/parallel.md) - [**Files**: Move code in, results out.](https://fdtn.dev/docs/files.md) - [**llms.txt**: Docs for your coding agent.](https://fdtn.dev/llms.txt) Source: https://fdtn.dev/docs/coding-agents/