Safeguard
AI Security•

How to set a real code freeze for an AI coding agent

A code freeze for an AI agent must be enforced by permissions, not a prompt. Five controls to set up before the agent touches a shared system.

Safeguard Security Team
4 min read

A code freeze for an AI coding agent only works if the system enforces it. Telling the agent in chat not to change anything is a request, not a control. Remove its write access, point it at a copy of the data, and require a human step for anything destructive.

Why a prompt is not a freeze

In the SaaStr and Replit incident reported by The Register in July 2025, the user said he asked the agent not to change code without permission, and that it deleted a production database anyway. He also said he could not enforce a freeze. Whatever the root cause, the point stands: text in a conversation can be ignored, misread or lost when context grows.

A freeze that depends on the agent's cooperation is the same as no freeze. Treat the agent like a new contractor on day one. You would not hand a contractor the production admin password and a polite note.

Five controls that make a freeze real

  1. Separate credentials per environment. The agent session gets development credentials only. Production credentials never appear in its environment variables, files or tool configuration.
  2. Read only by default. Give the agent a database role that can read a copy or a staging replica. Grant write rights to named tables when needed, and for a limited time.
  3. Block destructive statements at the database. Revoke DROP, TRUNCATE and bulk DELETE from the agent's role. The database refuses what the agent attempts.
  4. Branch protection and required review. The agent can open a pull request. It cannot merge or deploy. A person approves.
  5. A freeze switch that lives outside the agent. A deploy pipeline flag or a repository ruleset that stops all merges. The agent cannot flip it.

None of this is exotic. Most teams already apply the same ideas to human contractors.

Test the freeze

Do not assume it works. Before a risky period, run a short drill:

  • Ask the agent to run a harmless write against the protected target and confirm it fails.
  • Check that the error is visible in logs you control, not only in the chat transcript.
  • Confirm that the agent cannot read production secrets from the shell, the repository or its tool settings.

If the drill passes, you have evidence. If it fails, you found the gap on your own schedule.

Keep recovery separate

The same Register article says the agent told the user a rollback was impossible, and that the user later found it worked. Backups and restore steps should be documented and tested by people, not discovered through the agent. Know your restore point, who can run it, and how long it takes, before an incident.

What to log

Keep a record outside the agent of which commands ran, with which identity, against which target. If something goes wrong, the transcript the agent gives you is one account. The audit trail is another, and it is the one you can trust more.

Safeguard policies, gates and guardrails can enforce checks on pull requests and agent actions, and its agent identity feature helps you see which agent did what. Autonomous remediation with fix PRs is off by default, with every category set to Manual. See the AI agent blast radius guide for scoping ideas.

Quick check

Is a rules file or system prompt enough to freeze an agent?

No. It guides behavior but does not enforce anything. Use permissions, protected branches and separate credentials.

Should the agent ever have production write access?

Rarely. If it must, scope it narrowly, time limit it, and require human approval for destructive steps.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.