Skip to content

OpenCode vs Claude Code: permissions, sandbox and security compared

OpenCode and Claude Code side by side on permission rules, sandboxing, network access, hooks, admin policy and public advisories, with a source for every fact.

Checked

OpenCode

Made by
Anomaly (formerly SST)
Out of the box
The base policy allows every action and asks only before reading .env files. Unmatched requests ask. Edits and shell commands run without a prompt.
Sandbox
No OS-level sandbox. OpenCode says it does not sandbox the agent, and it advises a Docker container or VM when you need isolation.
Public advisories
3 with a CVE or GHSA id, 3 rated critical or high

Claude Code

Made by
Anthropic
Out of the box
From v2.1.283, interactive terminal and VS Code sessions start in auto mode, where a classifier reviews actions. Without a supported model it starts in Manual. claude -p and Agent SDK runs start in Manual, which asks before edits, shell commands and network access.
Sandbox
Yes, off by default. Turn on with /sandbox or sandbox.enabled. macOS uses Seatbelt, Linux and WSL2 use bubblewrap. Not supported on native Windows. Covers Bash, PowerShell and Monitor commands only. File tools, MCP servers and hooks run outside it.
Public advisories
8 with a CVE or GHSA id, 6 rated critical or high

Short answer

OpenCode is open source, works with many model providers and costs nothing beyond your model. Claude Code is Anthropic's agent for Claude models. Their defaults differ most. OpenCode's base policy allows every action and asks only before reading .env files, and it has no sandbox: the project advises a container or VM when you need isolation. Claude Code starts in auto mode, where a classifier reviews actions, and has an optional Seatbelt sandbox on macOS. Both let you write allow, ask and deny rules, and both let admins lock them.

At a glance

Every answer links to the page that says it. Both agents change often, so their own docs win where they differ from this page.

Safety controls, side by side
QuestionOpenCodeClaude Code
Sandbox on from the first runNoNo sandbox83NoOpt-in with /sandbox3
OS-level sandbox availableNoUse a container or VM83YesSeatbelt on macOS, bubblewrap on Linux3
No network in commands by defaultNoCommands have your network access3PartlyAsks in Manual mode; with the sandbox, an allowlist that starts empty34
Asks you before shell commands by defaultNoRuns commands until you add an ask rule3PartlyAuto mode lets a classifier approve; Manual mode asks2
Deny rules you writeYesOrdered rules, last match wins37Yesdeny arrays, checked first4
A hook can block a tool callPartlyA permission hook can deny14YesPreToolUse with exit code 2 or a deny5
Admin policy users cannot overrideYesManaged config on macOS and Linux135YesManaged settings file, MDM or admin console8
Admins can turn off the skip-approvals modeNot applicableNo skip flag; the default is already open3YesAdmins can disable bypassPermissions2
Open sourceYesMIT1NoThe sandbox runtime is open source93

The basics

QuestionOpenCodeClaude Code
Runs in
Terminal app, desktop app (beta) and a web view.12
Terminal CLI, VS Code and JetBrains extensions, desktop app, web at claude.ai/code, mobile app, GitHub Actions and GitLab CI/CD, and an Agent SDK.1
Platforms
macOS, Linux and Windows.2
macOS, Linux, WSL and native Windows. Installs with a script, Homebrew, WinGet, apt, dnf or apk.1
Open source
Yes, MIT licensed.1
No. The anthropics/claude-code repo holds issues, plugins and examples, and its license file is "All rights reserved" under Anthropic's Commercial Terms. The sandbox runtime is a separate open source package.93
Models
Many providers through the models.dev catalog, connected with /connect, plus custom providers and local models.2
Claude models from Anthropic, or third-party providers such as Amazon Bedrock, Google Cloud and Microsoft Foundry. Auto mode needs Opus 4.6 or later, Sonnet 4.6 or later, Haiku 5.5 or a Fable model on the Anthropic API.12
Pricing
The app is free. You pay your model provider or an OpenCode plan.2
Included with Claude Pro, Max, Ultra, Team and Enterprise plans, not Free. Pro is $20 a month, or $17 a month billed annually. Also usable with an Anthropic Console API account at API rates.101

Safety controls

QuestionOpenCodeClaude Code
Out of the box
The base policy allows every action and asks only before reading .env files. Unmatched requests ask. Edits and shell commands run without a prompt.3
From v2.1.283, interactive terminal and VS Code sessions start in auto mode, where a classifier reviews actions. Without a supported model it starts in Manual. claude -p and Agent SDK runs start in Manual, which asks before edits, shell commands and network access.2
Sandbox
No OS-level sandbox. OpenCode says it does not sandbox the agent, and it advises a Docker container or VM when you need isolation.83
Yes, off by default. Turn on with /sandbox or sandbox.enabled. macOS uses Seatbelt, Linux and WSL2 use bubblewrap. Not supported on native Windows. Covers Bash, PowerShell and Monitor commands only. File tools, MCP servers and hooks run outside it.3
Network in commands
Open. Shell commands run with the host user's filesystem, process and network authority. webfetch and websearch have their own rules.3
Without the sandbox, network commands and WebFetch ask in Manual mode, apart from preapproved documentation domains. With it, traffic goes through a local proxy that checks sandbox.network.allowedDomains, which starts empty.34
Turning approvals off
No skip flag is documented. The base policy already allows most actions with a wildcard allow rule, and configured deny rules stay enforced for non-interactive clients.3
--dangerously-skip-permissions, same as --permission-mode bypassPermissions. Skips prompts and safety checks. Deny rules and explicit ask rules still apply. Docs say to use it only in containers or VMs. Admins can disable it.2
Permission rules
An ordered permissions array in opencode.jsonc. Each rule has action, resource and effect (allow, deny or ask). The last matching rule wins.37
permissions.allow, ask and deny arrays in settings.json, for example Bash(npm run test *) and Read(./.env). Deny is checked first, then ask, then allow. /permissions lists them.4
Hooks before a tool runs
Plugins can register execute.before on ctx.tool.hook to inspect or replace tool input, and a permission hook evaluate that can set effect to deny. Docs do not say execute.before can block.14
Yes. PreToolUse hooks run before a tool call and can block it with exit code 2 or a deny decision. Types are command, http, mcp_tool, prompt and agent. A crashed hook does not block unless onFailure is block.5
Project instructions
AGENTS.md, plus a global ~/.config/opencode/AGENTS.md. It also reads CLAUDE.md in any directory with no AGENTS.md, and ~/.claude/CLAUDE.md when no global file exists.11
CLAUDE.md in the project and in ~/.claude/, plus CLAUDE.local.md and .claude/rules/. Can read AGENTS.md in place of CLAUDE.md. These are guidance, not enforced.61
MCP servers
Yes. Servers are set under mcp.servers in opencode.jsonc, and their tools match rules as <server>_<tool>.47
Yes. HTTP, SSE (deprecated), stdio and WebSocket. Servers live in .mcp.json (project) or ~/.claude.json (local and user scope). Admins can set managed-mcp.json or managedMcpServers.78
Session history
Sessions and persistent data are in the database ~/.local/share/opencode/opencode.db (override with OPENCODE_DB). The log file is ~/.local/share/opencode/log/opencode.log.12
Plaintext JSONL transcripts at ~/.claude/projects/<project>/<session>.jsonl, prompt history in ~/.claude/history.jsonl. Transcripts are deleted after 30 days by default (cleanupPeriodDays)6
Admin policy
On macOS, /Library/Managed Preferences/ai.opencode.managed.plist ranks first, then /Library/Application Support/opencode/opencode.json. Linux uses /etc/opencode. Managed config outranks user and project files.135
Yes. /Library/Application Support/ClaudeCode/managed-settings.json on macOS, a com.anthropic.claudecode MDM profile, or server-managed settings from the claude.ai admin console. Users and project files cannot override them.8

The differences that matter

What runs without asking

Out of the box OpenCode runs edits and shell commands without a prompt and asks only before .env reads. You add rules to change that. Claude Code's interactive sessions start in auto mode, where a classifier approves routine actions, and scripted runs start in Manual mode, which asks before edits and commands.

The sandbox

OpenCode says it does not sandbox the agent, and its shell commands run with your user's file and network access. Claude Code has a sandbox you turn on, Seatbelt on macOS, that covers shell commands and sends their traffic through a proxy with a list of allowed domains.

How the rules work

OpenCode keeps an ordered permissions array in opencode.jsonc, and the last matching rule wins, so a narrow deny can follow a broad allow. Claude Code keeps allow, ask and deny arrays in settings.json and checks deny first. In both, a deny you configured holds even when you choose to always allow something.

Hooks

Claude Code's PreToolUse hooks can block a call with exit code 2 or a deny decision. OpenCode's plugins can inspect or replace a tool's input, and a permission hook can set a deny. Its docs don't say the input hook itself can block a call.

Models and price

OpenCode connects to many providers through models.dev, plus local models, and the app is free. Claude Code uses Claude models from Anthropic or through Bedrock, Google Cloud and Microsoft Foundry, and comes with Claude's paid plans or API billing.

Public advisories

OpenCode has three advisories, all in its local server and web UI, the worst rated critical in January 2026. Claude Code's repository lists eight since June 2026. All were fixed in releases. If you run opencode serve, keep it off the network or set a password.

Approval modes

Each agent's modes, from the one that asks most to the one that asks least, with the mode each starts in marked.

OpenCode

  1. plan agentAsks for some actions
  2. Ordered permission rulesAsks for some actions
  3. Allow alwaysAsks for some actions
  4. build agentAsks for some actionsStarts here

Claude Code

  1. planAsks for some actions
  2. default (Manual)Asks before each action
  3. dontAskNever asks
  4. acceptEditsAsks for some actions
  5. autoAsks for some actionsStarts here
  6. bypassPermissionsNever asks

OpenCode modes in detail

ModeHow to turn it onAsks youWhat it allows
plan agent
Press Tab to switch to the plan agent
For some actions
Reads and plans, with edits denied except files under ~/.opencode/plan.
Ordered permission rules
permissions array in opencode.jsonc, each with action, resource and effect
For some actions
Each rule allows, denies or asks, the last matching rule wins, and an unmatched action asks.
Allow always
Choice in an approval prompt
For some actions
Saves a project-scoped allow rule for the pattern the tool proposes, and it never overrides a configured deny.
build agent
Default, switch agents with Tab
For some actions
Full access under the base policy, which allows every action and asks only for .env reads.

Claude Code modes in detail

ModeHow to turn it onAsks youWhat it allows
plan
Shift+Tab, --permission-mode plan or /plan
For some actions
Reads and proposes changes without editing source until you approve the plan.
default (Manual)
--permission-mode default or permissions.defaultMode
Before each action
Prompts for most edits, shell commands and network access. Reads in the working directory run without asking.
dontAsk
--permission-mode dontAsk (not in the Shift+Tab cycle)
Never
Denies every call that would prompt. Only reads and pre-approved tools run.
acceptEdits
Shift+Tab, --permission-mode acceptEdits
For some actions
Auto-approves edits and common filesystem commands in the working directory. Other Bash commands still prompt.
auto
Shift+Tab, --permission-mode auto or defaultMode in user settings
For some actions
A classifier model blocks risky actions such as curl | bash and force pushes. Pauses and prompts after 3 blocks in a row or 20 in total.
bypassPermissions
--dangerously-skip-permissions or --permission-mode bypassPermissions
Never
Skips prompts and safety checks. Deny rules and explicit ask rules still apply. Docs say it offers no protection against prompt injection.

Where their settings live

OpenCode

PathWhat it holds
~/.config/opencode/opencode.json
Global config, also read as opencode.jsonc
~/.config/opencode/AGENTS.md
Global instructions
opencode.jsonc
Project config, permissions and MCP servers
.opencode/opencode.json
Project config inside a .opencode folder
/Library/Application Support/opencode/opencode.json
Managed policy on macOS
/Library/Managed Preferences/ai.opencode.managed.plist
Managed preferences on macOS, highest authority
~/.local/share/opencode/opencode.db
Session database
~/.local/share/opencode/log/opencode.log
Log file for installed builds

Claude Code

PathWhat it holds
~/.claude/settings.json
User settings, permissions and hooks
.claude/settings.json
Project settings, shared in git
.claude/settings.local.json
Personal project settings, gitignored
/Library/Application Support/ClaudeCode/managed-settings.json
Admin-managed policy on macOS
~/.claude.json
Account state, trust decisions, local and user MCP servers
.mcp.json
Project MCP servers
~/.claude/projects/
Session transcripts and auto memory
~/.claude/history.jsonl
Prompt history
~/.claude/file-history/
Pre-edit file snapshots for checkpoint restore
CLAUDE.md
Project instructions

Security advisories

Public advisories and well-documented reported issues since 2025. A longer list can mean more people are looking, so read each one rather than the count.

OpenCode

3Listed here
3With a CVE or GHSA id
3Name a fix

Claude Code

8Listed here
8With a CVE or GHSA id
8Name a fix

Both, newest first

  1. Claude CodeGHSA-5xjx-9qx6-jcrvHigh

    A race in the Edit tool's path check let a process in the Bash sandbox swap a parent directory for a symlink, so the unsandboxed Edit tool could overwrite a file outside the workspace on macOS. CVE-2026-88968.

    Fixed in 2.1.251
  2. Claude CodeGHSA-4p2j-qj3c-6x84High

    Uncontrolled search path let a malicious git executable run arbitrary code. Affects Claude Desktop, listed in the Claude Code repo. CVE-2026-88066.

    Fixed in Claude Desktop 1.8089.0
  3. Claude CodeGHSA-pq7j-f95f-qfcvHigh

    A plugin commit SHA pin could be bypassed, allowing installation of attacker-controlled code. CVE-2026-86063.

    Fixed in 2.1.179
  4. Claude CodeGHSA-5j29-h97v-84chHigh

    Arbitrary file write through write-time symlink following (a time-of-check to time-of-use race). CVE-2026-103435.

    Fixed in 2.1.129
  5. Claude CodeGHSA-gfvf-j8jh-jxxwLow

    Managed settings were not applied when a stored API key was preferred over enterprise sign-in. CVE-2026-103012.

    Fixed in 2.1.260
  6. Claude CodeGHSA-v234-4jrq-mgg6High

    Claude Desktop on macOS: opening a malicious file from a Cowork folder could run commands on the host. Listed in the Claude Code repo.

    Fixed in Claude Desktop 1.15962.0
  7. OpenCodeGHSA-632h-h47v-g4x4High

    A cross-site request to /global/upgrade on opencode serve could make an npm, pnpm or Bun based install fetch an attacker-chosen package. Installs from curl, Homebrew, Chocolatey or Scoop were not affected.

    Fixed in 1.18.22
  8. Claude CodeGHSA-7835-87q9-rgvvHigh

    Git worktree path confusion allowed a sandbox escape and unsandboxed code execution. CVE-2026-55607.

    Fixed in 2.1.163
  9. Claude CodeGHSA-4vp2-6q8c-pvq2Medium

    An insecure temporary file in the /copy command allowed response disclosure and a symlink-based file write. CVE-2026-46406.

    Fixed in 2.1.128
  10. OpenCodeGHSA-c83v-7274-4vgpCritical

    CVE-2026-22813: the web UI's markdown renderer allowed script injection on localhost:4096, which a malicious site could chain into running commands through the PTY API.

    Fixed in 1.1.10
  11. OpenCodeGHSA-vxw4-wv6m-9hhhHigh

    CVE-2026-22812: the local HTTP server started with no authentication and permissive CORS, so another local process or a website could run shell commands.

    Fixed in 1.0.216

Strengths and things to watch

OpenCode

What it does well

  • Rules are ordered and the last match wins, so a narrow deny can follow a broad allow.
  • Configured deny rules stay enforced for non-interactive clients, and Allow always never overrides one.
  • Managed policy outranks user and project config, with a macOS managed preferences file at the top.
  • The shell scanner checks each sub-command, and a command it cannot analyze fails when a shell deny rule applies.
  • The code is MIT licensed and the advisories are public.

What to watch for

  • The base policy allows every action except .env reads, so nothing asks until you add rules.
  • There is no OS-level sandbox, and shell commands have the host user's file and network authority.
  • Paths outside the project (external_directory) are allowed unless you add a rule.
  • A shared background server owns sessions and tools, so exposing opencode serve on the network needs a password.
  • The docs do not say that the execute.before plugin hook can block a tool call.

Claude Code

What it does well

  • Permission rules and hooks are enforced by Claude Code, not by the model, and deny rules apply in every mode.
  • Managed settings rank above user, project and command-line values, and admins can disable bypass and auto modes.
  • An OS-level sandbox with a domain allowlist and credential and filesystem controls is available, built on an open source runtime.
  • PreToolUse hooks can block a call before it runs, and onFailure: "block" makes a failed hook fail closed.
  • Transcripts and pre-edit file snapshots are kept locally, with claude purge and cleanupPeriodDays to control retention.

What to watch for

  • The sandbox is off by default and covers Bash, PowerShell and Monitor commands only. Edit, Read, Write, WebFetch, MCP servers and hooks run outside it.
  • Sandboxed reads cover most of the machine by default, including ~/.ssh, unless denyRead or similar settings narrow them.
  • A failed sandboxed command can be retried unsandboxed with dangerouslyDisableSandbox unless allowUnsandboxedCommands is false.
  • Bash rules match command text, so Bash(rm *) does not match /bin/rm or bash -c 'rm ...'. The docs point to the sandbox for stronger enforcement.
  • Transcripts are plaintext, so a value read from a .env file or printed by a command is written to ~/.claude/projects/.

Which should you pick

Pick OpenCode if

  • You want an open source agent (MIT) that works with many model providers or local models.
  • You are comfortable writing your own permission rules, starting from an open default.
  • You will run it in a container or VM when you need isolation.
  • You want to pay only for the model you use.

Pick Claude Code if

  • You want Claude models, and a default that reviews actions before they run.
  • You want an OS-level sandbox for shell commands with a network allowlist.
  • You want hooks that are documented to block a tool call before it runs.
  • Your company manages settings through MDM or the Claude admin console.

Running both

OpenCode reads CLAUDE.md in any folder that has no AGENTS.md, so instructions you wrote for Claude Code reach it. Its permissions are separate, though: a deny rule in Claude Code's settings.json means nothing to OpenCode, so write matching rules in opencode.jsonc.

Where Excellent fits

What Excellent doesOpenCodeClaude Code
Reads its session logs (free scan)
Yes
Yes
Key finder reads its key files
Yes
Yes
Live check before risky actions (Pro)
Yes, in its own hook settings
Yes, in its own hook settings
Before a force push to main
Refuses and tells OpenCode to ask you
Claude Code asks you first
Excellent's sandbox (Pro)
No
Yes, in its own sandbox settings
Rule sharing
No
Yes

Excellent reads the session logs of both OpenCode and Claude Code on your Mac. The free scan shows what each did: your email in request commands or form inputs, keys sitting in logs, secrets files read, history overwritten, checks skipped. Each finding says which agent and where.

With Pro, Excellent adds its live check to each one's own hook settings, after listing what it will change. The same rules apply to both: it blocks your email on its way to a website, an API key typed into a command, and deleting a folder you marked never-delete.

Excellent's sandbox and rule sharing are for Claude Code and Codex only, so here they apply to Claude Code. The check reads what a command says, so it isn't a wall around your Mac.

Questions

Is OpenCode safe to use?

It can be, with setup. Its default allows edits and commands without asking, and it has no sandbox. Add a rule that asks before shell commands, add an external_directory rule, and use a container or VM for untrusted code.

Does OpenCode have a sandbox?

No. OpenCode says its permission system keeps you informed and isn't a security boundary, and it recommends Docker or a VM for isolation.

Can OpenCode use Claude models?

Yes. OpenCode connects to many providers through models.dev, Anthropic among them, and you add one with /connect.

Does OpenCode read CLAUDE.md?

Yes, in any folder with no AGENTS.md, and it reads ~/.claude/CLAUDE.md when there is no global AGENTS.md. Set OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1 to turn that off.

Read more

Sources

More agent comparisons

All comparisons →

Check what OpenCode and Claude Code did on your Mac

Get the Mac app