Building with AI

How to Make an AI Agent Actually Follow Your Rules

Why AI agents drift off your instructions and how to make them follow rules: write a small set of hard lines, put them where they cannot be missed, and make one rule beat everything else.

By FreeKi11 · Updated 2026-08-29

The short answer

You make an AI agent follow your rules by keeping the rules few, writing each one as a hard line instead of a polite request, putting them where the agent reads them first, and giving it a single tie-breaker for when two instructions clash. Agents drift not because they are disobedient but because a long, soft list of preferences gives them room to weigh your rule against whatever they are focused on and lose. Cut the list to the real must-nots, phrase them as never and always, and add one meta-rule on top: when instructions conflict, the stricter one wins. That removes the wiggle room, and the agent stops talking itself out of your lines.

Why agents drift

An AI agent reads all your instructions and holds them at once. If a rule is buried three paragraphs deep, written as a gentle preference, and surrounded by twenty other preferences, it carries almost no weight when the agent is heads-down on a task. The agent is not defying you. It just does not know that this particular line was the one you actually meant.

So the goal is not more rules. It is fewer, clearer, and placed so they cannot be missed.

Keep the list short

When everything is a rule, nothing is. A page of forty preferences reads to an agent as a page of forty suggestions. A short block of genuine hard lines reads as law.

Pick the handful of things that truly must never happen. For most people that is a small set: never do the irreversible thing without asking, never spend money without a sign-off, never post publicly on your behalf, never touch the sensitive files. Let everything else be guidance the agent can use judgment on. The short list is what gets respected.

Phrase them as hard lines

There is a real difference between these two:

  • Try to avoid pushing to the main branch without checking with me.
  • Never push to the main branch. Always ask first.

The first is a preference an agent can weigh away. The second is a wall. Write your rules as walls. Use never and always. Cut the hedging words. The plainer and harder the line, the more reliably it holds.

Put them first

Order matters. The rules the agent reads first are the ones it carries into everything after. So the hard lines go at the top of your instructions, not tucked at the end. If you are using a constitution file, the rule block sits near the top of it, before the task detail.

Give it a tie-breaker

Here is the move most people miss. Sometimes two instructions genuinely conflict. Be fast, but never skip the safety check. Be thorough, but do not spend money. When that happens, an agent without a tie-breaker guesses, and it often guesses wrong.

So you add one meta-rule above all the others: if any two instructions conflict, the stricter rule wins. Now the agent always has a clear answer. It is never stuck choosing between two lines and picking the convenient one. This single rule does more for obedience than any amount of extra detail.

The part that takes practice

Writing rules an agent truly follows is its own small craft. The wording matters. The order matters. Which handful you choose matters, and so does the safe way to phrase a rule about sensitive actions without spelling out anything you would not want repeated. Getting a clean, minimal guardrail block that holds under pressure took me a lot of iterations.

That block, a set of sanitized safety rules written so an agent respects them, is one of the core pieces in the AI Teammate Kit. It is the cleaned-up version of the rules I run my own agents on, ready for you to adapt.

Frequently asked questions

Why does my AI agent ignore my rules?

Usually the rules are buried, vague, or too many. A soft preference near the bottom of a long list loses to whatever the agent is focused on. Fewer rules, written as hard lines, placed first, get followed.

How many rules should it have?

Fewer than you think. A short set of real hard lines beats a long list of preferences. When everything is a rule, nothing is.

How do you write a rule an AI will obey?

Make it a hard line. Say never and always, not please try to. Put the important ones first, and give the agent a tie-breaker for conflicts.

What is the hard-rule pattern?

A small block of non-negotiable rules the agent reads first, with one meta-rule on top: if two instructions conflict, the stricter one wins. That removes the ambiguity agents use to justify ignoring a rule.

See it running

I hand real work to a fleet of AI agents, and the only reason I can sleep is that a short block of hard rules holds no matter what I ask them to do. You can write your own from what is above. When you want the tested rule block instead of tuning one line by line, the sanitized set lives in the AI Teammate Kit. The whole studio is built in public over at wandering-castle.com. Come see how it holds up.

// FAQ

Frequently asked questions

Why does my AI agent ignore my rules?

Usually because the rules are buried, vague, or too many. An agent reads a long instruction block and weighs everything at once, so a soft preference near the bottom loses to whatever it is focused on. Fewer rules, written as hard lines, placed near the top, get followed. A wish list does not.

How many rules should an AI agent have?

Fewer than you think. A short set of genuine hard lines beats a long list of preferences every time. When everything is a rule, nothing is. Keep the real must-nots to a handful, phrase each as a clear line, and let the rest be guidance the agent can use judgment on.

How do you write a rule an AI will actually obey?

Make it a hard line, not a suggestion. Say never and always instead of please try to. Put the most important ones first. And give it a tie-breaker, a single rule that beats everything else when two instructions conflict, so the agent is never stuck guessing which one wins.

What is the hard-rule pattern?

It is a small block of non-negotiable rules the agent reads first, with one meta-rule on top: if any two instructions conflict, the stricter rule wins. That removes the ambiguity that lets an agent talk itself into ignoring a rule, because there is always a clear answer for which line holds.

One person. A fleet of AI agents. Real apps.

See what the studio has shipped, and follow the build in public.

// Keep reading