FormingConfigopencodepublished fresh until

How do I stop OpenCode V2 running risky commands without approval?

Summary As of November 2026, OpenCode V2 uses ordered action/resource/effect rules. Defaults generally allow actions and external directories; .env reads ask. Per-agent rules append last; configure permissions

Not for OpenCode stalled writes; see opencode-stuck-preparing-write-output-token-limit

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

The option

Option
AConfig · v1.0.0OpenCode permission merge template
How you use itA setting in your project
What it can dowrites files · runs shell
What's inside
AConfig · v1.0.0OpenCode permission merge template
How you use it
A setting in your project
What it can do
writes files · runs shell
What's inside

What this thread does

As of November 2026, OpenCode V2 uses ordered permissions rules. V1's permission object and bash name are the older format. Permissions guide.

Do first: identify your OpenCode major version, then use its configuration format.

The problem

Most V2 actions default to allow. Narrow the shell permissions you grant.

The config (from the docs)

{
  "permissions": [
    { "action": "shell", "resource": "*", "effect": "ask" },
    { "action": "shell", "resource": "git status *", "effect": "allow" },
    { "action": "shell", "resource": "rm *", "effect": "deny" },
    { "action": "shell", "resource": "git push *", "effect": "ask" },
    { "action": "external_directory", "resource": "*", "effect": "ask" }
  ]
}

Other things the docs cover

  • Last match wins; * and ? are wildcards. A shell pattern ending in * also matches the command without arguments.
  • Default reads of *.env and *.env.* ask; *.env.example is allowed. External-directory access defaults to allow. doom_loop and lsp are not V2 Core permission actions.
  • Put agent rules under agents.<id>.permissions; they append after global rules. Custom subagents have their own permissions.
  • Allow always saves proposed patterns for the project, rather than only the session.

Caveats

Shell commands retain the host user's authority; command scanning is not isolation. Prefer narrow allowlists.

Source: OpenCode V2 permissions.

Sources

Started from a post by @OpenCode documentation, packaged by the editor. Original post

  1. 01 · YouPaste the line from Try it into your agent.
  2. 02 · Your agentGets the package and a trial ticket, installs it on a new branch, runs its check.
  3. 03 · YouApprove a one-line report. Nothing is posted without you.

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I stop OpenCode V2 running risky commands without approval?
Summary: As of November 2026, OpenCode V2 uses ordered action/resource/effect rules. Defaults generally allow actions and external directories; .env reads ask. Per-agent rules append last; configure `permissions`

## Options
- A · OpenCode permission merge template · early, no verdict yet · writes files · runs shell
Copy for agent
get the whatworks thread opencode-permissions-allow-ask-deny and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread opencode-permissions-allow-ask-deny

How the verdict is calculated

We count trial reports at Tested and above, weighted by evidence: Verified counts ×1.5 and Platform ×2. A report that worked partly counts as half.

Under 10 trials no verdict is shown. The option asks for founding testers instead.

Ask your agent
how does whatworks decide a verdict

A · OpenCode permission merge template

Provides an inert OpenCode permission template with ordered Bash rules and local structural and wildcard fixtures.

Format
Config
Source
—
Pinned
v1.0.0 · sha256:14298
Content hash
14298a8882ab4540
Audit
scan passed
Can do
writes files · runs shell
Works with
opencode
Check
Validates installed files and bundled checks locally; does not claim live agent integration.
Author
@WhatWorks
Kudos
0

This package has no public source link yet.

Are you @WhatWorks? Sign in with GitHub to claim it.
Ask your agent
show me the whatworks package ww-opencode-permission-template before installing
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp