Skip to content

feat: align permission defaults with Claude Code#30

Merged
terisuke merged 3 commits intodevfrom
feat/align-permission-defaults-with-claude-code
Apr 4, 2026
Merged

feat: align permission defaults with Claude Code#30
terisuke merged 3 commits intodevfrom
feat/align-permission-defaults-with-claude-code

Conversation

@terisuke
Copy link
Copy Markdown

@terisuke terisuke commented Apr 4, 2026

Summary

  • Expands .opencode/opencode.jsonc permission config to mirror Claude Code's acceptEdits + allow-list model
  • Adds pattern-based bash whitelist for common dev tools (git, gh, node, npm, bun, python, curl, docker, etc.)
  • Adds explicit deny rules for dangerous operations (rm -rf, sudo, force-push, curl-pipe-sh)
  • Adds .env/secrets deny rules for read and edit operations
  • Sets glob/grep/list/websearch/webfetch/codesearch/lsp/task/skill to "allow"

Motivation

OpenCode's default permission config only specifies one deny rule (packages/opencode/migration/*), causing all other tool operations to fall through to "ask". This results in significantly more approval prompts compared to Claude Code, which has a broad allow-list and acceptEdits mode.

Closes #28

Test plan

  • Start OpenCode TUI with updated config
  • Verify read/edit/glob/grep operations proceed without prompts
  • Verify bash commands (git, npm, bun, ls) auto-approve
  • Verify dangerous commands (rm -rf, sudo) are blocked
  • Verify .env file access is denied

🤖 Generated with Claude Code

Reduce excessive approval prompts by expanding OpenCode's permission
config to mirror Claude Code's ergonomic defaults: auto-allow for
read/edit/glob/grep/web tools, pattern-based bash whitelist for common
dev commands, and explicit deny rules for dangerous operations.

Closes #28

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 4, 2026 10:32
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the repository’s checked-in OpenCode configuration to reduce permission prompts by expanding .opencode/opencode.jsonc with a Claude Code–style allow/deny ruleset (broad allows for common tools, explicit denies for sensitive operations/files).

Changes:

  • Expands permission.read / permission.edit defaults to allow-by-default with deny exceptions.
  • Adds a pattern-based permission.bash whitelist for common dev commands plus targeted deny rules.
  • Sets several non-file tools (glob/grep/list/websearch/webfetch/codesearch/lsp/task/skill) to "allow", while keeping external_directory at "ask".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +57 to +59
"cat *": "allow",
"head *": "allow",
"tail *": "allow",
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description/test plan says .env access should be denied, but the bash whitelist includes cat * (and other file-reading tools). That allows cat .env without prompting/denial, bypassing the read/edit deny rules. If the intent is to block .env/secrets access, consider removing cat from the allow-list (leave it as ask) and/or adding explicit bash deny patterns for .env*/**/.env* and **/secrets/** (plus similar read utilities like head/tail).

Suggested change
"cat *": "allow",
"head *": "allow",
"tail *": "allow",
// File-reading commands must not bypass sensitive-file deny rules
"cat .env": "deny",
"cat .env.*": "deny",
"cat **/.env": "deny",
"cat **/.env.*": "deny",
"cat secrets/**": "deny",
"cat **/secrets/**": "deny",
"head .env": "deny",
"head .env.*": "deny",
"head **/.env": "deny",
"head **/.env.*": "deny",
"head secrets/**": "deny",
"head **/secrets/**": "deny",
"tail .env": "deny",
"tail .env.*": "deny",
"tail **/.env": "deny",
"tail **/.env.*": "deny",
"tail secrets/**": "deny",
"tail **/secrets/**": "deny",
"cat *": "ask",
"head *": "ask",
"tail *": "ask",

Copilot uses AI. Check for mistakes.
// Dangerous operations: deny (Claude Code denies: rm -rf, sudo, force-push)
"rm -rf *": "deny",
"sudo *": "deny",
"git push --force*": "deny",
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

git push --force* won't match common force-push forms like git push origin main --force or git push --force-with-lease because the pattern requires --force immediately after git push. Since git * is allowed above, those commands would be allowed. Consider adding deny patterns such as git push * --force* (and potentially git push * --force-with-lease*) to reliably block force pushes.

Suggested change
"git push --force*": "deny",
"git push --force*": "deny",
"git push * --force*": "deny",
"git push * --force-with-lease*": "deny",

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +29
// Edit operations: allow by default (Claude Code's acceptEdits mode)
// Deny migration files and sensitive configs
"edit": {
"*": "allow",
"packages/opencode/migration/*": "deny",
".env": "deny",
".env.*": "deny",
"**/.env": "deny",
"**/.env.*": "deny",
},
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says it adds .env/secrets deny rules for both read and edit, but edit only denies .env* patterns and does not deny secrets/** (or **/secrets/**). Either add the secrets deny patterns under edit as well, or update the PR description to match the actual behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +18
"read": {
"*": "allow",
".env": "deny",
".env.*": "deny",
"**/.env": "deny",
"**/.env.*": "deny",
"secrets/**": "deny",
"**/secrets/**": "deny",
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In read, patterns like .env and .env.* are unlikely to match because the Read tool checks permissions against an absolute file path (e.g. /repo/.env). The **/.env* entries will work, but the non-globbed variants are effectively dead rules and can be misleading. Consider using patterns like *.env / *.env.* (as in the guardrails configs) or dropping the redundant entries to keep the rule set clear.

Copilot uses AI. Check for mistakes.
terisuke and others added 2 commits April 4, 2026 19:38
Add turbo, bunx, npx, yarn, tsc, eslint, prettier, biome, jest,
vitest, playwright, and common Unix utilities. Also add git push -f
deny pattern to complement --force variant.

Ref #28

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude Code allows these tool operations unconditionally. Adding them
reduces unnecessary approval prompts for AI-initiated questions and
todo management.

Ref #28

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@terisuke terisuke merged commit 0873ac4 into dev Apr 4, 2026
2 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: align OpenCode permission defaults with Claude Code for reduced approval prompts

2 participants