Mohamed Douare Logo

← Blog

Series: Software that acts · Part 6 of 12

Guides, Sensors, and the Ratchet

In Part 2, we saw a revealing situation: the execution loop worked perfectly, but the small model produced an incorrect summary while reporting that the task was complete.

That kind of mistake shows why an agent can't simply be left to work on its own. It needs guidance before taking action, and its work needs to be checked once it's done.

I use three complementary mechanisms for this: guides, sensors, and the ratchet.

Guides: prepare the agent before it acts

Guides contain the information an agent needs to do its job correctly: project rules, architectural constraints, coding conventions, and examples of good practices.

Their purpose is simple: prevent agents from repeating mistakes we already know about.

Think of them as a combination of a driving manual and the rules of the road. They give the driver the information needed before getting behind the wheel.

In my repositories, these guides are stored in a simple text file at the root of each project: AGENTS.md.

The advantage of this format is that it's open and understood by several tools. Regardless of which provider or model is being used, any compatible agent can read the same instructions.

But providing instructions doesn't guarantee they'll be followed. That's where the second mechanism comes in.

Sensors: verify the result after the action

Sensors are all the mechanisms used to check what an agent actually produced: tests, automated code checks, evaluations, and reviews by a second model.

Guides try to prevent known mistakes. Sensors detect the ones that still happen.

Let's go back to the incorrect summary from Part 2. A test checking that the summary contains exactly three points would have immediately caught the problem.

Sensors are a bit like a vehicle inspection. A driver can claim that everything works, but an inspection is what verifies the actual condition of the vehicle.

Guides and sensors therefore serve two different purposes. That's precisely why they need to work together.

Guides provide direction. Sensors verify the outcome.

A system that relies only on guides depends entirely on the agent's ability to understand and follow instructions. It can still ignore them or interpret them incorrectly.

On the other hand, a system that relies only on sensors risks detecting the same mistakes over and over again without ever helping agents avoid them.

Combining the two gives us something stronger: guides reduce known mistakes, while sensors catch the ones that still slip through.

But we can take this a step further.

When a sensor detects a mistake, fixing the immediate problem shouldn't be enough. The correction should also help ensure that the system doesn't repeat it.

That's the idea behind the third mechanism: the ratchet.

The ratchet: turn every mistake into a lasting improvement

The word "ratchet" refers here to a design principle: every time an agent makes a mistake, the correction must leave a permanent trace in the system.

That trace takes one of two forms: a new rule in the guides or a new test.

The idea is similar to a ratchet wrench. Each movement advances the mechanism by one notch, while preventing it from slipping backward. In the same way, every corrected mistake should move the system one step forward.

Let's look at a concrete example.

  1. Agent, makes a mistake. It writes a function that crashes when given an empty list.
  2. Sensor, detects the problem. A test fails, or a review catches the issue before deployment.
  3. Agent, fixes the code. The function can now handle an empty list correctly.
  4. Ratchet, requires another notch. The fix must come with a new test or a rule in the guides. Otherwise, the change is flagged.
  5. System, retains the lesson. If the problem comes back, the test fails. And if another agent encounters the same situation, the relevant rule is already in the guides.
Figure 1. The lifecycle of a mistake.

The important difference is that the learning doesn't remain trapped inside a conversation with a model. It's recorded in the code repository, where every future agent can find it.

The system therefore becomes progressively more robust without requiring us to change or retrain the model.

We still need to make sure, however, that every correction actually leaves that trace.

A script enforces the ratchet at delivery time

In my factory, a script checks changes before they're delivered.

It first identifies fixes based on their names, then examines the modified lines. For a fix to be considered complete, it must add or modify at least one test, or add at least one rule to the guides.

Deleting a test or removing a rule obviously doesn't count as a new lesson.

If a fix leaves no new notch behind, the script flags it. In strict mode, it even blocks delivery.

I also track the number of rules and tests added each week, along with recurring mistakes. The goal is simple: no repeat occurrences of an error we've already detected.

There's one final point worth considering: sensors themselves can make mistakes.

Sensors need to be reliable too

In Part 4, my review tool had masked fake secrets deliberately included in some tests. Claude then mistakenly concluded that the tests were broken.

The problem wasn't in the code being reviewed. It was in the tool preparing the review.

I fixed that tool so it now clearly identifies any content it masks.

It's an important lesson: a sensor that regularly produces false alarms eventually loses the trust of the people relying on it. Over time, they may stop taking its warnings seriously.

Verification mechanisms therefore need to be maintained and tested just as carefully as the code they inspect.

An agent fixes a bug but adds neither a test nor a rule. What does my delivery script do?

Nothing, because the bug has been fixed

Not quite. Without a test or a rule, nothing prevents the same problem from returning.

It flags the change, and in strict mode blocks it

Exactly. Every fix must leave one additional notch, in the form of a test or a rule.

It reverts the fix

Not quite. The correction may be valid, but it's missing the mechanism that would help prevent the mistake from happening again.

What to take away

  1. Guides prepare the agent before it acts, while sensors verify the result afterward.
  2. With the ratchet, every correction must leave a permanent trace: a new test or a new rule.
  3. Learning stays in the repository, not in the model. We can therefore switch models without losing what the system has learned.

In the next part, we'll tackle another question: how do we decide how much autonomy an agent should have, depending on the nature of the change it proposes?

Mission 1: the guide A mistake is already known. You choose where the rule that prevents it lives, then you watch three weeks on the line. Play → Mission 2: the check The agent says the task is done. You set what checks its work after the action, and whether you can trust that check. Play → Mission 3: the notch Every fix must leave a test or a rule behind. You set the script that checks it at delivery, then the model changes. Play →

Governance · Published on December 1, 2026Lire en français

Be told when the next part is out →

A question about this article? Send me an email, I answer.