Loading...
Loading...
Manage OpenCode's permission rules in opencode.jsonc — add, remove, or list auto-approval rules for Bash commands and tool invocations so the agent stops asking for confirmation on every single command. Use whenever the user wants to auto-approve, deny, or require confirmation for a shell command, even if they don't mention "permission" or "opencode.jsonc" directly. Triggers on "允许 kubectl get *", "拒绝 rm -rf", "auto-approve npm run build", "总是执行 git status", "add permission rule", "list my permissions", "查看权限", "添加权限", "移除权限", "把 X 加到允许列表", "skip confirmation for", and similar — even if the user doesn't explicitly mention OpenCode's config.
npx skill4agent add cnife/skills opencode-permissionpermission~/.config/opencode/opencode.jsonc"kubectl get *"allowaddremovelistlist-allformat# 单条添加
uv run --script <skill-path>/scripts/manage_permission.py add "kubectl get *" --action allow
# 批量添加
uv run --script <skill-path>/scripts/manage_permission.py add "kubectl get *" "kubectl describe *" "kubectl logs *"addremoveformatopencode.jsonc.YYYYMMDDTHHMMSS.bakaddremoveadd# 单条(默认 action=allow)
uv run --script manage_permission.py add "kubectl get *"
# 批量添加
uv run --script manage_permission.py add "kubectl get *" "kubectl describe *" "kubectl logs *"
# 指定 action
uv run --script manage_permission.py add "git commit *" --action ask
uv run --script manage_permission.py add "rm -rf *" --action deny
# 自定义配置路径
uv run --script manage_permission.py add "kubectl get *" --config /path/to/opencode.jsoncuv run --script manage_permission.py remove "kubectl get *"# List permission.bash only
uv run --script manage_permission.py list
# List all permission categories (bash, read, edit, etc.)
uv run --script manage_permission.py list-all# 格式化 bash 规则(一行一条,自动备份)
uv run --script manage_permission.py format| Value | Meaning |
|---|---|
| Auto-execute, no confirmation needed |
| Prompt for confirmation each time |
| Block the command entirely |
| Symbol | Meaning | Example |
|---|---|---|
| Matches zero or more characters | |
| Matches exactly one character | |
"git status"git status"git status *"| Key | Matches | Description |
|---|---|---|
| Shell command pattern | Command execution (e.g., |
| File path | File reading operations |
| File path | File modifications (edit/write/patch) |
| Glob pattern | File wildcard search |
| Regex pattern | Content search |
| Directory path | Directory listing |
| Subagent type | Subagent spawning |
| LSP query | Language server queries |
| Skill name | Skill loading |
| File path | Access outside working directory |
| — | Todo writing (simple, no pattern matching) |
| — | Asking user questions (simple) |
| URL | Web fetching (simple) |
| Search query | Web/code search (simple) |
| — | Repeated tool call detection (simple) |
"allow""ask""deny""*""*": "ask"allow~$HOME~/.config/opencode/opencode.jsonc<project>/.opencode/opencode.jsonc///* */{
"permission": {
"edit": "ask",
"bash": {
"*": "ask",
"kubectl get *": "allow",
"git status *": "allow"
}
}
}agentuv run --script manage_permission.py add \
"kubectl get *" \
"kubectl describe *" \
"kubectl logs *" \
"kubectl top *" \
"kubectl explain *" \
"kubectl diff *" \
"kubectl auth can-i *"uv run --script manage_permission.py add "git commit *" --action allow
uv run --script manage_permission.py add "git push *" --action askuv run --script manage_permission.py add "rm -rf *" --action denyuv run --script manage_permission.py formatuv run --script manage_permission.py listjson-fivepermission.bashaddremoveformatopencode.jsonc.20260428T153045.bak