Guardrails for AI coding agents in regulated industries

Guardrails for Claude Code and Codex where change control is audited: what SOX, PCI DSS, HIPAA and DORA ask, the settings, hooks and branch rules that answer it, and how to give an agent internal tools safely.

· 10 min read

Regulated change control asks four things of every change to a system in scope: that it was authorised, reviewed and tested before it reached production; that the person who wrote it is not the one who approved or deployed it; that access to production is limited to those who need it; and that there is a record of all of it. A coding agent such as Claude Code, Codex or Cursor gets no exemption. Treat it as one more author: what it writes goes through the same review, what it may touch is limited like any account, and its risky actions wait for a person.

None of the frameworks below mentions coding agents by name. They do not need to. Each one already says who may change what, and an agent fits into those words as another author with its own account.

What the frameworks ask

What SOX, PCI DSS, HIPAA, DORA and NYDFS ask of changes and access, and what each means for an AI coding agent
OptionWhat it asksFor a coding agent
SOX (US listed companies)What it asksSection 404 makes management report on internal control over financial reporting and, for larger companies, the auditor attest to it under PCAOB AS 2201. The Act lists no IT controls. Auditors test IT general controls for systems that feed the accounts, usually grouped as access to programs and data, program changes and computer operations.For a coding agentA change to a system in scope is a program change: it needs an approval by someone other than its author, and evidence an auditor can sample. The agent's access to those systems is reviewed like any other account's.
PCI DSS v4.0.1What it asks6.5.1: production changes follow a procedure with a reason, the security impact, documented approval by authorised parties, testing and a way back. 6.5.3 and 6.5.4: pre-production is separated from production, and roles are separated so only reviewed and approved changes are deployed. 6.2.3.1: manual code reviews are done by someone other than the author. 7.2.5: system accounts get least privilege. 10.2.2: logs record who, what, when, the result, the origin and what was affected.For a coding agentThe agent works in pre-production and cannot deploy what it wrote. Its account gets only the access it needs, its actions are logged under its own identity, and live card numbers stay out of its environment (6.5.5).
HIPAA Security RuleWhat it asks164.308(a)(4): policies for authorising access to ePHI. 164.312(a)(1): access only for persons or software programs granted access rights; 164.312(a)(2)(i): unique user identification. 164.312(b): mechanisms that record and examine activity. 164.308(a)(1)(ii)(D): regular review of those records.For a coding agentThe rule names software programs, so an agent that can reach ePHI needs its own grant and its own identity. Keep real patient data out of its workspace and log what it touches.
DORA (EU financial entities)What it asksArticle 9(4)(e): documented ICT change management so that all changes are recorded, tested, assessed, approved, implemented and verified in a controlled manner. Article 9(4)(c): access limited to legitimate and approved functions. Delegated Regulation 2024/1774, Article 17: independence between the functions that approve changes and those that request and implement them, and emergency changes approved after the fact.For a coding agentWhoever requests or implements a change cannot approve it. That excludes the agent, and in practice the person who directed it. Every change the agent makes needs the same record a person's would.
NYDFS 23 NYCRR 500What it asks500.7: access limited to what the job needs; few privileged accounts, used only for the functions that need them; all access reviewed at least once a year.For a coding agentAn agent's service account is a user for this purpose: scoped to its task, no standing admin rights, and in the annual access review.

This is a map, not legal advice. Your auditor or assessor decides how these apply to your systems, and the conversation goes better when you bring the controls below to it.

The agent and its driver are both authors

Separation of duties is where agents cause the most confusion. The agent cannot approve its own work, which is obvious. Less obvious: the engineer who prompted the agent and accepted its edits is on the author side too. If that engineer approves the pull request the agent opened, or the deploy the agent asked for, the author has approved their own change. The approver has to be someone else, and your controls should make that the only path, not a habit.

1. Where the agent runs

The strongest guardrail is what the machine does not hold. A coding agent that never has production credentials cannot misuse them, however it is prompted.

  • Run it in a sandbox, a dev container or a cloud workspace with no production credentials, no customer data, no card numbers and no patient records. Use synthetic or masked data.
  • Keep secrets out of the working tree. A .env file the agent can read ends up in its context, and from there in a log or a commit.
  • Limit network egress to the hosts the work needs: the Git host and the package registry. Claude Code’s own sandbox starts with no allowed domains, but by default it can still read most of the machine, including ~/.ssh and ~/.aws/credentials. Deny those reads too, or keep them off the machine.

2. What it can read and run

Both Claude Code and Codex let an organisation set limits a developer cannot loosen. In Claude Code, managed settings (/Library/Application Support/ClaudeCode/managed-settings.json on macOS, /etc/claude-code/managed-settings.json on Linux) sit above user and project settings. Rules are checked deny first, then ask, then allow. In Codex, /etc/codex/requirements.toml restricts the approval policies and sandbox modes a developer may pick, and its command rules must be prompt or forbidden. Before rolling out a Claude Code settings file, paste it into the settings checker: it flags allow rules that run any program or reach the network, and secrets nothing denies.

{
  "permissions": {
    "deny": [
      "Read(./.env)",
      "Read(./.env.*)",
      "Read(./secrets/**)",
      "Read(~/.aws/**)",
      "Read(~/.ssh/**)",
      "Bash(kubectl *)",
      "Bash(terraform apply *)"
    ],
    "ask": [
      "Bash(git push *)",
      "Bash(npm install *)",
      "Bash(psql *)"
    ],
    "disableBypassPermissionsMode": "disable"
  },
  "sandbox": {
    "enabled": true,
    "network": { "allowedDomains": ["github.com", "registry.npmjs.org"] }
  }
}
  • allowManagedPermissionRulesOnly in Claude Code’s managed settings makes them the only source of permission rules. Move every deny and ask rule you rely on there.
  • A Bash rule matches the command as the agent usually writes it, not every way of running the program, and Anthropic’s docs say it is not a security boundary. It is a guard rail; the wall is layer 1.
  • On Codex 0.138.0 or later, OpenAI’s docs prefer permission profiles (allowed_permission_profiles) to allowed_sandbox_modes.

3. A person before the risky step

Built-in prompts ask the person at the keyboard, who is the author. For steps that must be approved by someone else, the question has to leave the machine. A PreToolUse hook sends it to VariantGate, where a colleague answers from the inbox or a phone and the answer is recorded. The approval hooks article explains how the hook works; in managed settings it looks like this:

{
  "allowManagedHooksOnly": true,
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "variantgate hook claude-code",
            "timeout": 180,
            "onFailure": "block"
          }
        ]
      }
    ]
  }
}
  • allowManagedHooksOnly runs only the hooks your organisation deploys, so add a matcher here for every MCP server whose write tools should ask, such as mcp__jira__.*; developers cannot add their own. onFailure: block (Claude Code 2.1.295 or later) denies the call if the hook cannot run, instead of letting it through.
  • The hook waits two minutes for a person by default, then withdraws the request and denies the call. A denial tells the agent not to try another way.
  • If the hook runs but cannot reach VariantGate, it hands the call back to Claude Code’s own prompt, so the developer can keep working during an outage. That prompt is answered by the author at the keyboard, which is not separation of duties. So the steps that need a second person must not depend on the hook alone: keep them off the laptop with the deny rules above, and run them from the pipeline step below, which refuses to run without an approval.
  • Every shell command arrives as shell.run, so a rule cannot tell git push from ls. Gate all commands for unattended runs. For a session someone is watching, a hook’s if field can send only some commands, such as Bash(git push *); Claude Code’s docs call that filter best-effort.

Deploys and migrations should not run from the agent’s machine at all. Run them in the pipeline, under the pipeline’s own key, with a named action rules can tell apart. The step below asks, runs deploy.sh only on a yes, and reports the outcome. The details are in the production deploys and database migrations guides.

- name: Deploy once two people approve
  env:
    VARIANTGATE_API_URL: https://api.variantgate.com
    VARIANTGATE_KEY: ${{ secrets.VARIANTGATE_KEY }}
  run: |
    npx -y https://variantgate.com/sdk/variantgate-agent-0.3.0.tgz run --agent release-pipeline --action deploy.production \
      --summary "Deploy ${{ github.sha }} to production" \
      --details '{"commit": "${{ github.sha }}", "run_id": "${{ github.run_id }}"}' \
      -- ./deploy.sh ${{ github.sha }}

The request stays open for 15 minutes, so both approvals have to come in that window. If they do not, the step fails as not approved and nothing is deployed; rerun the job to ask again.

Owners then write rules that route each kind of change to the right people:

  1. Always ask about deploy.production, two people, for Ana, Ben and ChenTwo different people from the release group approve each production deploy. One denial stops it.
  2. Always ask about db.migrate.production, two people, for Dana and EvanSchema changes go to the two people who own the database, with the migration in the summary, so neither approves their own change alone.
  3. Always ask about shell.runEvery command a gated coding agent runs waits for a person, even if someone later remembers an answer as always: ask beats allow. With no deciders any member may answer, including the engineer driving the agent; for systems in scope, add deciders from outside the team.
The same rules as API bodies
# POST /v1/workspaces/{workspace_id}/rules, one call per rule
{
  "action": "deploy.production",
  "approvals": 2,
  "deciders": [
    "USER_ID_OF_ANA",
    "USER_ID_OF_BEN",
    "USER_ID_OF_CHEN"
  ],
  "effect": "ask"
}

{
  "action": "db.migrate.production",
  "approvals": 2,
  "deciders": [
    "USER_ID_OF_DANA",
    "USER_ID_OF_EVAN"
  ],
  "effect": "ask"
}

{
  "action": "shell.run",
  "effect": "ask"
}

Owners write rules under Rules in the app, or post these bodies while signed in. Replace the ids in capitals with your own.

Scope each agent key to what that agent may ask about. A coding agent’s key without deploy.* in its scope is refused if it asks to deploy by name. It does not stop ./deploy.sh typed into a shell, which the hook asks about as shell.run; what stops that is a laptop with no production credentials and the deny rules above. One switch, the emergency stop, denies every agent at once, and only an owner can resume.

VariantGate records who approved. It does not know who prompted the agent, so it cannot keep the author out of the vote by itself. Workspace owners can always decide a routed request, and any member can once its escalation time passes, so naming deciders narrows who is asked, not who may answer. Keep the engineers who drive agents out of the owner role, leave escalation off for changes in scope, and require two people, as the deploy rule above does, so that at least one approval comes from someone other than the author.

4. Review and merge

The code review is the control auditors know best, and most of it is already in your Git host. On GitHub, protect the main branch with a ruleset or branch protection:

  • Require a pull request with at least one approving review. GitHub does not let a pull request’s author approve it.
  • Turn on “Require approval of the most recent reviewable push”, so the last push is approved by someone other than the person who pushed it, and “Dismiss stale pull request approvals when new commits are pushed”.
  • Add a CODEOWNERS file and “Require review from Code Owners”, so changes to payment, auth, infrastructure and migration paths go to the people who own them.
  • Turn on “Do not allow bypassing the above settings”. By default, branch protection does not apply to admins.
  • Leave “Allow GitHub Actions to create and approve pull requests” off. The one setting allows both, so an agent that opens pull requests should push as its own GitHub App or bot account instead, with CODEOWNERS or two required reviews so no bot approval is ever enough.

Make the agent’s part visible. On a laptop the agent commits as the engineer; add a Co-authored-by trailer naming the agent, and GitHub’s rule already keeps that engineer from approving their own push. A background agent that pushes as a bot or GitHub App leaves a gap: the engineer who started it is not the pusher, so GitHub would accept their approval. Close it with CODEOWNERS, two required approvals for agent branches, or a written rule that the requester never reviews.

5. The record

Auditors test a control by sampling. For changes, they take the population of production changes in the period, check it is complete against a second source such as the deploy history, and ask for the authorisation behind each sampled one. For an agent-written change, have these to hand:

  1. The pull request, with the agent marked as author or co-author, the review by someone else, and the CI results.
  2. The deploy approval: who approved, when, and that it came before the deploy. variantgate run prints the request id in the job log; put it in the change ticket or release notes too.
  3. The commands the agent ran that were gated, and who allowed each, from the record.
  4. The settings and rules in force at the time, with their change history: who changed a rule, and when.

More on what auditors sample is in the evidence they ask for, and on logging each call in audit logs for agent tool calls.

How do you give a coding agent access to internal tools and context?

Give it its own identity, read access by default, and a person in front of every write. In practice:

  • Context as files or read-only tools. Architecture notes, runbooks and coding standards go into the repository’s context files (CLAUDE.md, AGENTS.md) or a docs MCP server that can only read. Leave out anything with secrets or customer data.
  • A service account per agent. The ticket tracker, the wiki, the error tracker and the internal API each get a token issued to that agent, scoped to read, with an owner and an expiry. Never an engineer’s personal token: the agent’s actions would look like theirs, and the access review would miss it.
  • Reads run free, writes ask. Put write tools on their own MCP server or behind a matcher such as mcp__jira__.*, and send them through the hook. The tool risk checker sorts a server’s tools into the ones that only look and the ones that act.
  • One list of servers. Claude Code’s allowManagedMcpServersOnly limits a developer to the MCP servers the organisation approved.

Setup for each tool is in the docs for Claude Code, Codex, Cursor and GitHub Actions.

Checklist

  • No production credentials, customer data or secrets where the agent runs.
  • Deny and ask rules in managed settings or requirements.toml, bypass mode disabled.
  • Deploys and migrations only from the pipeline, behind an approval from someone who did not write the change.
  • Branch protection with an independent review, CODEOWNERS on sensitive paths, and no admin bypass.
  • Each agent with its own key and service accounts, scoped, owned and in the access review.
  • A record that links each change to its review and approval, kept from the first day of the audit period.

For the wider picture beyond coding agents, start from the guide to AI agent guardrails. The approval policy generator writes the policy document these controls implement.

Sources

  1. 15 U.S.C. 7262: Management assessment of internal controls (Sarbanes-Oxley Act, section 404)
  2. PCAOB AS 2201: An Audit of Internal Control Over Financial Reporting That Is Integrated with An Audit of Financial Statements
  3. PCI Security Standards Council: PCI DSS v4.0.1, June 2024, Requirements 6.2.3.1, 6.5.1 to 6.5.6, 7.2.5 and 10.2.2
  4. 45 CFR 164.308: Administrative safeguards (HIPAA Security Rule)
  5. 45 CFR 164.312: Technical safeguards (HIPAA Security Rule)
  6. Regulation (EU) 2022/2554 on digital operational resilience for the financial sector (DORA), Article 9
  7. Commission Delegated Regulation (EU) 2024/1774 on the ICT risk management framework, Article 17
  8. New York DFS: 23 NYCRR Part 500, Cybersecurity Requirements for Financial Services Companies, section 500.7
  9. Claude Code docs: Configure permissions
  10. Claude Code docs: Deploy managed settings
  11. Claude Code docs: Hooks reference
  12. Claude Code docs: Sandboxing
  13. OpenAI Codex docs: Configuration reference
  14. OpenAI Codex docs: Managed configuration
  15. GitHub Docs: About protected branches
  16. GitHub Docs: Approving a pull request with required reviews
  17. GitHub Docs: Creating a commit with multiple authors