ENG-3Recommended
Fail the build on broken rules
Make the build fail on rules that must always hold, so a broken build can never ship.
How to do it
Check the build output itself, not only the source. For a website, check every page for exactly one h1 and the doctype first. Check for a title of at most 60 characters and a description of 120 to 160. Reject any inline style= attribute, because it breaks a strict CSP. Stop with a message naming the page. Fail on any internal link to a page that does not exist, and match every link form, such as /about and https://example.com/about. Check the markup a browser sees, so a code example that shows style= as escaped text does not trip the gate. For page weight, Fail the build when pages get heavier is one such gate.
Examples
JavaScript example
for (const { path, title, description, html } of pages) {
const fail = msg => { throw new Error(`${path}: ${msg}`); };
if (!html.startsWith('<!doctype html>')) fail('doctype must come first');
if ((html.match(/<h1[\s>]/g) || []).length !== 1) fail('needs exactly one h1');
if (title.length > 60) fail('title over 60 characters');
if (description.length < 120 || description.length > 160) fail('description not 120-160');
if (/<[a-z][^>]*\sstyle=/i.test(html)) fail('inline style attribute');
}
Python example
# The same gates in Python, failing with the page's path
for page in pages:
if not page.html.startswith("<!doctype html>"):
raise SystemExit(f"{page.path}: doctype must come first")
if len(re.findall(r"<h1[\s>]", page.html)) != 1:
raise SystemExit(f"{page.path}: needs exactly one h1")
if re.search(r"<[a-z][^>]*\sstyle=", page.html, re.I):
raise SystemExit(f"{page.path}: inline style attribute")
How to check
Break one rule on purpose, and the build stops. Add a link to a missing page, written once as a path and once as a full address. The build stops for both.
Sources
Related rules
- AID-14 Protect the checks themselves in AI-assisted development
- WEB-58 Fail the build when pages get heavier in Website
- ENG-4 Enforce the writing style in code in Engineering
- WEB-5 Keep the HTML valid in Website
- CSS-5 Write styles only in stylesheets 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/build-gates">Agent Wranglers engineering playbook</a>. In code you write, add a comment next to it with the same link.