How do I make my coding agent follow my rules?
A short learning video. A renovation company owner whose AI coding agent broke one of her rules, and a software engineer who shows her how to write rules it keeps.
What this video shows
Nora’s rules file started as a few lines (she wrote it in “How do I use RAG when I code?”). Every time something went wrong she added more, until it was a thick binder of rules. One of them said: never change the old database scripts. She even wrote it in capital letters. The agent changed one anyway.
Sam’s answer has three parts. Cut the file down to what the agent cannot guess from the code. Write each rule as one clear action with the reason after it, in a calm voice. And for a rule that must never break, like keeping the agent away from secret keys, add a real check: a setting that blocks the action, and tests that catch what slips through. The article has a sample file to copy, a table of good and bad rules, and the settings: read the article.
What you will learn
- Why a coding agent skips a rule that is written in its rules file.
- What to keep in the file, and what the code already tells the agent.
- How to write one rule so it can be checked, and why the reason matters more than capital letters.
- Which rules belong in a check instead of the file.
Further reading
- Anthropic, Claude Code docs: “How Claude remembers your project” (memory). code.claude.com
- Anthropic, Claude Code docs: “Best practices”. code.claude.com
- Anthropic, Claude Code docs: “Hooks guide” and “Permissions”. hooks and permissions
- OpenAI, Codex docs: “Custom instructions with AGENTS.md”. learn.chatgpt.com
- GitHub blog, 19 November 2025: “How to write a great agents.md: lessons from over 2,500 repositories”. github.blog
If you want rules and checks set up for your team’s coding agents, see how I can help or tell me about your project.
Transcript
0:03 Nora: How do I make my coding agent follow my rules?
0:08 Sam: Keep your rules file short. Write each rule clearly, and say why.
Sam: And the rules that must never break? Turn them into checks the agent cannot skip.
0:19 Nora: My rules file says: never change the old database scripts.
Nora: Last night the agent changed one anyway. And my app broke.
Nora: I even wrote that rule in capital letters.
0:30 Sam: Let me see the file. It has grown very long. Every time something went wrong, you added more.
Sam: The agent reads it all at the start, next to everything else. The more rules it holds, the more it drops.
0:45 Sam: Rules get lost for a few simple reasons.
Sam: The file is too long. A rule is vague. Two rules fight. Or you only said it in the chat.
0:57 Sam: So cut it down. Keep only what the agent cannot guess from your code.
Sam: How to run the tests. Where things are. And the few rules that are special to your app.
Nora: Everything else goes?
Sam: Yes. The code already shows the rest. This works the same in Claude Code, Cursor, Codex or Copilot.
1:18 Sam: Now write each rule so you can check it.
Sam: “Be careful with the database” tells it nothing. Write: never change an old database script. Add a new one.
Sam: Then say why. The old ones already ran on the live app.
Nora: Do I need capital letters?
Sam: No. A calm rule with a reason works better.
1:40 Sam: Some rules must never break. Like this one: never read the secret keys.
Sam: Words in a file only ask. A check makes sure.
Sam: A small setting blocks the action before it happens. And tests catch what slips through.
1:55 Sam: Think of it as steps.
Sam: The rules file asks. A block stops the action. Tests catch the mistake.
2:05 Nora: And if it still makes a mistake?
Sam: If it makes the same mistake twice, ask it why. Then add one line to the file.
Sam: And take out a line it no longer needs. Keep the file short.
2:18 Nora: A short file. A reason for each rule. A block on the secret keys. It follows my rules now.
Sam: Start today with your test commands and five clear rules.
2:29 Sam: Keep the rules file short. Give each rule a reason. Turn the rules that must never break into checks.
Have an app idea, a stuck app, or a daily job you want an AI agent to do?
Write three lines. I reply within one working day with a plain answer.


