We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Tool Permissions

OpenCode lets you decide whether a tool action should run automatically, ask first, or simply be denied using the permissions array in opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [
    { "action": "shell", "resource": "*", "effect": "ask" },
    { "action": "edit", "resource": "*", "effect": "allow" },
    { "action": "webfetch", "resource": "*", "effect": "deny" },
  ],
}

Each rule's effect is one of:

  • allow: run without approval
  • ask: prompt before running
  • deny: block the action

Each rule matches an action and a resource. A resource can be a path, command, URL, search query, skill ID, or subagent ID. Both fields support wildcards.

For example, this changes the default behavior for both webfetch and websearch to ask:

{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [{ "action": "web*", "resource": "*", "effect": "ask" }],
}

Rules are evaluated in order, and the last matching rule wins, so put broad defaults first and narrow exceptions later.

Default Behavior

OpenCode starts fairly permissive for most tools:

  • Most permissions default to allow
  • external_directory (accessing directories outside where OpenCode was started) defaults to ask
  • read is allowed by default, but .env files default to ask

One permission action can cover several related tools:

  • edit controls the edit, write, and patch tools.
  • shell controls shell commands.
  • subagent controls which child agents may run.

Assignment

Configure which tools OpenCode can use without asking.

  1. Allowing a custom tool like run_slop also allows whatever code it runs internally. Requiring approval for shell will not stop run_slop from executing commands.

Tell OpenCode to run and submit the CLI tests from the project root.

The agent may sometimes call a different tool than the one you expected, so when testing permissions be sure to watch the tool calls and steer it back to the intended path if needed.