— No reviews yet
0 installs
14 views
0.0% view→install
Install
$ agentstack add skill-jamesrobmccall-modal-skills-modal-sandbox ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Are you the author of Modal Sandbox? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claimAbout
Modal Sandbox
Quick Start
- Verify prerequisites before doing any work.
modal --version
python -c "import modal,sys; print(modal.__version__); print(sys.executable)"
- Do not assume the default
pythonorpython3interpreter can importmodaljust because themodalCLI exists. - Use the interpreter from the active Modal environment, project venv, or the environment behind the installed CLI.
- Do not look for a
modal sandboxsubcommand. Usemodal shellfor direct access andmodal container ...only for generic container inspection. - Wrap sandbox creation in
with modal.enable_output():when you want local image-build and provisioning logs. - Set
verbose=TrueonSandbox.create(...)when you want sandbox operation logs to show up in Modal logs and local output.
- Create an App before creating a sandbox from outside Modal.
import modal
app = modal.App.lookup("my-sandbox-app", create_if_missing=True)
sandbox = modal.Sandbox.create("sh", "-lc", "sleep 300", app=app)
- Choose the workflow that matches the task before writing code.
- One-shot command execution and output capture: use
Sandbox.exec(...). - A conversational or stateful controller loop: keep one long-lived sandbox alive.
- HTTP or TCP service exposure: use tunnels.
- Restore or persistence flows: use Volumes, CloudBucketMounts, or snapshots.
Choose the Workflow
- Use one-shot
Sandbox.exec(...)for isolated commands and output capture when the sandbox does not need to preserve conversational state across requests. Read [references/lifecycle-and-exec.md](references/lifecycle-and-exec.md). - Use a long-lived controller loop when the sandbox must keep state across requests or support repeated
stdinandstdoutinteraction. Read [references/example-patterns.md](references/example-patterns.md). - Use tunnels when the sandbox must expose HTTP or TCP services and the client needs a public or restricted URL. Read [references/networking-and-tunnels.md](references/networking-and-tunnels.md).
- Use Volumes or CloudBucketMounts for persisted or shared files, and use snapshots only for explicit restore flows. Read [references/files-and-persistence.md](references/files-and-persistence.md) and [references/snapshots.md](references/snapshots.md).
- Reattach to a live sandbox with
Sandbox.from_id(...)orSandbox.from_name(...)instead of creating duplicates.
Default Rules
- Create and control sandboxes through the Python SDK. Use
modal.App.lookup(..., create_if_missing=True)beforemodal.Sandbox.create(...)when provisioning from local code. - Set lifecycle limits deliberately. Treat the default sandbox lifetime as 5 minutes, raise
timeoutup to 24 hours when needed, and setidle_timeoutwhen inactivity should shut the sandbox down. - Reattach with
Sandbox.from_id(...)orSandbox.from_name(...)instead of creating duplicates. Name sandboxes only when you truly need a singleton on a deployed app. - Use
Sandbox.exec(...)as the default execution primitive. Readstdoutandstderrfrom the returnedContainerProcess, usebufsize=1for line-oriented loops, and setpty=Trueonly for commands that genuinely need a TTY. - Keep one long-lived controller process when the task needs conversational state or repeated back-and-forth over
stdinandstdout. - Open only the ports the task actually needs. Poll
sandbox.tunnels()for readiness, and useblock_network=True,cidr_allowlist=[...], orcreate_connect_token()when the service should be restricted. - Bake static inputs into the image at build time, and use Volumes or CloudBucketMounts for files that must outlive one sandbox or be shared across runs.
- Prefer filesystem or directory snapshots for restore flows. Use memory snapshots only when in-memory process state matters enough to justify their current limitations.
- Use
detach()when the sandbox should keep running after the client disconnects, andterminate()when the sandbox should stop immediately. - Keep this skill focused on sandbox lifecycle and isolated execution. Do not use it for ordinary stateless
@app.functiondeployments or generic Modal app hosting. - If the task is really about fine-tuning or post-training, stop and use
modal-finetuning. - If the task is really about vLLM or SGLang model serving, stop and use
modal-llm-serving. - If the task is really about detached batch orchestration or
@modal.batched, stop and usemodal-batch-processing.
Validate
- Run
npx skills add . --listafter editing the package metadata or skill descriptions. - Keep
evals/evals.jsonandevals/trigger-evals.jsonaligned with the actual workflow boundary of the skill. - Run [scripts/smoketest.py](scripts/smoketest.py) with a Python interpreter that can import
modalwhen changing lifecycle,exec(...), or file-IO guidance.
References
- Read [references/lifecycle-and-exec.md](references/lifecycle-and-exec.md) for lifecycle, reattachment, and command-execution details.
- Read [references/networking-and-tunnels.md](references/networking-and-tunnels.md) for tunnels, network controls, and service exposure.
- Read [references/files-and-persistence.md](references/files-and-persistence.md) for build-time uploads, runtime file IO, Volumes, and persistence tradeoffs.
- Read [references/snapshots.md](references/snapshots.md) for snapshot selection, limitations, and restore patterns.
- Read [references/example-patterns.md](references/example-patterns.md) for distilled sandbox workflow templates.
- Read [references/troubleshooting.md](references/troubleshooting.md) for common failure modes and recovery paths.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: jamesrobmccall
- Source: jamesrobmccall/modal-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.