Zero-hallucination is about schemas, not prompts
The standard advice for getting better output from an AI coding agent is to write a better prompt. Longer prompt, clearer prompt, more examples in the prompt. It helps, up to a point — and then it stops helping, in a very specific way.
A prompt can tell an agent what to build. It cannot, by itself, decide the things a codebase actually runs on: the table names, the foreign keys, the payload shapes, the authorisation rules, the empty and error states of each screen. If those decisions are not written down somewhere the agent must obey, the agent will make them — plausibly, consistently within one file, and differently in the next.
That is the hallucination problem, restated. It is not that the model imagines facts. It is that the specification leaves the load-bearing facts undecided, and the model is forced to decide them.
A worked failure, in miniature
Take a simple requirement: "users belong to workspaces, and a user only sees their own workspace's data."
In prose, that is one sentence, and it sounds complete. In a codebase, it is at least four decisions:
- A
workspacestable and aworkspace_memberstable, with the membership carrying the user id. - Every data table carrying a
workspace_idforeign key. - A Row Level Security policy on every table that checks membership — for example, a policy that allows a row only when its
workspace_idappears in the current user's membership rows. - API contracts whose payloads carry the workspace id in exactly one agreed place, validated before any query runs.
Write down only the sentence, and an agent will invent all four — and will happily invent a second, incompatible set when it writes the API layer a day later. Write down all four, in files that reference each other, and there is nothing left to invent. The agent's job shrinks from "design the system" to "implement this design", which is the job it is actually good at.
Why four files, not one long document
This is why Web Dev Mehedi, the generator I built, outputs a suite rather than a single document. One idea in, four files out, in under 60 seconds:
- PRODUCT_REQUIREMENTS.md — scope, user journeys, edge cases, and GIVEN/WHEN/THEN acceptance criteria. This is the part a product manager recognises.
- UI_UX_SPECIFICATION.md — design tokens, typography, view states, and accessibility rules. Screens have empty states, loading states, and error states specified in advance, so the agent does not improvise them differently on each page.
- TECHNICAL_ARCHITECTURE.md — the PostgreSQL DDL schema with Supabase Row Level Security policies, in the same file as the typed REST and Server Actions API contracts with Zod validation. Schema and contract sit together deliberately: if they drift apart, the drift is visible in one place.
- AI_AGENT_IMPLEMENTATION.md — phased build instructions and prompt rules that pin Cursor, Claude Code, or Windsurf to files 1–3: use these exact table names, these exact payloads, never bypass RLS, and flag a conflict instead of choosing silently. That last rule matters most. An agent that must report a contradiction instead of resolving it quietly turns a silent bug into a question you can answer.
None of this is a new kind of prompt engineering. It is the opposite: it moves the important decisions out of the prompt entirely, into artefacts with the same rigidity as code. A schema is a contract in a way prose can never be, because a schema either matches the query or it fails loudly.
The rule I now use before any build
Before handing anything to a coding agent, I ask: could two competent engineers, given only this specification, produce the same tables and the same payloads? If the answer is no, the specification is not finished — no matter how polished the prose reads.
That test is also a good way to judge AI tools in this category. A tool that returns only a prettier PRD has not removed the guessing; it has just made the guesswork start from a nicer document. A tool worth using returns the decisions the agent would otherwise have to invent.
If you build with AI coding agents, try it on a real idea: generate the full four-file suite and hand the agent all four files instead of just the PRD — https://webdevmehedi.com/ai-prd-generator — with 50 free credits on signup, no card required, and pricing from ৳99/month with bKash/Nagad. The free template behind the format is on GitHub if you prefer to use the structure without the generator: https://github.com/web-dev-mehedi/ai-prd-template
What does your coding agent still invent, even with a good spec in front of it?
