

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Tools
incomplete
2: Built-in Tools
incomplete
3: Specialized Tools
incomplete
4: Custom Tools
incomplete
5: Create a Custom Tool
incomplete
6: Tool Permissions
incomplete
7: Sandboxing
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
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 approvalask: prompt before runningdeny: block the actionEach 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.
OpenCode starts fairly permissive for most tools:
allowexternal_directory (accessing directories outside where OpenCode was started) defaults to askread is allowed by default, but .env files default to askOne 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.Configure which tools OpenCode can use without asking.
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.