ENG-1Recommended
Check every rule in code
Every rule a project follows must have a check in code that anyone can run again and that ends in a plain pass or fail.
How to do it
Write each rule as a build gate, a test or a script with an exit code. Zero means the rule holds, anything else means it is broken. The output names the rule, the file or page and the line, so nobody has to read, guess or interpret. A rule without a check is only a wish, so add the check in the same change as the rule.
Examples
JavaScript example
// A rule as code: pass or fail, never "looks fine"
const problems = pages.filter(p => (p.html.match(/<h1[\s>]/g) || []).length !== 1);
for (const p of problems) console.log(`FAIL ${p.path}: needs exactly one h1`);
process.exit(problems.length ? 1 : 0);
Python example
# The same rule as code in Python
import re, sys
problems = [page for page in pages if len(re.findall(r"<h1[\s>]", page.html)) != 1]
for page in problems:
print(f"FAIL {page.path}: needs exactly one h1")
sys.exit(1 if problems else 0)
How to check
Break one rule on purpose. The check fails, names the place, and exits with a code other than zero.
Measured
On a reference site, the first full run of the checks found 678 sideways-scrolling failures. One CSS line in a new menu caused all of them, and the menu had looked fine in screenshots.
Related rules
- AID-49 Add a check for every repeated mistake in AI-assisted development
- OPS-31 Learn without blame in Operations and observability
- OPS-69 Keep manual operations work under half the time in Operations and observability
- SEC-7 Turn every fix into a check in Adversarial testing
- INF-39 Test your own rules against the plan in Infrastructure and environments
- CMP-1 Keep a register of every duty that applies in Compliance and governance
- CMP-33 Turn every policy line into a checked control in Compliance and governance
- CSS-26 Lint styles with one shared config in HTML and CSS
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/engineering/rules-as-code/check-every-rule-in-code">Agent Wranglers engineering playbook</a>. In code you write, add a comment next to it with the same link.