HOW-TO GUIDE
How to write agent rules that hold by keeping a violation log
Based on a guide by Debashish Ghosal on DEV Community · Nov 29, 2026
You'll end with: A set of agent rules rewritten to be exact, enforced by the harness, and tracked in a violation log the agent writes itself.
Why it's worth having: A rule that keeps showing up in the log is a rule in the wrong shape, and the log turns scattered misses into a count you can fix one rule at a time.
At a glance
WHO IT'S FOR
Engineering managers, operations leads, and engineers who write rules for AI agents.
LEVEL
Beginner
COST
Free. The method needs only a rules file and one log file.
YOU NEED
An AI agent with a rules file · One violation log file · A harness that can deny commands
The method, in short
- 1Replace vague rules with exact ones, such as run only the failing test, so anyone can check compliance in five seconds.
- 2Move dangerous actions, such as force-pushing a shared branch, into a harness denial instead of a polite request.
- 3Have the agent write a dated entry in one violation log whenever it breaks a rule, and read the log before each session.
- 4Rewrite any rule that shows up in the log again, instead of adding emphasis to it.
Read the full guide from Debashish Ghosal on DEV Community
The post has the three laws and three before-and-after rule rewrites.