agentleFS
EnigmaWUEnigmaWU/MyCodeAgentSkills/design-tool-use-sandboxing/SKILL.md

design-tool-use-sandboxing

Skill4 starsChanged 3 months agoMITView on GitHub

WHEN/WHERE/WHO: [Scheduling: Agents or architects granting LLMs access to terminal commands, file systems, or external APIs.] HOW: [Structural: Use this SKILL to enforce boundary protections, user-approval loops, and containerized execution for dangerous tools.] WHY: [Scheduling: Autonomous agents carry user-level privileges. Unconstrained tool execution leads to catastrophic code deletion or security breaches.]

  • Reads credentials
  • Deletes or force-pushes

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter …

    line 13
  2. Distinctive:

    Must be used anytime an agent is given write, delete, or execute permissions.

    line 23
  3. Very specific:

    When an LLM hallucinates a command like rm -rf /tmp/cache but makes a syntax error resulting in rm -rf / tmp/cache, the host machine is …

    line 29
  4. Distinctive:

    Transfer Check: Verify the workflow still works across host execution, containerized execution, and mixed tool environments.

    line 45
  5. Distinctive:

    Stop Rule: If the execution environment cannot provide either safe sandboxing or explicit approval gates, stop and warn instead of enabling …

    line 46
  6. Distinctive:

    If the user asks to disable human-in-the-loop approvals for shell commands on their host machine, strongly warn them of the risks and …

    line 53
  7. Distinctive:

    If an LLM passes a malformed argument, the tool wrapper must catch the exception and return a clear error message *back to the LLM* so it …

    line 65
  8. Very specific:

    If the user rejects, return a message to the agent: "Tool execution rejected by human.

    line 70
  9. Distinctive:

    If full autonomy is required for dangerous tools, execute them inside a Docker container or ephemeral virtual machine.

    line 73

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Design Tool Use Sandboxing

Common Contract (Load First)

When this skill is activated, first load skill-common and apply the shared conventions it defines: canonical section order, frontmatter rules, anti-pattern guidance, and the Review In Mind loop in review-in-mind. This skill adds only domain-specific rules below.

Who

Architects, security engineers, or coding agents integrating tool-use (function calling) capabilities into autonomous systems.

What

Implement secure execution environments and "human-in-the-loop" approval gates for any tools that mutate state, execute arbitrary code, or interact with external networks.

When

  • Triggered by requests like: "give the agent a bash tool", "allow the agent to run scripts", or "add secure tool calling".
  • Must be used anytime an agent is given write, delete, or execute permissions.

Where

Applies to the tool definition and execution layers of the agent orchestration framework.

Why

When an LLM hallucinates a command like rm -rf /tmp/cache but makes a syntax error resulting in rm -rf / tmp/cache, the host machine is destroyed. Agents must be treated as untrusted users. Proper sandboxing and human-approval gates are mandatory for safety.

Inputs

  • Requested Tools: The list of functions the agent needs to call.
  • Execution Environment: The target OS or container where tools will run.

Output (Logical Evidence)

  • Secure Tool Wrappers: Code that wraps raw functions with validation and approval logic.
  • Sandbox Architecture: A Dockerfile or DevContainer configuration for isolated execution.

Optimization Readiness

  • Failure Signals: Dangerous tools bypass approval, schemas accept malformed arguments, host execution remains unsandboxed, or the workflow normalizes risky autonomy without clear human gates.
  • Evidence To Collect: Wrapper schemas, approval prompts, rejected tool calls, sandbox configs, and examples of blocked versus permitted mutative actions.
  • Safe Mutation Boundaries: Refine tool categorization, validation rules, approval UX, and sandbox examples without weakening the core safety boundary between read-only and mutative execution.
  • Acceptance Criteria: Accept revisions only if dangerous actions are gated or isolated, malformed inputs are rejected cleanly, and users can inspect exactly what an agent wants to execute.
  • Rejected Revision Handling: Record unsafe bypass proposals, weak validation patterns, and ambiguous approval wording so they are not reintroduced.
  • Transfer Check: Verify the workflow still works across host execution, containerized execution, and mixed tool environments.
  • Stop Rule: If the execution environment cannot provide either safe sandboxing or explicit approval gates, stop and warn instead of enabling dangerous tools.

Constraints (Logical Boundaries)

  • Mandatory Approval for Mutative Actions: Any tool that alters the file system, modifies databases, or executes shell commands MUST pause and wait for explicit human approval, unless running in a fully disposable, isolated container.
  • Strict Parameter Validation: Tool inputs generated by the LLM must be validated against a strict schema (e.g., Pydantic) before execution.

One More Thing

If the user asks to disable human-in-the-loop approvals for shell commands on their host machine, strongly warn them of the risks and ensure they explicitly accept responsibility before proceeding.


How (Structural Workflow)

1. Categorize the Tools

  • Safe (Read-Only): Tools like read_file, get_weather, search_web. These can execute autonomously.
  • Dangerous (Mutative/Exec): Tools like run_bash, write_file, git_commit, drop_table. These require sandboxing or approval.

2. Implement Input Validation

  • Wrap all tools with strict type-checking (e.g., Pydantic BaseModel).
  • If an LLM passes a malformed argument, the tool wrapper must catch the exception and return a clear error message back to the LLM so it can self-correct, rather than crashing the orchestrator.

3. Implement Human-in-the-Loop (HITL) Gates

  • For dangerous tools running on the host machine, inject an interrupt in the execution graph.
  • The system must display the exact command/arguments to the user: Agent wants to execute: 'rm -rf ./build'. Approve? (Y/n).
  • If the user rejects, return a message to the agent: "Tool execution rejected by human. Find an alternative approach."

4. Implement Containerized Execution (Optional but Recommended)

  • If full autonomy is required for dangerous tools, execute them inside a Docker container or ephemeral virtual machine.
  • Mount only the specific workspace directories required; never mount the root filesystem or sensitive directories like ~/.ssh.

5. Add Timeout Limits

  • Wrap all tool executions in a timeout block (e.g., timeout=30s) to prevent an agent from running an infinite while true loop script that hangs the orchestrator.

Review In Mind (ReviewInMindGenie)

Execute the common review loop in review-in-mind before delivering.

Review lens for this skill:

  • Are dangerous tools gated by HITL approval, containers, timeouts, and minimal mounts?
  • Is the approval prompt explicit about the exact command, arguments, and consequences?
  • Is there a defined fallback path when execution is rejected?

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.