try-works/role-model / .agents/skills/sandbox-sdk
sandbox-sdk
VerifiedBuild sandboxed applications for secure code execution. Load when building AI code execution, code interpreters, CI/CD systems, interactive dev environments, or executing untrusted code. Covers Sandbox SDK lifecycle, commands, files, code interpreter, and preview URLs. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.6 KB |
| references/api-quick-ref.md | markdown | 3.1 KB |
| references/examples.md | markdown | 1.5 KB |
references/api-quick-ref.md
View on GitHub# Sandbox SDK API Reference
Detailed API for `@cloudflare/sandbox`. For full docs: https://developers.cloudflare.com/sandbox/api/
## Lifecycle
```typescript
getSandbox(binding: DurableObjectNamespace<Sandbox>, sandboxId: string, options?: SandboxOptions): Sandbox
interface SandboxOptions {
sleepAfter?: string; // Duration before auto-sleep (default: "10m")
keepAlive?: boolean; // Prevent auto-sleep (default: false)
normalizeId?: boolean; // Lowercase IDs for preview URLs (default: false)
}
await sandbox.destroy(): Promise<void> // Immediately terminate and delete all state
```
## Commands
```typescript
await sandbox.exec(command: string, options?: ExecOptions): Promise<ExecResult>
interface ExecOptions {
cwd?: string; // Working directory
env?: Record<string, string>; // Environment variables
timeout?: number; // Timeout in ms (no default; runs without timeout if unset)
stdin?: string; // Input to command
}
interface ExecResult {
stdout: string;
stderr: string;
exitCode: number;
success: boolean; // exitCode === 0
}
```
## Code Interpreter
```typescript
await sandbox.createCodeContext(options?: CreateContextOptions): Promise<CodeContext>
interface CreateContextOptions {
language?: 'python' | 'javascript' | 'typescript'; // default: 'python'
cwd?: string; // Working directory (default: '/workspace')
envVars?: Record<string, string>;
timeout?: number; // Request timeout in ms (default: 30000)
}
await sandbox.runCode(code: string, options?: RunCodeOptions): Promise<ExecutionResult>
interface RunCodeOptions {
context?: CodeContext; // Reuse context for state persistence
language?: 'python' | 'javascript' | 'typescript';
timeout?: number; // Execution timeout in ms (default: 60000)
}
interface ExecutionResult {
code: string;
logs: { stdout: string[]; stderr: string[] };
results: RichOutput[]; // text, html, png, json, etc.
error?: { name: string; value: string; traceback: string[] };
executionCount: number;
}
```
## Files
```typescript
await sandbox.writeFile(path: string, content: string | Uint8Array): Promise<void>
await sandbox.readFile(path: string): Promise<{ content: string }>
await sandbox.mkdir(path: string, options?: { recursive?: boolean }): Promise<void>
await sandbox.listFiles(path: string): Promise<FileMetadata[]>
await sandbox.deleteFile(path: string): Promise<void>
interface FileMetadata {
name: string;
path: string;
isDirectory: boolean;
size: number;
modifiedAt: string;
}
```
## Ports
```typescript
await sandbox.exposePort(port: number): Promise<{ url: string; token: string }>
await sandbox.unexposePort(port: number): Promise<void>
await sandbox.listPorts(): Promise<PortInfo[]>
```
## Error Handling
Errors include context about the operation:
```typescript
try {
await sandbox.exec('invalid-command');
} catch (error) {
// error.message includes command and sandbox context
}
```
For `runCode()`, check `result.error` instead of catching:
```typescript
const result = await sandbox.runCode('1/0', { language: 'python' });
if (result.error) {
console.error(result.error.name); // "ZeroDivisionError"
}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |