code-sandbox

code-sandbox is a skill for Claude Code, Codex from malue-ai/dazee-small. It costs 34 tokens per session (1,500 once invoked), scanned A, original, MIT.

A guide for running AI-generated or untrusted scripts in an isolated environment. A sandbox is a separate execution area that limits the script’s impact on the main computer.

In plain words
What is it for?
Executing Python or JavaScript, analyzing CSV files, creating charts, testing scripts, trying extra dependencies, and running crawlers or API calls in Docker or E2B.
Why use it?
It reduces the risk of damaging the user’s system or cluttering the main environment when code needs to run, install dependencies, or access files.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/malue-ai/dazee-small/code-sandbox
Any agent
npx skills add malue-ai/dazee-small --skill code-sandbox
Clone the repo
git clone --depth 1 https://github.com/malue-ai/dazee-small

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for code-sandbox

README.md
[![agentmods](https://agentmods.dev/badge/skills/malue-ai/dazee-small/code-sandbox.svg)](https://agentmods.dev/skills/malue-ai/dazee-small/code-sandbox)
Your own site
<a href="https://agentmods.dev/skills/malue-ai/dazee-small/code-sandbox"><img src="https://agentmods.dev/badge/skills/malue-ai/dazee-small/code-sandbox.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,500 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00034 $0.01500
Opus 5 $0.00017 $0.00750
Sonnet 5 $0.00007 $0.00300
Haiku 4.5 $0.00003 $0.00150

Measured 3d ago against content hash 6df415066e9a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

code-sandbox scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

stdout=asyncio.subprocess.PIPE,
instances/xiaodazi/skills/code-sandbox/SKILL.md · 184 lines

How it starts

The opening of the file, as written. The whole thing — 184 lines — stays where its author put it; the contents beside it link to each section on GitHub.

安全代码沙箱

在隔离的沙箱环境中执行 AI 生成的代码,保护用户系统安全。支持 Docker 本地沙箱(免费)和 E2B 云沙箱两种模式。

使用场景

  • 用户说「帮我写个脚本分析这个 CSV 文件」→ 在沙箱中执行,不污染主系统
  • 用户说「帮我画个图表」→ matplotlib 在沙箱中运行,输出图片文件
  • 用户说「运行一下这段代码看看结果」→ 安全隔离执行
  • 数据分析、原型验证、临时脚本等不适合在主系统直接执行的场景
  • 执行来历不明或复杂度高的代码片段

何时使用此 Skill(而非直接 system.run)

判断逻辑:

需要执行代码
  ├── 简单系统命令(ls, git, pip 等) → 直接 system.run
  ├── 用户提供的完整脚本 → code-sandbox ✅ 更安全
  ├── AI 生成的分析/处理代码 → code-sandbox ✅ 推荐
  ├── 需要安装额外依赖的代码 → code-sandbox ✅ 不污染主环境
  └── 需要网络访问的爬虫/API 调用 → code-sandbox ✅ 隔离风险

前置条件(二选一)

方式一:Docker 本地沙箱(推荐,免费)

  1. 安装 Docker:https://www.docker.com/get-started
  2. 确保 Docker 正在运行:docker info
  3. 无需额外配置,首次使用时自动拉取基础镜像

方式二:E2B 云沙箱

  1. 注册 E2B 账号:https://e2b.dev/
  2. 设置环境变量:export E2B_API_KEY="your-key"
  3. 提供免费额度,适合不想装 Docker 的用户

执行方式

Docker 本地沙箱模式

执行 Python 脚本
import asyncio
import tempfile
import os

async def run_in_sandbox(code: str, files: dict = None, timeout: int = 60):
    """在 Docker 沙箱中执行 Python 代码"""

    # 创建临时工作目录
    work_dir = tempfile.mkdtemp(prefix="sandbox_")

    # 写入用户代码
    script_path = os.path.join(work_dir, "script.py")
    with open(script_path, "w") as f:
        f.write(code)

    # 如果有输入文件,复制到工作目录
    if files:
        for name, content in files.items():
            fpath = os.path.join(work_dir, name)
            if isinstance(content, bytes):
                with open(fpath, "wb") as f:
                    f.write(content)
            else:
                with open(fpath, "w") as f:
                    f.write(content)

    # Docker 执行命令
    cmd = [
        "docker", "run", "--rm",
        "--network=none",               # 默认禁用网络(需要时可开启)
        "--memory=512m",                 # 内存限制
        "--cpus=1.0",                    # CPU 限制
        "-v", f"{work_dir}:/workspace",  # 挂载工作目录
        "-w", "/workspace",
        "python:3.12-slim",
        "python", "script.py"
    ]

    proc = await asyncio.create_subprocess_exec(
        *cmd,
        stdout=asyncio.subprocess.PIPE,
        stderr=asyncio.subprocess.PIPE,
    )
    stdout, stderr = await asyncio.wait_for(
        proc.communicate(), timeout=timeout
    )

    return {
        "success": proc.returncode == 0,
        "stdout": stdout.decode(),
        "stderr": stderr.decode(),
        "output_dir": work_dir,  # 检查输出文件
    }

Read the full file on GitHub · 184 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 184 lines · 34 tokens per session scan A 6df415066e9a

Subscribe to this mod's changes

code-sandbox is a skill published in the GitHub repository malue-ai/dazee-small (36 stars, last pushed 5mo ago), licensed MIT. It adds 34 tokens to every session and 1,500 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

obra/superpowers · 37 tokens

auto-perf-optimize

Run agent-driven VS Code performance or memory investigations. Use when asked to launch Code OSS, automate a VS Code scenario, run the Chat memory smoke runner, capture renderer heap snapshots, take workflow screenshots, compare run summaries, or drive a repeatable scenario before heap-snapshot analysis.

microsoft/vscode · 62 tokens

chat-perf

Run chat perf benchmarks and memory leak checks against the local dev build or any published VS Code version. Use when investigating chat rendering regressions, validating perf-sensitive changes to chat UI, or checking for memory leaks in the chat response pipeline.

microsoft/vscode · 51 tokens

chat-pet-sprite-creation

Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.

microsoft/vscode · 53 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens