AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure Cursor Agent Terminal Permissions and Allowlists for Safe Autonomous Execution

Nicolas Henriet · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Running Cursor Agent with full terminal autonomy is both the most powerful workflow and the most dangerous operational risk in modern AI-assisted engineering. When you instruct an autonomous agent to refactor a service, generate regression tests, and fix bugs across multiple files, the agent naturally executes shell commands—inspecting git branches, installing libraries, and running test suites.

Engineers face two bad extremes:

  1. The Approval Fatigue Trap ("Ask Every Time"): Prompting human confirmation for every single read-only command (git status, git diff, npm test, pytest) shatters developer flow. After clicking "Approve" forty times in twenty minutes, developers inevitably stop inspecting the commands and blindly click "Approve"—defeating the entire purpose of human-in-the-loop oversight.
  2. The YOLO Disaster ("Run Everything"): Blindly granting blanket autonomy allows the agent to execute any shell command. A single hallucinated regex or misunderstood prompt can trigger catastrophic operations: running rm -rf on uncommitted source trees, executing git push --force to remote main branches, exposing .env secrets through unintended curls, or dropping tables with unvetted database migrations.

365Finds Opinion: The solution is neither blind permission nor manual micromanagement. 365Finds recommends enforcing a strict, version-controlled engineering policy using Cursor's native .cursor/permissions.json paired with the Auto-review execution mode. By establishing explicit terminal allowlists for read-only inspection and local test execution while constraining the classifier subagent with plain-English safety boundaries, engineering teams can maintain uninterrupted developer flow while erecting a hardened, deterministic firewall against destructive accidents.


The Core Dilemma: Flow State vs. Terminal Safety

Autonomous coding agents differ fundamentally from autocomplete tools like Cursor Tab or simple inline diff editors like Composer. Cursor Agent executes continuous, multi-step agentic loops: it inspects code, edits files, runs terminal tools to evaluate compiler or test output, interprets the errors, and applies follow-up patches until the task succeeds.

Terminal access is essential for this loop, but shell commands possess unlimited blast radius:

Operation TypeTypical CommandsFlow RequirementRisk ProfileRecommended Policy
Read-Only Inspectiongit status, git diff, pwd, lsMust execute silently in millisecondsZero filesystem or remote state changeUnrestricted Allowlist
Local Test & Buildnpm test, pytest, cargo check, go testFrequent iteration during debuggingSafe if isolated; potential disk/memory saturationExplicit Allowlist / Sandbox
Package Managementnpm install <pkg>, pip install <pkg>Occasional executionTyposquatting risk, dependency supply-chain threatsAuto-review / Manual Approval
Stateful Mutationgit reset --hard, git checkout ., rm -rfRarely required autonomouslyHigh: Destroys uncommitted code and work in progressHard Block / Manual Approval
Remote & Infrastructuregit push, aws, kubectl, terraformNever required in local IDE agent loopsSevere: Remote pipeline corruption or production outageStrict Block / Forbidden

Relying on human memory to evaluate commands under approval fatigue always fails. True engineering security requires automated policy enforcement defined directly in code.


Cursor Agent Execution Modes Decoded

Cursor governs agent autonomy through Run Modes, configured in the IDE under Settings > Cursor Settings > Agents > Approvals & Execution. Understanding how these modes handle tool calls is crucial for architecting a safe workspace:

[Agent Shell Command Attempt]
            |
            v
+-----------------------+
| In terminalAllowlist? | ---- Yes ----> [Execute Immediately (No Prompts)]
+-----------------------+
            | No
            v
    [Current Run Mode]
            |
            +----> Allowlist Mode -------> Prompt Developer for Approval
            |
            +----> Run Everything -------> Execute Immediately (High Risk)
            |
            +----> Auto-review Mode (Recommended)
                         |
                         v
             +-----------------------+
             | Can Command Sandbox?  | ---- Yes ----> [Execute in Terminal Sandbox]
             +-----------------------+
                         | No
                         v
             +-----------------------+
             | LLM Classifier Check  | ---- Allowed -> [Execute with Classifier Consent]
             | (Steered by autoRun)  | ---- Blocked -> Prompt Developer for Approval
             +-----------------------+

1. Auto-review Mode (Recommended Default)

Auto-review introduces a three-tiered evaluation pipeline:

  1. Deterministic Allowlist: If a terminal command matches an entry in terminalAllowlist (or an MCP tool matches mcpAllowlist), Cursor executes it instantly without pop-ups or sandboxing overhead.
  2. Terminal Sandbox Containment: If the command is not on the allowlist, Cursor evaluates whether it can run inside the OS-level Terminal Sandbox. If the command only requires local workspace reads/writes and does not tamper with protected git directories or external networks, it runs safely inside the sandbox.
  3. Classifier Subagent: If the command cannot be safely sandboxed (e.g., requires external network calls or writes outside the project root), it is evaluated by a background safety classifier model. The classifier assesses command risk using natural-language instructions specified in the autoRun block before either approving execution or escalating to a human approval prompt.

2. Allowlist Mode

Under Allowlist Mode, Cursor behaves strictly deterministically:

3. Run Everything Mode (YOLO Mode)

Run Everything completely disables human confirmation prompts and sandboxing gates. Every tool call and shell command suggested by the LLM runs instantly.

365Finds Verdict: Never enable "Run Everything" on shared workstations, repositories connected to internal infrastructure, or environments holding valid cloud credentials (~/.aws, ~/.kube, or active SSH agent sockets). A single prompt injection in third-party code or a confused agent can irrevocably compromise local and remote environments.


Authorization Policy vs. Runtime Sandboxing

A common misconception is conflating permissions.json with sandbox.json. These two configuration layers operate on completely different security planes:

If a command is not allowlisted, runs in Auto-review, and attempts an action forbidden by sandbox policies (such as curling an external IP), the sandbox traps the operation, bubbles up an error, and the agent falls back to prompting the human developer.


Anatomy of .cursor/permissions.json

Cursor supports permissions.json using JSONC (JSON with Comments), meaning you can document rationale alongside individual rules.

File Hierarchy & Precedence

Cursor resolves permissions in a strict three-tier cascade:

  1. Team Admin Dashboard Controls (Highest Priority): Policies enforced globally by organization administrators on Cursor Teams or Enterprise plans override local workspace settings.
  2. permissions.json (Combined Per-User & Per-Repo): Cursor merges arrays from ~/.cursor/permissions.json (global user defaults) and <workspace>/.cursor/permissions.json (project-specific rules). If a command is allowlisted in either file, it is permitted.
  3. IDE Settings UI (Lowest Priority): The manual editor inside Settings > Agents > Approvals & Execution.

[!IMPORTANT] The UI Lockout Effect: Once a terminalAllowlist or mcpAllowlist is defined inside .cursor/permissions.json, Cursor automatically overrides the in-app settings UI, turning that section read-only and hiding the manual "Add to allowlist" button. This prevents local configuration drift and ensures all team members execute against committed, audited policy files.

Top-Level Schema Reference

{
  // 1. Exact commands or command prefix strings permitted to execute without prompts
  "terminalAllowlist": [
    "git status",
    "git diff",
    "npm test"
  ],

  // 2. Model Context Protocol (MCP) tools permitted to execute without approval
  "mcpAllowlist": [
    "sqlite:read_query",
    "github:get_issue"
  ],

  // 3. Plain-English instructions steering the Auto-review LLM classifier
  "autoRun": {
    "allow_instructions": [
      "Allow running local test suites, linter checks, and read-only git operations."
    ],
    "block_instructions": [
      "Require manual approval for any command that deletes files, modifies git remotes, or executes cloud CLIs."
    ]
  }
}

Matching Mechanics for terminalAllowlist

Entries in terminalAllowlist match based on command prefix tokens:


Production Blueprint: Enterprise-Ready .cursor/permissions.json

Below is the standard .cursor/permissions.json recommended by 365Finds for modern TypeScript/Node and Python engineering repositories. Commit this file directly into the repository root:

{
  // Terminal commands pre-approved for frictionless autonomous loops
  "terminalAllowlist": [
    // --- Git Inspection (Zero State Changes) ---
    "git status",
    "git diff",
    "git log",
    "git branch",
    "git show",

    // --- Node.js / TypeScript Test & Quality Checks ---
    "npm test",
    "npm run test",
    "npm run lint",
    "npm run typecheck",
    "npm run build",
    "pnpm test",
    "pnpm run test",
    "pnpm run lint",
    "pnpm run build",
    "npx tsc --noEmit",
    "npx eslint",
    "npx prettier --check",

    // --- Python / Pytest Workflows ---
    "pytest",
    "python -m pytest",
    "flake8",
    "black --check",
    "mypy",
    "poetry run pytest",

    // --- Filesystem Inspection ---
    "pwd",
    "ls",
    "which"
  ],

  // Pre-approved MCP Tool Endpoints
  "mcpAllowlist": [
    "filesystem:read_file",
    "filesystem:list_directory"
  ],

  // Steering Directives for the Auto-review LLM Classifier
  "autoRun": {
    "allow_instructions": [
      "Allow read-only filesystem inspections, build diagnostics, and unit testing runs that do not mutate persistent databases.",
      "Allow standard package linter and formatter validation commands within the project repository."
    ],
    "block_instructions": [
      "Block and require explicit manual human approval for any git push, git commit, git reset, git rebase, or git checkout command.",
      "Block and require approval for destructive file removals, including rm, shred, or rimraf.",
      "Block any execution of cloud provider CLIs, including aws, gcloud, az, kubectl, and terraform.",
      "Block all database migration tools that modify schema or drop tables, such as prisma migrate reset, alembic downgrade, or flyway clean.",
      "Block any command attempting to read, export, or curl environment variable files matching .env* or containing access tokens."
    ]
  }
}

Advanced CLI Token Rules (.cursor/cli.json)

If your team runs the Cursor headless CLI agent in local scripts or continuous development environments, permissions are configured through explicit permission tokens inside .cursor/cli.json (or globally in ~/.cursor/cli-config.json).

The token format uses structured function syntax:

{
  "permissions": {
    "allow": [
      "Shell(git status)",
      "Shell(git diff)",
      "Shell(npm test)",
      "Shell(pytest)",
      "Read(src/**)",
      "Read(tests/**)",
      "Write(src/**)",
      "Write(tests/**)",
      "WebFetch(docs.github.com)",
      "WebFetch(nodejs.org)"
    ],
    "deny": [
      // Deny rules ALWAYS take absolute precedence over allow rules
      "Shell(rm)",
      "Shell(git push:*)",
      "Shell(curl:*)",
      "Read(.env*)",
      "Read(**/*.pem)",
      "Read(**/*.key)",
      "Write(.github/**)",
      "Write(package.json)"
    ]
  }
}

Notice the critical precedence invariant: deny rules always override allow rules. Even if a pattern like Write(src/**) matches an .env file nested inside a source folder, an explicit deny: ["Read(.env*)"] blocks the agent from touching secrets.


Defense-in-Depth: Complementary Guardrails

Configuring permissions.json eliminates 90% of autonomous terminal execution risks, but enterprise security demands a multi-layered defense-in-depth posture:

1. Mandatory .cursorignore File

Autonomous agents scan directory trees to construct context. If your repository contains development secrets, API keys, or staging credentials, the agent can inspect them even without terminal execution. Place a .cursorignore file in the project root:

.env
.env.*
*.pem
*.key
credentials.json
id_rsa
secrets/

Files listed in .cursorignore are completely hidden from Cursor Agent's file indexing, semantic search, and context assembly pipelines.

2. Git Branch Protection and Pre-Commit Hooks

Never rely on IDE configurations alone to protect repositories:

3. Workstation Credential Hygiene

Ensure developer workstations isolate production credentials. Never keep active AWS Admin credentials, production database passwords, or unencrypted private keys in environment variables inherited by the IDE terminal session. Use temporary session tokens (e.g., AWS IAM Identity Center / SSO) with short lifespans.


Strategic Summary: Execution Mode Matrix

CapabilityAsk Every TimeRun Everything365Finds Recommended: Auto-review + permissions.json
Developer Flow StateBroken (Pop-ups on every test/git inspect)UninterruptedUninterrupted for allowed test/read loops
Protection Against Destructive CLIRelies on tired humans (High human error)Non-existent (Zero safety)Deterministic allowlists + AI Classifier safety gates
Filesystem & Network IsolationPrompt-drivenNoneOS Sandbox + sandbox.json boundaries
Team StandardizationIndividual user driftDangerously unstandardizedVersion-controlled repo config checked into git
Security AuditabilityNo audit trailUncontrolled blast radiusAudited JSONC committed to repository root

The 365Finds Recommendation

Standardize your engineering organization today:

  1. Switch all developer IDE instances to Auto-review mode (Settings > Agents > Approvals & Execution).
  2. Commit a curated .cursor/permissions.json to the root of every shared repository.
  3. Whitelist only read-only git subcommands and test/build runners.
  4. Codify strict classifier stop-rules in autoRun.block_instructions.
  5. Enforce .cursorignore to isolate local secrets.

By coupling deterministic allowlists with intelligent classifier fallbacks, your engineering team gains the full compounding productivity of autonomous agentic development without jeopardizing the stability of your code, machines, or infrastructure.


References