Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Secure sandboxed code execution environments for reproducible research computing
.claude/skills/brycewang-stanford-sandbox-execution-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 84% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 108% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 111% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 85% | 0% |
| case-03 | ✓→✗ | ▼ Worse | 87% | 0% |
A skill for setting up and using sandboxed code execution environments for research computing. Covers containerized execution, security considerations, resource management, and integration with research workflows.
Research code often requires:
dockerfile# Dockerfile for a reproducible research environment FROM python:3.11-slim # System dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ gfortran \ libopenblas-dev \ && rm -rf /var/lib/apt/lists/* # Create non-root user for security RUN useradd -m -s /bin/bash researcher USER researcher WORKDIR /home/researcher # Pin all dependencies COPY requirements.txt . RUN pip install --user --no-cache-dir -r requirements.txt # Copy project files COPY --chown=researcher:researcher . /home/researcher/project WORKDIR /home/researcher/project # Resource limits set at runtime, not build time CMD ["python", "main.py"]
bash# Run with CPU, memory, and time constraints docker run \ --cpus="2.0" \ --memory="4g" \ --memory-swap="4g" \ --pids-limit=100 \ --network=none \ --read-only \ --tmpfs /tmp:size=512m \ --timeout 3600 \ research-sandbox:latest python analysis.py # Mount data as read-only, output directory as writable docker run \ -v /data/raw:/data:ro \ -v /data/results:/output:rw \ --cpus="4.0" \ --memory="16g" \ research-sandbox:latest python pipeline.py
pythonimport subprocess import resource import signal import tempfile import os def run_sandboxed(code: str, timeout: int = 60, max_memory_mb: int = 512) -> dict: """ Execute Python code in a sandboxed subprocess with resource limits. Args: code: Python code string to execute timeout: Maximum execution time in seconds max_memory_mb: Maximum memory in megabytes """ with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f: f.write(code) script_path = f.name try: result = subprocess.run( ['python', '-u', script_path], capture_output=True, text=True, timeout=timeout, env={ 'PATH': '/usr/bin:/usr/local/bin', 'HOME': '/tmp', 'PYTHONDONTWRITEBYTECODE': '1' } ) return { 'stdout': result.stdout, 'stderr': result.stderr, 'returncode': result.returncode, 'timed_out': False } except subprocess.TimeoutExpired: return { 'stdout': '', 'stderr': f'Execution timed out after {timeout}s', 'returncode': -1, 'timed_out': True } finally: os.unlink(script_path) # Example usage result = run_sandboxed(""" import numpy as np data = np.random.randn(1000) print(f"Mean: {data.mean():.4f}") print(f"Std: {data.std():.4f}") """, timeout=30, max_memory_mb=256) print(result['stdout'])
For maximum reproducibility, use Nix to pin every dependency including system libraries:
nix# shell.nix for a research project { pkgs ? import (fetchTarball { url = "https://github.com/NixOS/nixpkgs/archive/nixos-23.11.tar.gz"; }) {} }: pkgs.mkShell { buildInputs = with pkgs; [ python311 python311Packages.numpy python311Packages.scipy python311Packages.pandas python311Packages.matplotlib python311Packages.scikit-learn R rPackages.ggplot2 rPackages.dplyr ]; shellHook = '' echo "Research sandbox activated" echo "Python: $(python --version)" echo "R: $(R --version | head -1)" ''; }
bash# Enter the reproducible environment nix-shell shell.nix # Or use flakes for even better reproducibility nix develop
When running untrusted or third-party code:
--network=none in Docker to prevent data exfiltrationAutomate research pipeline execution with GitHub Actions:
yamlname: Research Pipeline on: push: paths: ['src/**', 'data/**'] jobs: run-analysis: runs-on: ubuntu-latest container: image: research-sandbox:latest options: --cpus 4 --memory 8g steps: - uses: actions/checkout@v4 - run: python src/01_preprocess.py - run: python src/02_analyze.py - run: python src/03_visualize.py - uses: actions/upload-artifact@v4 with: name: results path: output/
This ensures every commit triggers a fresh, sandboxed execution of the full pipeline, catching environment-dependent bugs and ensuring reproducibility.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 16,515 | 17,431 | +6% | 1 | 1 | 0% | 3,001 | 4,124 | +37% | 0 | 0 | — |
case-02 | fail→fail | 12,195 | 7,331 | -40% | 1 | 1 | 0% | 2,531 | 3,057 | +21% | 0 | 0 | — |
case-03 | pass→fail | 9,957 | 7,424 | -25% | 1 | 1 | 0% | 1,577 | 2,955 | +87% | 0 | 0 | — |
case-04 | fail→pass | 8,583 | 6,650 | -23% | 1 | 1 | 0% | 1,540 | 2,832 | +84% | 0 | 0 | — |
case-05 | fail→fail | 16,278 | 15,693 | -4% | 1 | 1 | 0% | 3,060 | 4,392 | +44% | 0 | 0 | — |
case-11 | fail→pass | 5,519 | 3,610 | -35% | 1 | 1 | 0% | 1,046 | 2,174 | +108% | 0 | 0 | — |
case-06 | fail→fail | 12,761 | 12,095 | -5% | 1 | 1 | 0% | 2,659 | 4,030 | +52% | 0 | 0 | — |
case-07 | fail→fail | 22,697 | 18,651 | -18% | 1 | 1 | 0% | 4,195 | 4,812 | +15% | 0 | 0 | — |
case-08 | fail→pass | 7,904 | 8,896 | +13% | 1 | 1 | 0% | 1,652 | 3,486 | +111% | 0 | 0 | — |
case-09 | pass→pass | 9,833 | 8,328 | -15% | 1 | 1 | 0% | 1,851 | 3,090 | +67% | 0 | 0 | — |
case-10 | fail→fail | 11,514 | 11,057 | -4% | 1 | 1 | 0% | 1,738 | 3,254 | +87% | 0 | 0 | — |
case-12 | fail→pass | 12,312 | 9,997 | -19% | 1 | 1 | 0% | 1,687 | 3,117 | +85% | 0 | 0 | — |
case-13 | pass→pass | 13,207 | 9,809 | -26% | 1 | 1 | 0% | 2,390 | 3,428 | +43% | 0 | 0 | — |
case-14 | pass→pass | 7,372 | 6,425 | -13% | 1 | 1 | 0% | 1,402 | 2,731 | +95% | 0 | 0 | — |
case-15 | pass→pass | 2,681 | 2,816 | +5% | 1 | 1 | 0% | 442 | 1,997 | +352% | 0 | 0 | — |
case-16 | pass→pass | 2,574 | 2,290 | -11% | 1 | 1 | 0% | 399 | 1,924 | +382% | 0 | 0 | — |
case-17 | fail→fail | 8,556 | 8,833 | +3% | 1 | 1 | 0% | 1,415 | 2,995 | +112% | 0 | 0 | — |
case-18 | pass→pass | 5,828 | 4,866 | -17% | 1 | 1 | 0% | 948 | 2,377 | +151% | 0 | 0 | — |
case-19 | fail→fail | 9,577 | 7,470 | -22% | 1 | 1 | 0% | 1,443 | 2,601 | +80% | 0 | 0 | — |
case-20 | pass→pass | 2,511 | 4,121 | +64% | 1 | 1 | 0% | 426 | 2,113 | +396% | 0 | 0 | — |
case-21 | pass→pass | 10,469 | 8,934 | -15% | 1 | 1 | 0% | 2,079 | 3,286 | +58% | 0 | 0 | — |
case-22 | pass→pass | 7,189 | 9,243 | +29% | 1 | 1 | 0% | 1,393 | 3,016 | +117% | 0 | 0 | — |
case-23 | pass→pass | 11,419 | 11,811 | +3% | 1 | 1 | 0% | 2,322 | 3,656 | +57% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +13 percentage points is the difference between those two pass rates over the 23 comparable cases. 2 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.