Skip to content

Commit 1d62126

Browse files
committed
docs: fix permission docs
1 parent a63fa64 commit 1d62126

File tree

4 files changed

+172
-150
lines changed

4 files changed

+172
-150
lines changed

packages/web/src/content/docs/agents.mdx

Lines changed: 36 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -362,42 +362,33 @@ Here are all the tools can be controlled through the agent config.
362362

363363
### Permissions
364364

365-
Permissions control what actions an agent can take.
365+
You can configure permissions to manage what actions an agent can take. Currently, the permissions for the `edit`, `bash`, and `webfetch` tools can be configured to:
366366

367-
- edit, bash, webfetch
368-
369-
Each permission can be set to allow, ask, or deny.
370-
371-
- allow, ask, deny
372-
373-
Configure permissions globally in opencode.json.
367+
- `"ask"` — Prompt for approval before running the tool
368+
- `"allow"` — Allow all operations without approval
369+
- `"deny"` — Disable the tool
374370

375371
```json title="opencode.json"
376372
{
377373
"$schema": "https://opencode.ai/config.json",
378374
"permission": {
379-
"edit": "ask",
380-
"bash": "allow",
381-
"webfetch": "deny"
375+
"edit": "deny"
382376
}
383377
}
384378
```
385379

386-
You can override permissions per agent in JSON.
380+
You can override these permissions per agent.
387381

388-
```json title="opencode.json" {7-18}
382+
```json title="opencode.json" {3-5,8-10}
389383
{
390384
"$schema": "https://opencode.ai/config.json",
385+
"permission": {
386+
"edit": "deny"
387+
},
391388
"agent": {
392389
"build": {
393390
"permission": {
394-
"edit": "allow",
395-
"bash": {
396-
"*": "allow",
397-
"git push": "ask",
398-
"terraform *": "deny"
399-
},
400-
"webfetch": "ask"
391+
"edit": "ask"
401392
}
402393
}
403394
}
@@ -419,83 +410,60 @@ permission:
419410
Only analyze code and suggest changes.
420411
```
421412

422-
Bash permissions support granular patterns for fine-grained control.
423-
424-
```json title="Allow most, ask for risky, deny terraform"
425-
{
426-
"$schema": "https://opencode.ai/config.json",
427-
"permission": {
428-
"bash": {
429-
"*": "allow",
430-
"git push": "ask",
431-
"terraform *": "deny"
432-
}
433-
}
434-
}
435-
```
436-
437-
If you provide a granular bash map, the default becomes ask unless you set \* explicitly.
413+
You can set permissions for specific bash commands.
438414

439-
```json title="Granular defaults to ask"
415+
```json title="opencode.json" {7}
440416
{
441417
"$schema": "https://opencode.ai/config.json",
442-
"permission": {
443-
"bash": {
444-
"git status": "allow"
445-
}
446-
}
447-
}
448-
```
449-
450-
Agent-level permissions merge over global settings.
451-
452-
- Global sets defaults; agent overrides when specified
453-
454-
Specific bash rules can override a global default.
455-
456-
```json title="Global ask, agent allows safe commands"
457-
{
458-
"$schema": "https://opencode.ai/config.json",
459-
"permission": { "bash": "ask" },
460418
"agent": {
461419
"build": {
462420
"permission": {
463-
"bash": { "git status": "allow", "*": "ask" }
421+
"bash": {
422+
"git push": "ask"
423+
}
464424
}
465425
}
466426
}
467427
}
468428
```
469429

470-
Permissions affect tool availability and prompts differently.
471-
472-
- deny hides tools (edit also hides write/patch); ask prompts; allow runs
473-
474-
For quick reference, here are common setups.
430+
This can take a glob pattern.
475431

476-
```json title="Read-only reviewer"
432+
```json title="opencode.json" {7}
477433
{
478434
"$schema": "https://opencode.ai/config.json",
479435
"agent": {
480-
"review": {
481-
"permission": { "edit": "deny", "bash": "deny", "webfetch": "allow" }
436+
"build": {
437+
"permission": {
438+
"bash": {
439+
"git *": "ask"
440+
}
441+
}
482442
}
483443
}
484444
}
485445
```
486446

487-
```json title="Planning agent that can browse but cannot change code"
447+
And you can also use the `*` wildcard to manage permissions for all commands.
448+
Where the specific rule can override the `*` wildcard.
449+
450+
```json title="opencode.json" {8}
488451
{
489452
"$schema": "https://opencode.ai/config.json",
490453
"agent": {
491-
"plan": {
492-
"permission": { "edit": "deny", "bash": "deny", "webfetch": "ask" }
454+
"build": {
455+
"permission": {
456+
"bash": {
457+
"git status": "allow",
458+
"*": "ask"
459+
}
460+
}
493461
}
494462
}
495463
}
496464
```
497465

498-
See the full [permissions guide](/docs/permissions) for more patterns.
466+
[Learn more about permissions](/docs/permissions).
499467

500468
---
501469

packages/web/src/content/docs/config.mdx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ You can configure code formatters through the `formatter` option.
249249

250250
### Permissions
251251

252-
You can configure permissions to control what AI agents can do in your codebase through the `permission` option.
252+
By default, opencode **allows all operations** without requiring explicit approval. You can change this using the `permission` option.
253+
254+
For example, to ensure that the `edit` and `bash` tools require user approval:
253255

254256
```json title="opencode.json"
255257
{
@@ -261,11 +263,6 @@ You can configure permissions to control what AI agents can do in your codebase
261263
}
262264
```
263265

264-
This allows you to configure explicit approval requirements for sensitive operations:
265-
266-
- `edit` - Controls whether file editing operations require user approval (`"ask"` or `"allow"`)
267-
- `bash` - Controls whether bash commands require user approval (can be `"ask"`/`"allow"` or a pattern map)
268-
269266
[Learn more about permissions here](/docs/permissions).
270267

271268
---

0 commit comments

Comments
 (0)