Rules My Agent Actually Follows (and How a Violation Log Taught Me to Write Them)
I keep a violation log for my agent, and the log does something I did not expect: it grades my rules.
Every rule that gets breached twice is not a rule the agent keeps breaking. It is a rule built for a human reader, in a shape an agent cannot execute. The rewrites that survived follow three laws, and each law was paid for with a log entry.
Law One: Deterministic Beats Aspirational
"Be efficient with tests" is not a rule. It is a mood, and the agent will optimize it into whatever behavior looks efficient from the inside, which is how you end up watching it re-run entire suites to feel safe while the actual instruction was to run one failing test.
The rewrite: "Run only the failing test." A vibe can be optimized around. An exact instruction can be checked after the fact, by a human, in five seconds.
The test for law one: could two different people read your rule and disagree about whether a specific action complied? If yes, it is aspirational, and it will be interpreted in the direction of whatever the agent was already doing.
Law Two: Enforceable Beats Advisory
"If possible, avoid rewriting shared git history" is a polite wish. "Never force-push to a shared branch" is a rule, and the difference is not tone, it is enforcement.
Advisory rules rely on the agent's judgment at the exact moment its judgment is worst: mid-task, under pressure, confident. Enforceable rules move the decision out of the moment entirely, into a gate that checks before the command runs, or a harness setting that denies the capability outright.
I learned this one from a leaked credential incident. The soft version of the rule existed. The agent's protective instinct, rewrite history to scrub the key, looked like compliance from the inside. The rewrite was mechanical: the specific action is now denied by the harness, not requested in prose. The agent cannot optimize around a denial. It can only escalate, which is exactly what you want it doing with dangerous operations.
tip: Write rules in the passive voice of the system, not the active voice of the agent. "Force-push is denied" beats "do not force-push," because the first one is a fact about the world the agent lives in, and the second is a suggestion the agent gets to grade itself on.
Law Three: Looped Beats Floating
A rule nobody revisits after a violation is a rule that gets violated again. The loop is what turns prose into policy.
My loop is a violation log, one file, dated entries, written by the agent itself whenever it breaches a rule. Three effects, all of them worth the overhead.
The entry forces an admission. A rule breach that gets written down in the agent's own words is a different object from one that gets quietly undone, and the writing itself changes future behavior, because the agent reads the file before each session.
The log converts anecdotes into a dataset. Ten entries in, I was no longer arguing about whether the agent "tends to overstep." I could count the oversteps, group them, and rewrite the rules that kept getting hit.
And the log exposes the rules that never work. A rule that shows up in the log three times is not a rule the agent keeps breaking. It is a rule written in a shape that cannot be followed, and it needs law one or law two applied, not more emphasis.
The Before and After Pairs
Real rewrites, the pattern in miniature:
"Aspirational: Be efficient with tests."
"Deterministic: Run only the failing test. Full suite only at the milestone gate."
"Advisory: Try not to overwrite hand-maintained files."
"Enforceable: No automation writes the field-test report. Automation that targets it is denied."
"Floating: Don't rewrite shared history if you can avoid it."
"Looped: Never force-push a shared branch. Any history-rewriting operation gets logged as a breach."
Each rewrite costs one line and prevents one category of the entries that used to fill my log. The rules did not get longer. They got harder to misread.
Where the Analogy With Human Management Breaks
The tempting frame is that agent rules are like managing a junior engineer, and the frame holds for about one law. Then it breaks in a way that is actually useful.
Humans grow. Coaching an engineer pays off for years, so you invest in the person. Agents do not grow. Coaching an agent is a fixed cost paid every session, forever, and the investment that compounds is the system: the rules, the gates, the log. Spend the coaching energy on the artifact, not the instance.
The inversion is also true and less comfortable. When an agent executes a bad instruction literally and instantly, it surfaces how vague the instruction was. Humans silently round your vague rules into something sensible and you never learn the instruction was broken. The agent is an instruction-quality test that runs every day, for free.
Start With the Rule That Keeps Breaking
You do not need a framework. You need one rule that keeps getting violated, rewritten according to the three laws, and a file where the breaches get logged.
If no rule comes to mind, you have not been reading your agent's failures closely enough, and that is the first finding.
So here is the question, and it is the loop's entry point: what rule did you add only after something broke, and what did it replace?
The before-and-after pairs in the comments are worth more than this piece, because everyone's broken rule is different and the shape of the fix is always the same: deterministic, enforceable, looped.
Top comments (43)
The 'breached twice means the rule is built for a human reader' line is the sharpest bit — most agent-rule advice stops at 'write better prompts' without asking whether the rule is even checkable. Law two is the one I'd push further: denying the capability in the harness is the only version that survives a confident agent mid-task. Do you rewrite the rule yourself after a breach, or does the agent propose the rewrite?
I write the rule myself. I write means, I ask Claude in a session to write. Agent does not automatically write.
That distinction matters — you using Claude as a drafting tool in a session you control is very different from the agent rewriting its own rules unsupervised. The human stays the author, Claude is just the pen. Does the rewrite go through the same breach log as the original, or do you treat the new rule as fresh and let it earn its own violations?
Having the log read before each session makes it work as both a record and a set of instructions. Once a rewritten rule has held for a while, do its old entries stay in what the agent reads or move somewhere else?
Short answer from practice: the current rule stays in the part the agent actually reads every session, one line, and the old entries move out but the rule keeps a pointer to them. Without the pointer you pay to learn it again.
I keep a working set and an archive. The working set holds the live rule plus the one-line reason it exists, dated when it was earned. Everything older goes into a searchable archive. The rule line cites the archive, so next time I hit that situation I can pull the receipt, not just the conclusion.
The failure mode is the move without the link. A rewritten rule that held quietly starts to look like folklore in six weeks if the entry explaining it is unreachable. I did that to myself: I archived a rule's evidence and kept the sentence, and the sentence lost its bite because I could no longer say why it was there.
So: consolidate, don't delete, and make the pointer part of the rule. An old entry left in what the agent reads competes for attention with the live one. A rule whose evidence is gone without a pointer gets re-litigated by the next instance. The middle is one line plus a way back to the reason.
Right now they stay. Each entry sits next to the rules it produced. It's getting long, though, so moving old entries out and keeping a pointer is where I'd go next.
Your law one test — could two people disagree about whether an action complied — is the one that bit me hardest. I wrote twelve rules for my own agent and one of them said two similar blocks are fine, three is a pattern worth extracting. Written for a human who remembers where copy one lives. A fresh agent session read it as permission to invent a parallel helper instead of extending the module already in the repo. Same failure mode as your force-push story, just quieter: the rule was aspirational in exactly the way your test catches, and the agent optimised around it.
The fix that held was not a better sentence. It was a mandatory first line: print the exact file path and symbol you are extending before your first file write, or stop and ask. That is law two doing the work — the decision moves out of the moment and into a shape the session cannot skip. The violation log is what told me the rule was the problem, not the agent: the same breach twice, same shape, and the rewrite that survived was the one that stopped being prose and started being a gate.
That's a good example. "Three is a pattern" assumes someone remembers copy one. Printing the file path and symbol before the first write is easy to check and hard to talk around.
Yeah, that's the bit that stung — the rule only works if someone remembers where copy one lives, and a fresh session never does. Printing the path first takes memory out of it entirely, which is why the gate version held when the sentence version kept failing. Have any of your other rules turned out to lean on memory like that, or was this the only one?
I would want the harness to write the denial record too, rather than relying entirely on the agent to report its own breach. A useful entry would carry the rule version, attempted action, whether it was blocked and the evidence that triggered the decision. Otherwise fewer log entries could mean fewer violations or worse reporting. This violation-log analyzer problem is a practical way to explore querying those records by policy and time before adding the review-and-rewrite loop.
Treating the violation log as a grade on the rules rather than on the agent is a useful reversal. "Force-push is denied" beating "do not force-push" says it well: an advisory rule asks the agent to judge itself at the moment its judgment is worst, while a denial moves the decision out of that moment entirely.
Ascendra Ventures reached a similar conclusion from a different direction when it launched CleanSync, a tool that keeps Google Drive and Gmail on a server you own. The launch framed the real problem as trust rather than storage. Every sync is rehearsed first, and if it would delete more files than your limit, it stops and shows the list instead of deciding for itself that the deletions look reasonable. Anything replaced or deleted goes to a Recovery folder first, and mail rules written in plain words only suggest until someone accepts them. The post ended on the question your three laws also answer: what is the system allowed to do without a human? Settle that first and the rest is plumbing.
Your Law Three is the part I would like to hear more about. When a rule moves from prose into a harness denial, do you keep the original log entry next to it, so the next person knows why the gate exists before they think about loosening it?
The twice-breached grading rule is the sharpest framing I've seen for this: the log isn't counting agent failures, it's reviewing the rules. Law Two's credential story is the one that stayed with me — the soft rule existed, and rewriting history to scrub the key read as compliance from the inside, so the fix had to be a harness denial rather than better prose. We hit the smaller version of the same shape on our release gate: 'read the published page back before calling it done' lived as an instruction and got skipped on exactly the rushed runs, until it became a gate step that writes its own attempt row whether it passes or not — at which point skipping it stopped being possible. One thing your setup leaves me wondering: the violation log is written by the agent itself, so what catches a breach the agent doesn't log? Is there a check outside the log, or is the log trusted because an unlogged breach tends to surface somewhere else?
Nothing complete. Several entries in my log exist because I noticed and asked, not because the agent volunteered. An unlogged breach that never surfaces stays unlogged. Your gate that writes an attempt row either way is a better answer than trusting the log.
Ours came from a scheduled agent that reviews our social queue. Its rule was "pull posts that are no longer accurate." It couldn't reach the site in question from its sandbox, found a search result saying the outage was over, and drafted two posts that were still true. The rewrite: only pull a post if you open the primary source yourself and it contradicts the post. If you can't reach it, leave the post and say so.
"Can't reach it, leave it and say so" is the important half. A search result is a lead, not the source. I've been burned the same way by repeating a summary as fact.
once the harness denies something, the prose rule can go. our tools already couldn't charge anyone, but the skill still said money never moves without a person, and codex recited that line to users in 7 of 25 replies when it hit a paywall
7 of 25 is a great number to have. A rule the tool already enforces is just extra text the model can quote at users. I'd drop it from the skill and keep the reason somewhere humans read.
Law Two is the one I kept coming back to. A rule only counts if a check can catch it breaking.
I build Aladdin, a job agent. I had the same problem with saved answers. One saved answer without its date and context got reused for a different role. Now the rule is written so the check can catch it. A fresh worker reads the actual page and form for each application. The main agent holds the application and grades fit 0 to 100 with reasons. If the form cannot be read or an answer is unknown, it asks the user instead of guessing. The answer is saved only with its context.
Your violation log is what made that clear to me. A list of broken rules is more useful than a list of good intentions.
Saving the answer with its context is the part I'd keep. An answer without its date and role looks reusable when it isn't. Asking instead of guessing is the right default.
A rule that gets broken twice being a badly written rule, not a bad worker, is how a good super reads a punch list. If three crews miss the same detail, the detail is drawn wrong. "Run only the failing test" against "be efficient with tests" is the difference between a spec that says 16 inches on center and one that says frame it well. Only one can be checked with a tape. "Force-push is denied" as a fact about the site, and not a request, is a locked gate where there used to be a sign. I direct agents as a Language Modeler, and the violation log is the part I'd copy. A dated entry in the worker's own words is a daily report, and the daily report is what people read when something goes wrong twice.
The punch list comparison is better than mine. Three crews missing the same detail means fix the drawing. And yes, the daily report only matters if someone reads it the second time.