Design a Sandbox Security Policy for Autonomous Coding Agents

Generate a rigorous security policy for autonomous agents to define allowed shell commands, file access boundaries, and network restrictions.

Agent prompt for Claude Code and Cursor

Prompt

Prompt
You are a lead security engineer specializing in AI agent infrastructure. Your job is to draft a comprehensive sandbox execution policy for an autonomous coding agent. First, ask these 3 questions: 1. What is the primary language or framework the agent will be working in? 2. What specific external APIs or cloud services must the agent access? 3. Does the agent need to perform persistent changes to the production environment or only local testing? After receiving my answers, provide the policy following these rules: 1. Define a strict allowlist of shell commands. 2. Define a denylist of high-risk commands. 3. Specify filesystem read/write boundaries. 4. Detail network access limits using specific host patterns. Output format: # Sandbox Execution Policy

## 1. Allowed Shell Commands
- List of approved commands.

## 2. Forbidden Shell Commands
- List of blocked commands.

## 3. Filesystem Boundaries
- Defined paths for read and write access.

## 4. Network Access Policy
- List of permitted hostnames and protocols.

This is not professional cybersecurity advice; consult a certified security architect for production-grade hardening.

Example output

Example for: a Python-based web development agent needing access to GitHub and local SQLite databases.

Sandbox Execution Policy

1. Allowed Shell Commands

  • git status, git pull, git push
  • python -m pytest (all tests)
  • sqlite3 (only for local .db files)
  • npm install (only in /src/web)

2. Forbidden Shell Commands

  • sudo, su
  • rm -rf /
  • curl | bash
  • nc, nmap, netcat
  • chmod 777

3. Filesystem Boundaries

  • Read Access: /project/src, /project/tests, /project/requirements.txt
  • Write Access: /project/src, /project/tests, /project/data/local.db
  • Forbidden Access: /etc, /home/user/.ssh, /var/log, /root

4. Network Access Policy

  • Protocol: HTTPS only (port 443)
  • Permitted Hosts: github.com, api.github.com, pypi.org, files.pythonhosted.org
  • Blocked: All inbound connections; all non-essential outbound traffic to untrusted IPs.

This is not professional cybersecurity advice; consult a certified security architect for production-grade hardening.

Written by AI from this prompt. Your results will vary.

Tips and common edits

Why this works

  • Forces a clear distinction between necessary operations and dangerous commands.
  • Uses a structured format that is easy to copy into configuration files or system prompts.
  • Includes a mandatory disclaimer regarding security infrastructure best practices.

Use this prompt when configuring Claude Code, Cursor, or similar autonomous agents to ensure they do not accidentally compromise your local machine or server. Paste this into the chat interface and answer the follow-up questions.

Common edits

  • Modify the network allowlist to include specific internal company API endpoints.
  • Adjust the filesystem boundaries if the agent requires access to specific configuration folders.

Reuse it: Use in a workflowAdapt in the builder

Prompt details

By
Prompts-GPT editors
Published
How prompts are written and checked

Did this prompt work?

AI Coding AgentsClaude Code

Create Automated Verification Loops for Long-Running Coding Agents

Generate a deterministic shell pipeline that combines linting, isolated unit testing, and diff-budget monitoring to validate AI agent code changes.

AI Coding AgentsClaude Code

Generate Reproducible Bug Fix Specs for Coding Agents

Get a standalone reproduction test script and a precise technical plan to fix a bug, ensuring your AI agent stays focused and avoids unnecessary file changes.

AI Coding AgentsClaude Code

Audit PR Git Diffs for Scope Creep and Churn

Reviews git diff statistics and patch files to immediately flag out-of-scope edits, accidental whitespace formatting churn, and unrequested dependency updates.

AI Coding AgentsClaude Code

Convert User Stories into Strict Acceptance Test Assertions

This prompt transforms vague business requirements into precise Given-When-Then test assertions with exact HTTP status codes and JSON payload structures for AI coding agents.

AI Coding AgentsClaude Code

Create a Legacy Module Reference Sheet for Coding Agents

Compresses messy legacy source files into a dense markdown cheat sheet capturing public methods, hidden state changes, and side effects for coding agent contexts.