Give your AI coding agent rules, not just a PRD
I handed Cursor a good PRD once. Detailed scope, numbered requirements, acceptance criteria — the works. Three days later the database had tables the PRD never mentioned, two API payloads had quietly changed shape, and half the screens were // TODO stubs waiting for a human.
The PRD was not the problem. The problem was that I gave the agent a document and no rules. A PRD tells an agent what to build. It says nothing about what the agent is not allowed to do — and an agent with no constraints improvises, confidently, in exactly the places that cost the most to fix.
The fix is a short rules file that sits next to the spec: .cursor/rules, CLAUDE.md, or your agent's equivalent. Not a prompt — a constraint. Prompts are suggestions the agent can drift away from. Rules are boundaries it has to stay inside.
What goes in the rules file
Six rules do most of the work. They come from the free template I publish, and they pin the agent to the other three files of the spec:
- Build only what the PRD requires. If a requirement is unclear, stop and ask — do not invent behaviour.
- Use the table and column names in the schema exactly. Never invent a column, table, or relationship.
- Use the request/response shapes in the API contracts exactly. Never change a payload without updating the contracts first.
- Every database table must keep its Row Level Security policy. Never bypass RLS in application code.
- After building each requirement, run its acceptance check and report the result.
- If the PRD, the schema, and the contracts disagree with each other, report the conflict instead of choosing silently.
Rule 6 is the one people skip, and it is the most important. An agent that flags a conflict is useful. An agent that picks silently is a bug factory — you only find out which choice it made when a user hits it in production.
What this looks like in a real spec
Here are the golden rules from a sample spec the generator on my site produces — a sprint-tracking app called TaskPulse, shown on the generator page as an example of the fourth file, AI_AGENT_IMPLEMENTATION.md:
- Never invent arbitrary dependencies or unapproved database tables.
- Every server action must validate input payloads using Zod schemas.
- Every database query must respect Supabase Row Level Security boundaries.
- Output complete, production-grade files. Do not use "// TODO" or placeholder stubs.
Notice what those four lines do: they forbid the three most common agent failure modes I kept hitting — invented tables, unvalidated payloads, and security bypassed "for now" — and they forbid the TODO stub, which is how an agent declares a task done without doing it.
The same file also fixes the build order, so the agent cannot start with the fun part:
- Phase 1: Database DDL migrations & RLS policy verification
- Phase 2: Authentication flow & workspace tenancy middleware
- Phase 3: Typed Server Actions & CRUD endpoint validation
- Phase 4: Kanban UI components & optimistic state management
Database first, auth second, API third, UI last. When the order is written down, the agent cannot build screens on top of tables that do not exist yet — which is the mistake that used to cost me the most time.
How to use it without slowing down
Two habits make the rules file work instead of becoming decoration:
One journey at a time. Do not paste the whole spec and say "build it all." Give the agent one user journey, let it build that, run the acceptance check from the PRD, and only then move on. The spec makes the agent fast; small steps keep it correct.
Treat a flagged conflict as a win. When the agent stops and says the PRD and the schema disagree, that is the system working. Answer the question, fix the spec, and the next build gets faster. Every silent choice you allow is a bug you will debug later, without the context of why it was made.
The template, if you want the whole shape
The rules above are Part 4 of a free four-part template: the core PRD, the database schema, the API contracts, and the agent rules — four files that must agree with each other. It is on GitHub, free, no signup: https://github.com/web-dev-mehedi/ai-prd-template
If you would rather generate the whole suite from one paragraph than fill it in by hand, the generator that uses the same structure produces all four files in under 60 seconds: https://webdevmehedi.com/ai-prd-generator — 50 free credits on signup, plans from ৳99/mo with bKash and Nagad.
Either way, the lesson is the same: the PRD is the plan, but the rules file is what keeps the build honest. Write the rules first, and the agent stops being a very fast intern who guesses — and starts being a very fast engineer who checks.



