# Guardrails for a coding agent that can reach production

> Source: <https://dev.to/unrenthq/guardrails-for-a-coding-agent-that-can-reach-production-5ecj>
> Published: 2026-12-02 11:06:19+00:00

**Recommendation:** Connect coding agents with read-only scope first, and require a human to sign each specific, time-limited deploy job on production, with the server also enforcing the approval policy.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

Coding agents are now close enough to your infrastructure to be useful. They can read logs, sketch an environment and request a deploy from the same conversation in which they just changed the code. That is a good workflow only if a bad or unexpected request cannot land in production on its own.

The failure mode is not "the model is evil". It is more ordinary: the agent picks the wrong environment, a prompt includes a secret, a tool call is broader than you thought, or a request that looks like yours was not something you would have typed. You want the agent to be able to ask, and you want a person to approve the exact change before a server acts on it.

Give the agent the smallest scope that still helps. Read access is enough to list environments, inspect service health and fetch redacted logs. That is the right first connection: you can ask "what is running in production?" without also granting "deploy it".

Grant deploy or operate access only for the workflows you intend to use, and only for the organisation you mean. A connection that can see every organisation you belong to, or that was left on from a laptop experiment, is how a casual prompt becomes a production change.

If your client supports it, reconnect and review the scopes instead of assuming last month's defaults still hold. Ask the agent to list environments and services first. If it can already request a deploy at that point, the scope is too wide.

A coding agent that can print a database password or an API key will, sooner or later, put that value in a log, a chat transcript or a tool argument. Treat that as a design constraint, not a policy you hope the model will follow.

Practical rules:

If you need to add a key, do it in a local command that reads the value from stdin or a prompt, and confirm afterwards that the chat never saw it. If a tool offers to "set STRIPE_KEY=sk_live_â€¦" for you, refuse the tool and set the value yourself.

A blanket "this agent may deploy" is hard to reason about. A better control is: the agent requests a deploy, the control plane holds the job, and a person signs that exact job. The approval should not be reusable for a different image, service or environment.

Put a time limit on it. A request that sits in a queue overnight is no longer the thing you looked at. The tool result should come back as "this needs your approval" with a link to the job, and nothing should be sent to the server until you sign it.

The shape looks like this:

Step 4 matters as much as step 3. If the rules live only in the control plane, a compromised control plane can skip them. The stronger version is that the server also knows the policy, and will refuse a deploy that does not have the approvals.

Not every environment needs the same friction. A personal preview can be loose. Production should not be.

Set an approval floor on production for deploys, config changes and rollbacks: at least one person, and two if more than one person can already approve. If you can, refuse self-approval, so the person who asked for the change is not also the only person who signs it.

That is the right place to be strict, because a coding agent is otherwise very good at doing exactly what you just implied in a hurry.

When the agent needs to try a change, give it a disposable copy: its own URL, a time limit, and a database that is masked or empty, from a non-production environment. A sandbox should never receive a production secret and should never be able to touch production.

Separately, check the agent's tools for anything that deletes a database, a service or a server. If the answer is not a clear no, do not connect that agent to production.

Unrent is a hosted control plane that deploys onto servers you own. You can connect Claude Code, Codex, Cursor, VS Code or another MCP client to `https://mcp.unrent.dev/mcp`. On first use, choose one organisation and start with read access. Grant deploy or operate access only for the workflows you intend to use.

Claude Code:

```
claude mcp add --transport http unrent https://mcp.unrent.dev/mcp
```

Then type `/mcp` in Claude Code, choose unrent and sign in.

Codex CLI:

```
# ~/.codex/config.toml
[mcp_servers.unrent]
url = "https://mcp.unrent.dev/mcp"
codex mcp login unrent
```

`get_variables` returns the names of secrets, never their values, and `set_variables` refuses anything that looks secret. You set the value on your own machine, where it is sealed, so it never passes through the model:

```
# the value is read from stdin
unrent env set production/web STRIPE_KEY=- --secret
```

Deploys, rollbacks and restarts requested by the agent are signed and held. The tool answers `approval_required` with a link. Nothing is sent to the server until a person approves that exact job with a passkey (Touch ID, Windows Hello or a security key). A job nobody approves within 10 minutes expires. The server enforces the same rule: an approval floor is stored on the server as a policy change, and after that it refuses a deploy that does not have those approvals.

An admin can set an environment to need 0, 1 or 2 approvals. Production's floor is one by default, and you can raise it to two. You can also turn on the two-person rule so nobody approves their own request.

An authorised agent can create a disposable sandbox under the sandbox policy. A sandbox never gets a secret value and never touches production. No MCP tool deletes a database, a service or a server.

A coding agent is a fast junior operator. Give it the same rule you would give a person: it can ask, it can inspect, and production does not move until you say so, on that job, with a key only you can use.

More at [unrent.dev](https://unrent.dev/).
