Need a fixed database schema for a lab sample tracker
A tight v1 scope where the schema is the single source of truth, and the out-of-scope list prevents scope creep during the build.
Write a PRD (product requirements document) and a spec before you build — fewer bugs, less rework
Using AI to turn a vague app idea into a precise spec before any code is written: the one-liner, user stories, the data model, screens, acceptance criteria, constraints, and a build plan you approve first. Taught as a weak → strong ladder, with a small lab-inventory app as the running example.
In this chapter you will learn how to create clear, data‑first specifications that lock scope, define roles, and establish acceptance criteria before any code is written. You will be able to produce tight version‑one scopes with out‑of‑scope lists, write screen test cases and guardrail rules, and generate incremental build plans that keep each step reviewable. By the end you will have a repeatable process for drafting user‑story specs, data models, flow diagrams, and technical constraints so that every feature is built against a single source of truth and avoids costly rewrites or scope creep.
Vibe coding fails when the AI has to guess what you meant. The fix is a spec: a short, precise blueprint you write WITH the AI before any code exists. Each technique below shows a weak ask and a strong one. Work down from Beginner to Advanced — by the end you can turn a one-line idea into a build plan you approve before a single line is written.
You begin by using AI to turn your vague idea into a concise one‑liner, then expand it into user stories, define the data schema, sketch screens, list out‑of‑scope items and acceptance tests, all reviewed before development.
Locking scope creates clear boundaries, explicit guardrails and test cases that prevent bugs, reduce rework and stop scope creep by ensuring every feature is built against an approved specification.
Describe what you are building
Build me a lab inventory app.
I want a web app for my lab to track reagents — who has what, quantities, and expiry dates, with a low-stock alert. Users are 5 lab members; no public access. Before writing any code, ask me 5 questions to pin down the requirements.
It should have users.
Two roles: (1) Lab member — adds reagents, updates quantities, sees the low-stock list. (2) Lab manager — everything a member can do, plus delete entries and export to CSV. Write these as user stories: 'As a [role] I can [action] so that [reason].'
Add every feature you can think of.
Must-have for v1: add / edit / delete reagents, low-stock alert, CSV export. Explicitly NOT in v1: barcode scanning, multi-lab support, a mobile app. Build only the must-haves first.
Structure the spec
Store the reagents somehow.
Define the data model before the UI. Reagent: { name, category, quantity, unit, expiry_date, location, added_by }. User: { name, role }. Show the schema as a table and flag anything ambiguous before building.
Make it look nice.
Screens: (1) Inventory list — searchable table, low-stock rows highlighted. (2) Add/Edit form — all reagent fields. (3) Export button. Describe the navigation between them, then build screen 1 only so I can check it before you continue.
Make the low-stock alert work.
Low-stock alert acceptance criteria: when quantity ≤ the reagent's threshold, the row turns amber and is counted in a 'Low stock' badge at the top. Test case: a reagent at quantity 2 with threshold 5 must show as low. Confirm it passes.
Spec for agents & code
Use whatever you want.
Constraints: a single-page web app, data in the built-in database (no external service), simple email-link login, no payments, one framework only. If a requirement needs anything outside these, stop and ask me.
Now build the whole thing.
From the spec above, produce a numbered build plan: each step is one feature with its acceptance criteria, in dependency order (data model → list screen → add form → alert → export). I will approve the plan before you write any code.
Just make it secure.
Non-functional rules: a member cannot delete another member's entries; the CSV export excludes the 'added_by' email; invalid quantities (negative or non-numeric) are rejected with a clear message. Build these as explicit checks and list how each is enforced.
Just keep adding features in the chat.
Treat the spec as a living document. When we change a requirement, update the spec first, then ask: 'Given the updated spec, what needs to change in the code?' Paste the current spec at the start of every new session.
A concise product requirements document that captures the core idea and scope before any design work.
Produce a single‑sentence description and a one‑page specification after answering five AI‑generated questions
A simple spreadsheet that lists each entity, its attributes, and data types.
You will produce a single source of truth that defines all data objects before any UI is designed.
A tabular definition of all objects, fields, and relationships that the app will use.
Produce a complete data‑model spreadsheet that can be reviewed by the whole team before UI work begins
Behavior‑driven test scenarios written in Gherkin that describe expected behavior of a screen.
You will have executable acceptance criteria that can be used by developers and testers alike.
A concise PRD that captures overview, features, user stories, and constraints for the app.
You will produce a living document that aligns stakeholders on what is being built and why.
A set of concrete test cases that define when a screen’s feature is considered complete.
Produce a checklist of pass/fail criteria for each screen based on the spec and data model
A step‑by‑step schedule that breaks the project into reviewable increments.
You will create a plan that maps each feature to a development sprint and acceptance test checkpoint.
18 outcomes in all — one per recipe below.
Need a fixed database schema for a lab sample tracker
A tight v1 scope where the schema is the single source of truth, and the out-of-scope list prevents scope creep during the build.
Not sure what each screen must do
Each feature has a pass/fail test written before the code, removing ambiguity about what "works" means at review time.
Unsure what exactly to build
The scope is locked in 10 minutes of questions rather than discovered mid-build when rewrites are expensive.
Want to break a spec into bite‑size chunks
A build that progresses one reviewable chunk at a time, not an all-at-once dump that is hard to course-correct.
Ticket routing not meeting SLA
SLA rules have a pass/fail test written before the code, so the correct behaviour is testable immediately after each rule is built.
Unsure which roles need screens in a booking app
Every role's needs are on paper before the first screen, so no user type is forgotten mid-build and the permissions model is obvious.
Project keeps expanding with extra features
A written boundary that stops "while we're at it" additions from doubling the build time.
Don't know what comes after each step
The full user journey is agreed on paper; no screen is a surprise when it appears in the build.
Prevent accidental risky actions
Behavioural boundaries that survive across multiple build sessions and prevent the AI from "helpfully" shipping a dangerous shortcut.
Memo drafts need uniform layout and traceable numbers
Every memo draft follows the same structure and is fully source-traceable — reviewers can verify any figure without hunting through the data room.
Need to define tech stack, storage limits and role permissions for a finance dashboard
Every build session starts with the same constraints locked in, so no feature is built on the wrong stack or with the wrong permissions model.
Specs get out of sync between sessions
Drift between spec and build is caught at the spec update stage, not discovered as a bug three screens later.
Quarterly portfolio updates have mismatched formats
Every quarterly update produces a consistent table the investment team can compare across companies and periods without normalising mismatched formats.
Need a common inventory data model before any screens
A schema everyone agrees on before the first screen, so no feature requires a breaking data-model change mid-build.
Can't see every role’s workflow in a leave‑request app
No actor's workflow is discovered mid-build; the permissions matrix falls out of the story set naturally.
Ticket reassignment rule changes
The spec stays the single source of truth through the whole build — the AI never works from a stale memory of the original requirement.
A pre-build spec that pins down exactly what data is collected and who can see it, so the privacy decision is made once at spec time instead of discovered during a compliance review.
Mistakes hidden until the end
Mistakes are caught after one screen, not after twelve; the approved spec is the contract that keeps each build step on track.
Need a candidate brief from intake notes
Every brief sent to candidates uses the same structure and contains no fabricated requirements — reducing misalignment between candidates and hiring managers.
Need an audit‑ready candidate shortlist with source citations
The shortlist is auditable (every inclusion and omission has a stated reason), and final decisions remain with the human reviewer, not the model.
Need to keep rep data private
A one-page spec that covers permissions, data model, and guardrails before a single field is built — so the AI never builds a feature that leaks one rep's data to another.
Need a view of the deal‑stage pipeline
The full pipeline UX is on paper before any component is built; each screen's inputs and outputs are agreed and the build order is clear.
Need a ticket portal spec that blocks cross‑customer visibility
A complete pre-build spec that covers every role's view and a hard data-isolation rule, so the most dangerous mistake is blocked at the spec stage.
Not sure a feature works
Say how you will know each feature actually works. Acceptance criteria turn "it works" into something checkable — the AI can verify against them, and so can you.
Spec is just text
Make the AI produce an ordered, checkable plan — and approve it before any code. An approved plan is the contract. You catch a wrong assumption on a 10-line plan, not in a finished, broken app.
Don't know what fields you need before building screens
Name the objects and their fields before any screen exists. The data model is the app's skeleton. Getting it right first prevents the painful rewrites that happen when you find a missing field after the UI is built.
Need a list of things the app must never do
Write the rules the app must never break — the bugs that bite later are the unstated ones. The "must never" list up front is what separates a demo from something you can actually trust with real data.
When requirements change and chat history is lost
Update the spec when requirements change — and re-feed it each session. Chat history gets lost; the spec does not. Re-grounding each session in the current spec stops the code and the plan from silently drifting apart.
Need a lab inventory app but don’t want guesswork
Name the app, the user, and the core job in one sentence — then make the AI ask before it builds. A one-liner plus "ask me first" turns a vague wish into a scoped conversation — the AI clarifies instead of guessing and building the wrong thing.
Too many ideas for version 1
Scope the first version — and say out loud what it will NOT do. An explicit out-of-scope list is what stops v1 from ballooning into a half-finished, buggy everything-app — for both you and the AI.
Can't map out pages and flow
List the pages, what is on each, and how you move between them — then build one at a time. Naming the screens and building one at a time gives you checkpoints — instead of a 2000-line app you have to debug all at once.
I must restrict the AI to my chosen stack, built‑in database and email‑link login
State the stack, storage, auth, and the limits the AI must stay inside. Stating the stack and boundaries keeps the AI from pulling in heavy dependencies that break the build or quietly route your data somewhere it should not go.
Can't tell who does what in the lab
List the roles and their top tasks as user stories. User stories pin down exactly what each person must be able to do, so the AI builds the features that matter — not a generic CRUD app.
The same set on /recipes, filtered by tool and role.
The case for writing the spec first — from DeepLearning.AI's course on spec-driven development with coding agents.
How a written spec keeps an AI agent building the right thing instead of drifting mid-build.
Because vibe coding fails when the AI has to guess what you meant. A short, precise spec turns a vague wish into something the AI can build correctly the first time — instead of a confident, bug-ridden everything-app you then have to unpick.
It is faster overall. You catch a wrong assumption on a 10-line plan in seconds, not after the AI has generated 2,000 lines of the wrong app. The spec is the cheap place to be wrong.
A one-line description, who the users are and their top tasks (user stories), the data model, the screens, acceptance criteria for the key features, the tech constraints, and an explicit out-of-scope list. That fits on a page and is enough for the AI to build from.
A checkable statement of how you will know a feature works — ideally with a concrete test case. "When quantity ≤ threshold the row turns amber and is counted in a Low-stock badge" can be verified; "make the alert work" cannot.
Write the out-of-scope list out loud — the features v1 will NOT have. An explicit boundary is what stops both you and the AI from quietly adding "just one more thing" until nothing is finished.
No — have it turn the spec into a numbered, dependency-ordered build plan and approve that first. The approved plan is the contract; you review 10 lines, not a finished app.
Update the spec first, then ask "given the updated spec, what needs to change in the code?" Treat the spec as the living source of truth and re-paste it at the start of each session, so the code and the plan never silently drift apart.
PRDUser storyData modelAcceptance criteriaOut-of-scopeGuardrailsBuild planLiving specVibe codingAsk, share, or report — over on the Heidelberg AI community forum.