permissions field and an ordered array of rules.
Rule schema
Each rule has three required string fields:actionmatches a tool permission action.resourcematches the value the tool is trying to use, such as a path, command, URL, query, or agent ID.effectis"allow","deny", or"ask".
allow proceeds without prompting, deny blocks the operation, and ask
waits for a user decision. If no rule matches, the result is ask.
Matching and order
Bothaction and resource support simple wildcards:
*matches zero or more characters, including/.?matches exactly one character.- All other characters are literal.
" *" also matches the command without arguments: "git status *" matches
both git status and git status --short.
The last matching rule wins. Put broad rules first and exceptions later.
Rules from lower-priority configuration files are loaded first. OpenCode then
appends all global rules before agent-specific rules, so a matching agent rule
overrides a global rule.
Some operations check several resources at once, such as a patch touching
multiple files. OpenCode denies the operation if any resource resolves to
deny; otherwise it asks if any resolves to ask; otherwise it allows it.
Actions and resources
V2 action names are strings, so plugins may introduce additional actions. The current built-in actions use these resources:
Built-in agent policy also reserves
plan_enter and plan_exit for plan-mode
transitions. doom_loop and lsp are not current V2 Core permission actions.
External directories
An external path requires a separateexternal_directory decision before the
tool’s own read or edit decision. This applies to external paths used by
read, edit, write, and patch, and to an external shell working
directory.
external_directory, read, and edit resources, a leading ~, ~/,
$HOME, or $HOME/ is expanded when configuration loads. Shell resources are
raw command text and are not home-expanded.
Relative mutation paths cannot escape the active Location, and symlink escapes
from inside it are rejected. Explicit external paths are canonicalized before
matching, so authorize only trusted directory boundaries.
Defaults
The evaluator’s fallback isask, but shipped agents include ordered defaults:
The base read rules are ordered as follows:
Agent overrides
Configure shared policy at the top level and append narrower rules to a named agent underagents.<id>.permissions:
Approval choices
When anask rule matches, clients can reply with:
- Allow once (
once): approve only the pending request. - Allow always (
always): approve this request and save the patterns proposed by the tool for the current project. - Reject (
reject): reject the request. Rejecting also rejects other pending permission requests in the same session; clients may attach feedback.
allow
rules, but they can never override a configured deny. The proposed saved
pattern may be broader than the displayed resource: several tools propose *,
shell proposes the exact command text, and skills and subagents propose their
IDs. Review the confirmation carefully and remove saved approvals that are no
longer needed.
For non-interactive runs, opencode2 run --auto replies once to permission
requests. It does not save approvals, and explicit deny rules remain enforced.
Without --auto, a non-interactive run rejects permission requests.