In July 2025 SaaStr founder Jason Lemkin reported that Replit's coding agent had deleted the production database of his new app, despite a code freeze. Replit CEO Amjad Masad confirmed the deletion. The agent then declared a rollback impossible. The rollback worked, according to Lemkin and Replit.
One detail interests me: the code freeze was a line in a text file. A sentence where a lock belongs. The agent even knew about it, and quoted it afterwards. And instead of writing a better prompt, Replit separated dev and prod by default. That is the whole lesson. The rest of this piece is implementation.
Coding agents are fast and very sure of themselves, even when they are wrong. You may know colleagues like that, but colleagues type more slowly.
We let agents into our dev environment every day, with real clusters and real services. So our rules live in the tool an agent uses to talk to the platform. There are three guardrails.
1. Read and write are separate
Every tool our MCP server offers has a class in the code: read, tenant_mutation, destructive, billing or sensitive. Whatever only reads goes through. Everything else stops at a gate.
2. Preview first, then confirmation
A write doesn't run on the first call. The server returns what would happen, plus a token bound to exactly this call: same tool, same arguments. If the agent changes an argument, the token no longer matches.
For anything that can't be undone, costs money or hands out credentials, the server goes one step further. If the client supports asking the user (MCP calls this elicitation), the question lands there. The answer comes from the client's UI and bypasses the model. If the person declines or the question fails, nothing happens.
The platform decides what is allowed after that. An agent can never do more than the person who started it. And if you let your agent auto-approve everything, you have taken the guardrail off yourself.
3. Secrets stay out
Treat whatever sits in a model's context as published. So the agent only starts the login, the person confirms it in the browser, and the token ends up in the operating system's keychain. Database passwords are generated locally by the tool and written straight to the vault. The agent only sees the path. Git only holds references.
What you can build without us
The pattern works for any internal tool and any MCP server. Four rules are enough to start with:
- Every tool has a class in the code. Without an entry it counts as a write.
- A write only runs on the second call, bound to exactly these arguments.
- Whatever can't be taken back asks a human, through the client. If the question fails, it counts as declined.
- The agent gets its own account with the permissions for exactly this job, and secrets go around its context.
Rules 1 and 2 fit in a few lines:
import hashlib, hmac, json
CLASSES = {"project_list": "read", "project_delete": "destructive"}
def gate(tool, args, token=None):
if CLASSES.get(tool, "write") == "read":
return run(tool, args)
expected = hmac.new(
SECRET,
json.dumps([tool, args], sort_keys=True).encode(),
hashlib.sha256,
).hexdigest()
if token is None or not hmac.compare_digest(token, expected):
# The agent only gets a preview.
return {"code": "confirmation_required", "token": expected}
return run(tool, args)
The token only proves a second call. For the human you need the question in the client.
What permissions does your coding agent have today? Be honest.
Sources
- Jason Lemkin: post on the code freeze and the deletion, 18 July 2025
- Jason Lemkin: the rollback did work, 18 July 2025
- Amjad Masad, CEO of Replit: statement, 20 July 2025
- Replit: separating dev and prod, 29 July 2025
- MCP specification 2026-07-28: principles on consent and control
- MCP specification 2026-07-28: Tools
- MCP specification 2026-07-28: Elicitation