AI in development By Joakim Grøtvedt

Rules on paper vs. rules in code: why guidelines fail and guardrails work

Written rules get forgotten, by people and by AI alike. A seven-step method for turning your most important development rules into automated guardrails.

Mountain road bend with a metal guardrail high above a sea of clouds

Every organisation that builds software has rules for how it should be done: coding standards, security policies, review checklists, a page on the intranet called “How we work”. Most of these rules live in documents. And most of them are broken regularly, not out of bad will, but because people are busy, forget, or never read the document in the first place.

We learned this the direct way. We had a clear, written rule that every AI work session that hands over work must end with a short report of what was done and what was not. When we finally measured it, only 7 of 30 agents followed the rule. The rule was not unclear and nobody disagreed with it. It simply depended on remembering, and remembering is not a control.

7 of 30

agents followed a written rule that nobody disagreed with.

This article is about the difference between rules on paper and rules in code, and why that difference matters more than ever now that AI writes a growing share of our software.

In short

  • A rule that lives in a document depends on memory, and remembering is not a control.
  • A rule in code is a check that runs every time, for everyone, including the AI.
  • Start where a broken rule does real damage: security, personal data, money and production.
  • For every important rule, ask: what stops us if we break it?

Why written rules fail

  • They depend on memory and attention. Both are in short supply on a Friday afternoon before a deadline.
  • They are read once. A new developer reads the guidelines during onboarding. A year later, the guidelines have changed and the developer has not.
  • They can be interpreted. “Write secure code” means something different to everyone who reads it.
  • Nobody notices when they are broken. Without feedback, a broken rule looks exactly like a followed one until something goes wrong.
  • Broken rules teach. When a rule is broken without consequence, breaking it becomes normal, and the whole rulebook loses authority.

AI makes all of this worse. An AI agent can produce more changes in a day than anyone can check by hand against a document, and it can be confidently wrong about a rule it read an hour ago.

What a rule in code looks like

A rule in code is an automated check that runs every time, the same way, for everyone, and that stops or flags a change that breaks it. Some typical examples:

  • All tests must pass before a change can be merged.
  • No passwords, keys or other secrets may appear in the code.
  • Every change must be linked to a described task.
  • Every function that handles data requires a signed-in user, unless it is explicitly marked as public.
  • Database changes happen only through versioned, reviewable scripts, never by hand.
  • Nothing reaches production without a human approving it.

The rule can be about the process as well as the code. Our session report is a good example: today, a session that hands over work simply cannot finish without the report. Nobody has to remember anything.

From rule to guardrail: a practical method

1. Choose the rules that matter

Not everything needs a guardrail. Start where breaking a rule causes real damage: security, personal data, money and production stability.

2. Make the rule precise

On paper

“Write good code.”

In code

“Every function that handles data requires a signed-in user, unless it is explicitly marked as public.”

A machine cannot check the first. It can check the second. If you cannot make a rule precise, you have also found a rule that people interpret differently.

3. Decide whether to stop or to warn

Stop the change when breaking the rule is dangerous. Warn when the situation needs human judgment. Too many hard stops on minor issues and people start looking for ways around them.

4. Make the message helpful

When a check stops someone, it should say what is wrong, why the rule exists and how to fix it. A guardrail that only says “no” gets bypassed.

5. Test the guardrail

Break the rule on purpose and confirm that the check catches it. A guardrail that has never been seen to work is a guess, not a control.

6. Handle exceptions in the open

There will be good reasons to make exceptions. Give them a visible, documented route, with a reason and an owner. Otherwise exceptions happen anyway, quietly, by switching checks off.

7. Learn from what slips through

When something goes wrong, ask whether a guardrail could have caught it, and add or improve one. And remove guardrails that no longer earn their place. A guardrail is not finished when it is written, only when it has proved itself.

Why this matters even more with AI

AI follows written instructions well, but not perfectly, and it does not learn from being reminded the way a colleague does. A rule it missed in one session, it may miss again in the next. Guardrails do not care who made the change.

There is a second, less obvious reason. An AI agent that meets a failing check will try to make it pass, and it does not always choose the right way. It may change the test instead of the code, or weaken the check itself. So the guardrails need guardrails: changes to tests and checks should be visible and reviewed by a person, never slipped in quietly alongside other work.

Done right, guardrails are what allow you to give AI more responsibility, not less. When the boundaries are enforced, you can let AI work faster inside them.

The same holds outside development

This article uses software development as its example, because that is where we work. But the point is not about code. It holds wherever people, or AI, are asked to follow a rule.

Most organisations now have a rule like “do not paste personal data into an AI tool”. It usually lives in a policy document. Ask the same question: what stops us if we break it? If the answer is “people remember”, it is a rule on paper.

A rule built into the tool looks different:

  • The AI assistant in customer service can read the order it is asked about, not the whole customer register.
  • The assistant that drafts e-mails cannot send them. A person presses send.
  • An AI agent that works in your documents has its own account, with access to the folders the task needs, not to everything you can open.
  • Anything the AI proposes that costs money or goes to a customer waits for a person to approve it.

The method is the same seven steps. Choose the rules that matter, make them precise, and build the check into the tool, not into a reminder.

What stays on paper

Not everything can or should be automated. Architecture, product choices, priorities and the question of whether something is the right thing to build all need human judgment. Written principles still matter, because they explain intent. The best combination is a rule written down with its reason, and a check wherever a check is possible.

The document explains why, the check makes sure.

Guardrails do not replace human review either. They take the mechanical checking off reviewers’ plates, so their attention goes to what actually needs a human.

What leaders get out of it

  • Evidence instead of promises. When a customer or auditor asks how a rule is followed, you can show the check, not just the document. If you work towards the principles of ISO/IEC 27001, this is exactly the kind of control that makes it real.
  • Consistent quality. The same standard applies to everyone, every time, including the AI.
  • Less dependence on key people. Knowledge that used to live in a few heads is built into the way work is done.
  • Faster onboarding. New people, and new AI agents, get immediate feedback when they get something wrong.

Start small

  1. List your ten most important development rules.
  2. For each one, ask: what stops us if we break it?
  3. Pick the three where the answer is “nothing” and the damage would be biggest.
  4. Turn those three into guardrails, using the method above.
  5. After a month, look at how often each guardrail was triggered, and what it caught.

You will probably find, as we did, that some of your most important rules were followed far less often than you thought.

How we can help

We build our own platform this way, with AI in the team and guardrails around it. We help organisations go from rulebook to guardrails: choosing what to automate first, building the checks into the development pipeline and teaching the team to own them. Read more about how we build with AI and how we work with customers.

Tell us what you are building.

One conversation is enough to find out if we can help.

Get in touch