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.
OpenCode
- Made by
- Anomaly (formerly SST)
- Out of the box
- The base policy allows every action and asks only before reading
.envfiles. 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 -pand Agent SDK runs start in Manual, which asks before edits, shell commands and network access. - Sandbox
- Yes, off by default. Turn on with
/sandboxorsandbox.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
On this page
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.
PreToolUse with exit code 2 or a deny5The basics
| Question | OpenCode | Claude Code |
|---|---|---|
Runs in | 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 | |
Models | Many providers through the models.dev catalog, connected with /connect, plus custom providers and local models.2 | |
Pricing | The app is free. You pay your model provider or an OpenCode plan.2 |
Safety controls
| Question | OpenCode | Claude 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 | 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 | |
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 | 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 | |
MCP servers | ||
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 | 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
- plan agentAsks for some actions
- Ordered permission rulesAsks for some actions
- Allow alwaysAsks for some actions
- build agentAsks for some actionsStarts here
Claude Code
- planAsks for some actions
- default (Manual)Asks before each action
- dontAskNever asks
- acceptEditsAsks for some actions
- autoAsks for some actionsStarts here
- bypassPermissionsNever asks
OpenCode modes in detail
| Mode | How to turn it on | Asks you | What 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
| Mode | How to turn it on | Asks you | What 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
| Path | What 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
| Path | What 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
Claude Code
Both, newest first
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 in2.1.251Uncontrolled search path let a malicious git executable run arbitrary code. Affects Claude Desktop, listed in the Claude Code repo. CVE-2026-88066.
Fixed inClaude Desktop 1.8089.0A plugin commit SHA pin could be bypassed, allowing installation of attacker-controlled code. CVE-2026-86063.
Fixed in2.1.179Arbitrary file write through write-time symlink following (a time-of-check to time-of-use race). CVE-2026-103435.
Fixed in2.1.129Managed settings were not applied when a stored API key was preferred over enterprise sign-in. CVE-2026-103012.
Fixed in2.1.260Claude Desktop on macOS: opening a malicious file from a Cowork folder could run commands on the host. Listed in the Claude Code repo.
Fixed inClaude Desktop 1.15962.0A cross-site request to
Fixed in/global/upgradeonopencode servecould make an npm, pnpm or Bun based install fetch an attacker-chosen package. Installs from curl, Homebrew, Chocolatey or Scoop were not affected.1.18.22Git worktree path confusion allowed a sandbox escape and unsandboxed code execution. CVE-2026-55607.
Fixed in2.1.163An insecure temporary file in the
Fixed in/copycommand allowed response disclosure and a symlink-based file write. CVE-2026-46406.2.1.128CVE-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 in1.1.10CVE-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 in1.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
.envreads, 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 serveon the network needs a password. - The docs do not say that the
execute.beforeplugin 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.
PreToolUsehooks can block a call before it runs, andonFailure: "block"makes a failed hook fail closed.- Transcripts and pre-edit file snapshots are kept locally, with
claude purgeandcleanupPeriodDaysto 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, unlessdenyReador similar settings narrow them. - A failed sandboxed command can be retried unsandboxed with
dangerouslyDisableSandboxunlessallowUnsandboxedCommandsisfalse. - Bash rules match command text, so
Bash(rm *)does not match/bin/rmorbash -c 'rm ...'. The docs point to the sandbox for stronger enforcement. - Transcripts are plaintext, so a value read from a
.envfile 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 does | OpenCode | Claude 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
- OpenCode: safety and how to run it
- Claude Code: safety and how to run it
- All agents Excellent works with
Sources
OpenCode
- OpenCode repository and README
- OpenCode docs: Intro and install
- OpenCode docs: Permissions
- OpenCode docs: MCP servers
- OpenCode docs: Enterprise and managed config
- OpenCode docs: Web and server
- OpenCode docs: Migrate from V1
- OpenCode security policy and threat model
- OpenCode security advisories
- OpenCode changelog
- OpenCode docs: Rules
- OpenCode docs: Troubleshooting
- OpenCode docs: Policies
- OpenCode docs: Server plugins
Claude Code
- Claude Code docs: Overview
- Claude Code docs: Permission modes
- Claude Code docs: Sandboxing
- Claude Code docs: Permissions
- Claude Code docs: Hooks
- Claude Code docs: Explore the .claude directory
- Claude Code docs: MCP
- Claude Code docs: Deploy managed settings
- anthropics/claude-code: LICENSE.md
- Claude pricing
- anthropics/claude-code: Security advisories




