Skip to content
AgentAtlas

OpenCode Permissions: Allow, Ask or Deny Bash, Edit and Webfetch

How do I control which tools and commands OpenCode can run without asking?

Set the permission key in opencode.json. Each permission resolves to allow, ask or deny, and you can use glob patterns for bash commands and file paths. The last matching rule wins, so put the catch-all first and specific patterns after it.

Compare: allow all commands in every AI coding agent →

The three actions

  • allow: run without approval.
  • ask: prompt you for approval.
  • deny: block the action.

Most permissions default to allow. doom_loop and external_directory default to ask. Reading .env files is denied by default, while *.env.example is allowed.

Permission names

  • read, edit, glob, grep, bash
  • task (launching subagents), skill, lsp, question
  • webfetch, websearch
  • external_directory (paths outside the project)
  • doom_loop (the same tool call repeating three times with identical input)

edit covers all file changes, including edit, write and patch.

Ask before shell commands, allow safe ones

Give a permission an object of patterns instead of a single value. * matches zero or more characters and ? matches one.

opencode.json

{
  "permission": {
    "bash": {
      "*": "ask",
      "git *": "allow",
      "npm *": "allow",
      "rm *": "deny"
    },
    "edit": {
      "*": "deny",
      "docs/*.mdx": "allow"
    }
  }
}

Bash pattern gotcha

Bash patterns match parsed commands. A pattern like grep * allows arguments, but grep alone does not. If you pass arguments to git status, you need git status * to match.

Per-agent permissions

Agents can have their own permission block under the agent key or in a markdown agent's frontmatter. Agent rules merge with the global config and take precedence.

opencode.json

{
  "agent": {
    "reviewer": {
      "description": "Reviews changes for bugs",
      "mode": "subagent",
      "permission": { "edit": "deny", "bash": "ask" }
    }
  }
}

Sources

More OpenCode guides

Reviewed Oct 23, 2026. Settings change often; the linked vendor docs are the source of truth.

Built an MCP server? Get it listed everywhere →

Shipping an Android app? Google Play needs 12 testers for 14 days first. Get them with Tester Exchange →