---
title: "Rules as code · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/rules-as-code
updated: 2026-10-20
licence: "All rights reserved"
---

# Rules as code

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

> Turn every rule into a check in code that passes or fails. Then people and AI agents never have to guess whether work is right.

**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`.

## Required

- [Check every rule in code](https://agentwranglers.se/playbook/engineering/rules-as-code/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.
- [Run one check of everything before every deploy](https://agentwranglers.se/playbook/engineering/rules-as-code/run-one-check-before-every-deploy): Run every check against the whole project with one command, and let the deploy go ahead only when all of them pass.
- [Fail the build on broken rules](https://agentwranglers.se/playbook/engineering/rules-as-code/build-gates): Make the build fail on rules that must always hold, so a broken build can never ship.

## Recommended

- [Enforce the writing style in code](https://agentwranglers.se/playbook/engineering/rules-as-code/enforce-the-writing-style-in-code): Check the writing of every page and document in the build, so the language stays plain and short as more people and AI tools write.

- Next: [Build, test and deploy](https://agentwranglers.se/playbook/engineering/build-test-and-deploy)
- [All chapters](https://agentwranglers.se/playbook/engineering)
