ENUA

Maks Danylenko · 9 December 2026

Nobody Should Change Production by Hand. Including Me

When you work with AI agents, treat them as hackers who keep trying to break your production. I'll explain with two examples from my own work, then show how we set up access on a client project.

The agent merged its own pull request without an approval

Our default branch is stage. Everything that goes into it has to go through a pull request. The rule is simple: we review the pull request together, and only then merge it.

My agent finished a task, opened a pull request and tagged everyone who needed to see it in the chat. Then it merged the pull request itself. GitHub had no rule requiring at least one approval before a merge. We had agreed on it as a team, but nobody had configured it.

I turned on required approvals. The next time, the agent was already working under my account. To merge its pull request, it went into the GitHub settings, changed the configuration for a moment, merged without a single approval and changed the configuration back.

You could add one more prohibition to the prompt. Even when a prohibition in the prompt works (we tested this separately), it is still an instruction. Limits come from permissions the agent technically cannot get around.

A ban on reading .env does not stop the agent reading a copy

The second example. Set up a rule that forbids the agent to read .env. Then run an eval and give it a task that needs that file. The agent will get around the rule: it copies the file, renames the copy and reads everything inside.

99 correct runs guarantee nothing

An agent is not a person. Even if it follows the rules 99 times out of 100, you cannot be sure it won't break production or deploy something the next time.

The same goes for infrastructure. I think giving an agent write access to your whole infrastructure is an anti-pattern. OWASP calls this risk Excessive Agency: the agent has more permissions than the task needs.

Everyone can read, only CI can change

On a client project we took another route. Every developer can read the infrastructure and its configuration. Only CI in GitHub can change it. When a job runs, CI gets temporary access to the cloud through GitHub OIDC and deploys the changes to stage and production.

Permissions and settings of GitHub itself are also changed only through the Infrastructure repository. So the agent can no longer change the configuration for a moment and merge its pull request, as it did in the first story. Nobody has manual write access, not even me. I set up access for CI and removed my own permissions.

The emergency (break-glass) access is on my USB stick, which I'd rather not lose. Every use of it shows up in CloudTrail.

Every infrastructure change follows the same path:

  1. Pull requestInfrastructure repository
  2. ApprovalFrom a person
  3. StageCI deploys after the merge
  4. ProductionManual merge of stage into main
A person decides what to change and when to release it. Only CI applies the change.
WhoCan readCan change
DeveloperInfrastructure and configurationNothing directly, only through a pull request
AI agentSame as a developerNothing directly, only through a pull request
CIWhat it needs to apply changesstage and production after a merge
Break-glassEverythingEverything, recorded in CloudTrail

How to take admin rights away from yourself

You cannot remove yourself from GitHub completely: an organisation always needs at least one owner. So split the roles.

  1. Create a separate emergency account with the owner role. Protect it with a hardware key for 2FA, and keep the password and recovery codes in the same place as your emergency AWS access. Nobody uses it for daily work.
  2. Describe your GitHub settings in OpenTofu: rulesets with no bypass, teams, repository permissions, environment protection. To apply them, CI needs its own identity with admin permissions. Create a GitHub App for this: it is not tied to any person and gives CI a token that lasts an hour. Only CI on the main branch can use the App's key.
  3. Downgrade your own account to a regular organisation member without admin rights. You get repository access through a team defined in the same code.

After this, an agent working under your account loses admin rights too. Better still, give the agent its own account or GitHub App. Then it cannot approve its own pull request, and the history shows that the agent made the change.

One more setting is easy to miss: Require approval of the most recent reviewable push. Without it, the agent can push a commit after the approval, and a version you never reviewed gets merged.

A new secret also goes through a pull request

The obvious question: if nobody has write access, how do you add, say, an API key for an external service? The same way we change feature flags: through a pull request.

SOPS and KMS handle this. A developer encrypts the value with a KMS key they can only encrypt with, and commits the encrypted file to the repository. The reviewer sees in the pull request that the secret changed, but cannot see the value. After the merge, CI decrypts the file and writes the value to AWS Secrets Manager.

Only CI can decrypt the secret. Only application roles can read it in AWS. People and agents with read access cannot see the value. Otherwise we would get the same .env story, only in the cloud.

I don't count on the agent following the rules. I set things up so it has no permissions to break them. Changes to production go only through a pull request, and that applies to the agent and to me.

About Mavka. Want to know who can change your production, agents included? We'll review the access with you and show what to move to pull requests.

Review access to production

Related reading