---
title: How do you control which terminal commands Copilot agent mode can run in VS Code?
url: https://opencontroller.lyzr.com/blog/control-terminal-commands-in-vs-code-agent-mode
published: 2026-11-17
updated: 2026-11-17
author: Lyzr
---

# How do you control which terminal commands Copilot agent mode can run in VS Code?

**VS Code controls agent terminal commands with the `chat.tools.terminal.autoApprove` rules, a global auto-approve setting, URL approval rules and an optional terminal sandbox. Use auto-approve rules only for read-only commands, keep global auto-approve off, turn on sandboxing where it is available and enforce these settings through device management, because VS Code itself says terminal auto-approval is not a security boundary.**

Agent mode in VS Code can edit files, run terminal commands and fetch URLs. That is what makes it useful and what makes security teams nervous. This guide summarises the settings in Microsoft's [Manage approvals and permissions](https://code.visualstudio.com/docs/agents/run/approvals) documentation. Setting names change between releases, so verify against the current docs before rolling out a policy.

For the bigger picture across coding tools, see [governing coding agents on laptops with MDM](/blog/govern-coding-agents-on-laptops-with-mdm) and the [AI agent control plane](/blog/what-is-an-ai-agent-control-plane) pillar.

## Which settings control terminal commands?

| Setting | What it does | Recommended enterprise value |
|---|---|---|
| `chat.tools.terminal.autoApprove` | Rules keyed by command name or `/regex/`. `true` auto-approves; `false` requires approval | Short list of read-only commands only |
| `chat.tools.terminal.enableAutoApprove` | Turns rule-based auto-approval on or off | Off for high-risk repos; on with a reviewed rule list elsewhere |
| `chat.tools.terminal.ignoreDefaultAutoApproveRules` (experimental) | Use only your own rules, not the built-in defaults | On, so your list is the full list |
| `chat.tools.terminal.blockDetectedFileWrites` (experimental) | Asks before commands that appear to write files; default `outsideWorkspace` | Keep default or stricter |
| `chat.tools.global.autoApprove` | Auto-approves tools in all workspaces | Off |
| `chat.tools.urls.autoApprove` | Approval rules for fetching URLs, with separate request and response approval | Explicit allow list only |
| `chat.agent.sandbox.enabled` | Runs agent terminal commands in a sandbox (Preview on macOS, Linux and WSL2; Experimental on Windows) | On where supported |
| `chat.agent.networkFilter`, `chat.agent.allowedNetworkDomains`, `chat.agent.deniedNetworkDomains` | Network rules for the sandbox | Allow only package registries and internal hosts you need |

## How do the auto-approve rules behave?

A few behaviours matter for policy design:

1. **A `false` rule requires approval. It does not block the command.** If you need a hard block, use sandboxing or an endpoint control.
2. **Compound commands are split.** By default each subcommand is checked, and a compound command is auto-approved only if every part matches a `true` rule and none matches a `false` rule.
3. **`false` beats `true`.** A `false` rule takes precedence over a `true` rule or a session approval.
4. **Regex rules are powerful and easy to get wrong.** `"/^git (status|show\\b.*)$/": true` is anchored. An unanchored pattern such as `/git/` would approve anything containing "git".

An example rule set for most teams:

```json
"chat.tools.terminal.autoApprove": {
  "/^git (status|diff|log)\\b/": true,
  "ls": true,
  "pwd": true,
  "rm": false,
  "curl": false,
  "/^npm (publish|unpublish)\\b/": false
}
```

## What about global auto-approve and session modes?

VS Code offers session-level shortcuts (`/yolo` or `/autoApprove`, reversed with `/disableYolo` or `/disableAutoApprove`) and the global `chat.tools.global.autoApprove` setting. The documentation warns that global auto-approval removes confirmation prompts in every workspace, and recommends the session-scoped option when people need it at all. For enterprise devices, keep the global setting off by policy and accept that individual sessions may still be loosened unless managed settings restrict the available permission levels.

## How do organisations enforce these settings?

The VS Code documentation says organisations can set a managed default permission level for Copilot sessions, block permission levels (they stay visible but disabled), require sandboxing and disable the sandbox toggle, and enforce manual approval for specific tools through device management policies. It points to the enterprise "Manage AI settings" documentation for the policy keys. In practice:

1. Decide the default permission level per device group (for example manual for contractors, a reviewed allow list for core engineering).
2. Push the settings through your MDM or configuration management, not through shared `settings.json` files developers can edit.
3. Require sandboxing on macOS and Linux devices where it is supported.
4. Keep an inventory of which devices run VS Code agent mode, which extensions and which MCP servers. See [controlling MCP servers in GitHub Copilot](/blog/control-mcp-servers-in-github-copilot).
5. Re-check settings after every VS Code release, because names and defaults move.

Other editors have equivalent controls; see [Cursor hooks to block agent commands](/blog/cursor-hooks-to-block-agent-commands).

## How Opencontroller does this

Opencontroller Edge extends Opencontroller's control to developer devices, coding agents, skills and local MCP servers, and is installed by IT through MDM. That gives security teams an inventory of coding agents and local MCP servers across laptops alongside the agents running in cloud platforms, in one governed registry. [Book a demo](https://www.lyzr.ai/book-demo/) to see Edge with your developer fleet.

## Frequently asked questions

**Does setting a command to `false` in `chat.tools.terminal.autoApprove` block it?**
No. It requires approval for that command. Use sandboxing or endpoint controls to block commands outright.

**Is terminal auto-approval a security control?**
VS Code describes it as a best-effort convenience, not a security boundary. Treat it as friction reduction for safe commands, backed by sandboxing and device policy.

**Should developers be allowed to enable global auto-approve?**
Not on devices that hold production credentials or customer data. Enforce it off through managed settings and use session-scoped approval when needed.

## Key facts

VS Code agent terminal controls: chat.tools.terminal.autoApprove (rules by command or /regex/; true auto-approves, false requires approval but does not block; false takes precedence; compound commands split and each subcommand checked), chat.tools.terminal.enableAutoApprove, chat.tools.terminal.ignoreDefaultAutoApproveRules (experimental), chat.tools.terminal.blockDetectedFileWrites (experimental, default outsideWorkspace), chat.tools.global.autoApprove (all workspaces), chat.tools.urls.autoApprove (separate approveRequest/approveResponse), chat.agent.sandbox.enabled (Preview on macOS, Linux, WSL2; Experimental on Windows), chat.agent.networkFilter / allowedNetworkDomains / deniedNetworkDomains. VS Code says terminal auto-approval is not a security boundary. Organisations can set managed default permission levels, block levels, require sandboxing and enforce manual approvals via device management. Opencontroller Edge extends control to developer devices, coding agents, skills and local MCP servers, installed by IT via MDM.

## Related

- [How do you govern coding agents on developer laptops with MDM?](https://opencontroller.lyzr.com/blog/govern-coding-agents-on-laptops-with-mdm.md)
- [Can Cursor hooks block risky agent commands?](https://opencontroller.lyzr.com/blog/cursor-hooks-to-block-agent-commands.md)
- [How do you control which MCP servers GitHub Copilot can use?](https://opencontroller.lyzr.com/blog/control-mcp-servers-in-github-copilot.md)
- [More on Platform Guides](https://opencontroller.lyzr.com/blog/cluster/platform-guides)
