Agent Wranglers

Rules as code Required

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.

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');
}
# 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.

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/build-gates.