Skip to content
All posts
3 min read

OPERATING_RULES.md: Run Your AI Agent in Auto Mode Without Losing Control

Amit Raz

Amit Raz

Founder, RZ AI Labs

Broke your finger clicking approve, approve, approve for Claude? But when you send it off in auto mode it runs wild and burns 300K tokens in half an hour? This is exactly why every project of mine has a "rules" document the agent must obey. It is the middle ground that makes auto mode safe.

What is OPERATING_RULES.md?

In every project I keep a markdown file that defines what is allowed and what is forbidden. I call it OPERATING_RULES.md. My CLAUDE.md points to it and states that every action must comply with the rules in it.

Here is a real rule from one of my projects, which works with Apify, where careless calls cost actual money:

### Protocol when a paid call is needed

When Claude Code wants to verify something that would normally require a paid
call, it must:

1. Stop
2. State explicitly what it wants to call, against which service, with what
   expected cost
3. Wait for user confirmation
4. If approval is given, run exactly the one invocation that was approved, with
   no retries or "while I'm at it" follow-ups
5. If the call fails, do NOT retry: surface diagnostics and ask the user how to
   proceed

If Claude Code is uncertain whether a given action would trigger a paid call, it
asks rather than assumes

This rule matters because I do not want the agent blasting paid calls on the way just because something did not work out and it decided it needs to check again.

What do global rules look like?

Some rules are specific to a project, like the one above. Others apply everywhere. For example: the agent may never make a design decision on its own; it must ask me first.

That rule exists because of a real incident. We had decided on a relational database. Midway through, the agent concluded it was not working out, so it decided to store everything in a file instead. Less than ideal. Of course I caught it, but it had burned tokens for nothing, and then I had to revert everything it did and redo it, so we burned time too.

Another of my rules: any change the agent decides on by itself, it must document when it finishes, including what it changed and why, plus every decision it took on its own. That gives me oversight of what actually happened, and new rules keep emerging from that log as reactions to the nonsense it occasionally pulls. It pairs naturally with the decisions.md pattern I wrote about separately.

What do you actually gain?

Auto mode with a short leash: the agent works without nagging me every second, but on the important things it stops and asks.

Two things, concretely:

  • Control over what the agent really does, without approving every step
  • Massive token savings, because the agent does not get lost inside its own detours; it stops and asks instead

We are heading toward a world where it will be very hard to stay "on top of" the code 100 percent. Without control mechanisms, you simply will not know what is happening in there without reading every line. Rules files are one of the control layers I install as standard practice when building production agent systems for clients.

FAQ

What belongs in an AI agent rules file?

Two kinds of rules. Project-specific ones, like a strict protocol before any call that costs money. And global ones that apply everywhere, like never making design decisions alone and logging every self-made decision with its reasoning. The rules grow over time as reactions to things the agent got wrong.

How do I make Claude Code actually read the rules file?

CLAUDE.md points to the rules file and states that every action must comply with it. It is not hard enforcement, a model can still drift, but combined with decision logging it gives you control over what the agent does and big token savings, because the agent stops and asks instead of getting lost on its own.

Building something with AI?

I help teams ship custom agents, AI strategy, and software that works.