Stop AI agents from deploying without approval
DueReason Gate in two layers: a policy that blocks the agent's shell, write and MCP calls, plus a target-side check that stops a bypassed gate.
Updated · 7 min read
In short
- A gate inside the agent's harness (Claude Code, Hermes, a git hook) blocks a matching shell command, file write or MCP call until the request it files is fully approved, then hands back a signed grant.
- That gate alone only stops the agent: anyone with shell access on the same machine can skip it. The second, required layer is a check at the target -- a required GitHub status check or duereason-gate verify -- that refuses on its own.
- Settings > Agent gate generates the three pieces at once: the action and workflow, a minimally-scoped API key, and a .duereason/gate.yml policy plus install snippets for the harness you use.
- Claude Code, Cursor, Hermes, OpenCode, Codex, Gemini CLI, Windsurf, a generic git pre-push hook and a standalone MCP proxy each already have a real duereason-gate adapter in the codebase, and @duereason/gate is published to npm, so every one of them is installable by a customer today.
An agent that can run shell commands, write files or call MCP tools can also run git tag v2.0.0 && git push --tags, terraform apply, or a Stripe refund tool, the moment it decides that is the next step. DueReason Gate puts a policy in front of exactly those calls, scoped to the ones you name, so the agent asks first instead of acting first. This guide covers deploys specifically; approving AI agent actions walks through the same two-layer pattern for payments, data deletions and other agent-triggered actions.
Two layers, both required
- The gate inside the harness.
@duereason/gatereads one normalized event per tool call (shell command, file write/edit, or MCP call) from a thin per-harness adapter, matches it against a policy, and either lets it through unmatched, blocks it while a request is filed and decided, or denies it outright. This is a guardrail against the *agent*: it only runs where the harness itself chooses to call it. - Verification at the target. Anyone with shell access on the machine running the agent can comment out a hook, edit
.duereason/gate.yml, or run the deploy script directly. The system that actually performs the protected action has to refuse on its own when nothing approved exactly this payload: a required GitHub status check, a step at the top of the deploy job, orduereason-gate verifyfor CI that is not GitHub Actions. See the production deploys guide for exactly where to put each one. GitHub Environments' own required reviewers cover a related but different problem; see the comparison with an approval gate for where each stops.
Sell and document both layers. The first alone is convenience, not security.
What ships in the gate today
@duereason/gate's CLI (duereason-gate) reads a policy file (.duereason/gate.yml, merged with ~/.config/duereason/gate.yml) of rules matching a tool call's command, file paths, or MCP server/tool against a regex or glob, and renders a DueReason request from it -- title, reason and payload all templated from the match, the git context and an explicit allow-list of environment variables. npm install -g @duereason/gate installs it, the same command the Settings > Agent gate page shows per harness. duereason-gate install wires a real adapter into the harness's own hook mechanism for Claude Code, Cursor, Hermes, OpenCode, Codex, Gemini CLI, Windsurf and git-hooks (a pre-push hook for anything that can only run commands); duereason-gate mcp-proxy wraps any other MCP server so its tools/call requests are decided the same way. A harness with no adapter at all still wraps the command it would have run in duereason-gate exec: the gate decides it, runs it only if allowed, and reports the real exit code back as the execution outcome.
Setting it up from the console
Settings > Agent gate (owner/admin) turns the manual version of this into one page: pick Production deploys, Payments, Data deletion, or Custom to point it at an action you already created. Picking a template creates its action (with a payload schema matched to the policy below -- repository/commit/environment/tag for deploys, amount/currency/customer for payments, database/statement hash for deletions) and a starter workflow, both editable afterwards in the same workflow editor as anything else. The page then issues an API key scoped to exactly approval:request, approval:read and action:read -- shown once, like every DueReason key -- and generates the .duereason/gate.yml policy and the install command for the harness you pick, ready to paste.
A production-deploy policy, end to end
```yaml rules:
- match: tool: shell command: "^git tag (v[0-9][^\\s]*)" action: gate.production-deploy title: "Tag {{match.1}} on {{git.repo}}" reason: "An agent on branch {{git.branch}} wants to create release tag {{match.1}}." payload: repo: "{{git.repo}}" sha: "{{git.sha}}" environment: production tag: "{{match.1}}" mode: wait timeout: 1800
```
mode: wait blocks the agent's turn for up to 1800 seconds while the request is decided, then hands back a signed, single-use grant bound to this exact payload. mode: deny instead answers immediately with a console link, for a harness (Hermes, most chat-style agents) where blocking a live turn for half an hour is worse than the agent simply trying again later. An event that matches no rule is allowed offline, with no network call at all -- the gate only ever costs you a request for the calls you named.
Why the target-side check still matters
A request approved through this policy produces a grant: a signed, payload-bound token the executing system can check offline against DueReason's published keys. duereason-gate verify --action gate.production-deploy --payload '{"repo":"acme/shop","sha":"abc123","environment":"production"}' runs the same lookup-and-verify-offline check as a required GitHub status check, without ever having filed the request itself, and exits non-zero with a reason when nothing approved exactly this payload. Put it as the first step of the deploy job, not only as a pull-request check: a branch protection rule stops a merge, never a later manual re-run or a rollback to an older commit.
Questions
- Does installing a Claude Code or Hermes adapter widen what the agent can already do?
- No. An allow from the gate emits no output for Claude Code (its own permission system still runs) and returns None for Hermes (no opinion, the normal tool/approval flow is unaffected). The gate only ever narrows a call further, by blocking or filing a request for what the policy matches.
- What happens to a call the policy does not mention?
- It is allowed, offline, with no network call. The gate costs you a request only for the tool calls a rule actually matches.
- Is the in-harness gate enough on its own?
- No. Anyone with shell access to the same machine can bypass a hook or edit the policy file. The gate stops the agent; a required status check or duereason-gate verify at the target stops the action itself, independently of whatever ran on the agent's machine.
- What if my harness has no dedicated adapter?
- Wrap the command you would have run in duereason-gate exec instead: it decides the call, runs it only when allowed, and reports the real exit code as the execution outcome. Claude Code, Cursor, Hermes, OpenCode, Codex, Gemini CLI, Windsurf and git-hooks already cover the common cases, and a standalone MCP proxy covers any other MCP server.
Set up the Agent gate from your console
Settings > Agent gate creates the action and workflow, issues a scoped API key and generates the policy and install command for your harness in one page.
Read the API docsSources
This guide explains the regulation as we read it; it is not legal advice. Check the official text and your national law, which may add obligations.