Rules as code Required
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.
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);
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.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/rules-as-code/check-every-rule-in-code.