Arrange Act Assert

Jag Reehals thinking on things, mostly product development

AI Code Needs Rules, Not Rituals (The Proof)

18 Dec 2025

I wrote previously about why AI-generated code needs rules, not rituals.

AI coding agents aren't going anywhere. They're excellent at exploring ideas, generating boilerplate, and moving fast. But speed without reliability just ships bugs faster. And without constraints, AI-generated code is unreliable by default.

Prompting is a ritual. Linting is a rule.

Here is the proof.

Agent

Why Prompts Don't Cut It

Most teams try to control AI output with instructions:

All of this helps. None of it guarantees anything.

Prompting is probabilistic. You're hoping the model remembers your preferences and applies them consistently across contexts. Sometimes it does. Sometimes it doesn't. Often it lands in the worst possible place: almost correct.

Almost correct is how bugs slip through review.


A Real Example

My preference in JavaScript is that functions should take a single object parameter rather than positional arguments.

I've explained this preference to AI tools. I've shown examples. I've reinforced it repeatedly.

And I still get this:

// ❌ Generated anyway
function calculateDiscount(price, taxRate, couponValue) {
  // …
}

Sometimes the model listens. Sometimes it doesn't. That inconsistency alone disqualifies prompting as enforcement.


What Rules Actually Do

Encode the preference as a lint rule. I built eslint-plugin-prefer-object-params for exactly this. Now the bad version can't survive:

error  Prefer object params over positional arguments  prefer-object-params

No retries. No "please remember next time." The rule fires, the code fails, and the agent fixes it.

That's enforcement.


"But What If No Rule Exists?"

Write one. Or have the agent write one.

That's exactly what I did with the plugin above.

Now, AI-generated code hits the same walls as human-written code. Every generation has to pass. The output becomes deterministic, reviewable, and aligned with how I actually want the code to look.


What This Catches

Before:

// ❌ Easy to miss in review
function sendEmail(to, subject, body, cc, bcc) {
  // …
}

After:

✖ prefer-object-params: Use a single options object instead of positional arguments

AI slop hits a brick wall.


Beyond Style

These examples are structural because they're easy to show: parameters, signatures, conventions. But the principle scales.

Some rules live in linters. Some live in type systems. Some live in tests and runtime validation.

Complex business logic still needs tests. Security rules still need audits.

The point isn't that lint rules replace everything. The point is that anything you can make deterministic, you should.


The Reality

Prompting is great for exploration. Production code needs rules.

If AI is writing code in your repo, constrain it with the same systems you already trust: linters, types, tests, and CI checks. That's how you get the speed AI promises without sacrificing reliability.

Rituals hope. Rules enforce.

ai coding