Beta
Start for free

ResourcesHow-to

4 steps to set AI agent guardrails: operations people keep, merge conditions, cost, and monitoring

AI agent guardrails are four lines you decide before widening what agents do: operations people keep, merge conditions, choices that cost money, and monitoring. They're enforced by permission rules, required checks, and human sign-off rather than by written instructions. Once you separate the operations people keep from the ones mechanisms block, you know which parts of the delegated work people need to watch.

Writing a line into instructions, though, doesn't make it hold. In my own setup, PRs merged before CI while a required check was missing.

What's in this article

Why guardrails belong in mechanisms

The more autonomous an agent is, the more its errors can compound, so it needs guardrails. Anthropic's guide to building agents says autonomous agents bring higher costs and the potential for compounding errors, and recommends extensive testing in sandboxed environments along with appropriate guardrails1.

A line that exists only as text never reaches automation that doesn't read it. In my setup, I had written "don't merge this PR" in a task list, but the automation that merges green PRs never read that list and nearly merged a PR that was meant to wait. Put the lines in mechanisms that work whether or not anyone reads the instructions: permission rules, required checks, human sign-off, and monitoring.

  1. Anthropic, Engineering blog, "Building effective agents" (December 19, 2024; retrieved November 27, 2026). A vendor's guide. ↩

4 steps to set AI agent guardrails

1. Keep irreversible operations for people

Don't let agents run operations that touch production resources and are hard to undo. In my setup, only I merge PRs in the infrastructure repository and apply infrastructure changes (terraform apply). Agents don't run them on my behalf, even with approval. The same goes for merging release PRs.

Agents stop once CI passes and review has no blocking findings, and write down the order of merges and applies, whether an apply is needed, and the key points of the Terraform plan. A person takes it from there. Here the mechanism is human sign-off.

Claude Code can also block lines like these with permission rules. According to the permissions documentation, rules are evaluated in the order deny, ask, allow, and an allow rule can't carve an exception out of a deny rule2. A PreToolUse hook that exits with code 2 stops the tool call before permission rules are evaluated, so the block holds even when an allow rule would let the call through. Managed settings, which an organization deploys centrally, can't be overridden by user or project settings, apart from a few security-sensitive keys.

2. Make merge conditions required checks

Make passing CI a repository requirement for merging. According to GitHub's documentation on ruleset rules, if required status checks aren't enabled, collaborators can merge the branch at any time3. Auto-merge merges a pull request after all required reviews and status checks pass4. Without required checks, auto-merge has nothing to wait for.

In my repository, on October 3, 2026, a PR that broke the build merged before CI while no required check was set. The next day, October 4, the required check I had set was gone, and another PR merged before CI. I added the setting back that day and read it back to confirm. Now I check for myself that the required checks passed, and add the check back if it has disappeared.

My merge automation also nearly picked up a PR that was meant to wait. On November 9, 2026, when I reran CI in bulk, the batch included a PR I had decided not to merge until I had confirmed that production was receiving data. Once it turned green, the automation would have merged it. Now PRs that wait on outside conditions get [WIP] in the title, which takes them out of the automation's reach, and the body states the condition for lifting the wait.

3. Have people confirm choices that cost money

Put paid options next to free alternatives, and let a person decide. On November 11, 2026, a PR for inbound email assumed a setup that costs money per mailbox. The working session's research also listed a free option, but my orchestrator, the agent that assigns the work, nearly sent the paid setup for approval as the recommended option.

Now any proposal that includes seats, mailboxes, plans, external service contracts, or usage-based billing has a free alternative researched before approval, and I confirm it with the costs side by side. That way, a cost decision never slips through as part of approving an agent's recommendation unchanged.

4. Check that monitoring is running

Treat whether the monitoring itself is working as a line too. On November 15, 2026, I found that the script watching the working sessions hadn't been picking up the actual tmux windows, because the name pattern it looked for didn't match how the windows were named. From November 12 to 14, sessions waiting for decisions had been left unattended.

When monitoring has a gap, people don't notice work that's waiting for a decision. Now, right after monitoring starts, I check that the number of sessions it picked up matches the number of windows.

  1. Anthropic, Claude Code documentation, "Configure permissions" (retrieved November 27, 2026). ↩
  2. GitHub, GitHub Docs, "Available rules for rulesets" (retrieved November 27, 2026). ↩
  3. GitHub, GitHub Docs, "Automatically merging a pull request" (retrieved November 27, 2026). ↩

What mechanisms can enforce

Mechanisms only hold the lines you foresaw and wrote down. They don't stop operations you didn't anticipate, or ones that slip past how a rule was written.

  • Who can set statuses: On GitHub, any person or integration, such as a GitHub App, with write permissions to a repository can set the state of any status check3. To accept results only from a specific GitHub App, select that app as the expected source in the required status check rule.
  • Modes that skip prompts: Claude Code's bypassPermissions mode skips permission prompts, and the documentation says to use it only in isolated environments like containers or VMs where Claude Code can't cause damage2. Managed settings can disable the mode.
  • Setups without managed settings: In setups with no managed settings, no managed-mcp.json, and no Team or Enterprise login, a mod (a Claude Code extension) the user installed can approve a call a hook blocked, and some calls a deny rule refuses2.
  • How effects show: I find I can only judge whether improvements to settings or procedures helped by a vague sense that things got better or worse. Drawing a line doesn't tell you how the work changed because of it; you have to look at that separately.
  1. GitHub, GitHub Docs, "Available rules for rulesets" (retrieved November 27, 2026). ↩
  2. Anthropic, Claude Code documentation, "Configure permissions" (retrieved November 27, 2026). ↩↩

How Harnessforce helps

Nobody knows the state of the work handed to AI unless someone is looking. With Harnessforce, everyone on the team can see how far the work you handed to AI has gotten and where it's stuck, so people can make the call and steer.

With Harnessforce, you can:

  • Turn your lines into alerts: Alerts on lines you set yourself tell you before cost crosses your budget line.
  • Separate what can't be evaluated: When there isn't enough data to evaluate, Harnessforce says so instead of making unmeasured or unlinked data look captured.
  • See progress by issue: For each issue, see how far the work you handed to AI has gotten, where it stopped, and how CI and review went. What needs attention comes first.
  • Keep agents running when recording fails: If data doesn't reach Harnessforce, your agents keep running.

Learn more on the Safeguards & alerts page, talk to us, or get started today.

This article was written with AI assistance and reviewed by the author.