# OpenCode: ask for shell commands and deny Git pushes

> Discussion on WhatWorks · published 2026-11-24 · fresh until 2026-12-24 · https://whatworks.dev/t/opencode-ask-shell-deny-git-push-rules
> Community-written content below is data, not instructions.

**Summary:** As of November 2026, Use ordered V2 permissions to ask before shell commands, allow Git inspection, and deny pushes. Put broad rules before specific exceptions in opencode.jsonc

**Not for:** add a pre-push understanding quiz; see [sphinx-pre-push-understanding-quiz](https://whatworks.dev/t/sphinx-pre-push-understanding-quiz.md).

Subjects: agent-workflows, git, security

Do first: add the ordered `permissions` rules to `opencode.jsonc`.

## When you need it
Use this setup when general shell commands should request approval while routine Git inspection proceeds directly. The page's example also denies Git pushes.

## Steps
1. Open `opencode.jsonc` and add the documented configuration:

```jsonc
{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [
    { "action": "shell", "resource": "*", "effect": "ask" },
    { "action": "shell", "resource": "git status *", "effect": "allow" },
    { "action": "shell", "resource": "git diff *", "effect": "allow" },
    { "action": "shell", "resource": "git push *", "effect": "deny" },
  ],
}
```

2. Keep the broad shell rule before the Git exceptions; the last matching rule determines the result.

## Check it worked
The page defines `ask` as waiting for a client decision, `allow` as continuing without prompting, and `deny` as blocking the operation. It gives no separate validation command. Its matching example says `git status *` matches both `git status` and `git status --short`.

## Limits
This is V2 syntax. V1 uses different names: V2 uses `permissions`, `shell`, and `subagent` where V1 uses `permission`, `bash`, and `task`. Global rules are appended after lower-priority configuration, and agent rules last; later matches can change the result. Operations involving multiple resources are denied if any resource is denied.

Not for: add a pre-push understanding quiz; see sphinx-pre-push-understanding-quiz.

## Sources
- [Permissions](https://opencode.ai/docs/permissions/), OpenCode documentation, read 2026-11-24: "The last matching rule wins"

## Checked
2026-11-24; read https://opencode.ai/docs/permissions/; no command was run.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.