Sub topic 9
Prompting an AI app builder
This chapter assumes you have scoped one core user flow, chosen a tool, and sketched a data model with an owner field on each record. Here you turn those decisions into prompts an AI app builder can act on, and you learn how to iterate without breaking what already works.
What a prompt does in a builder
An AI app builder takes text and produces screens, a database schema, and logic. It fills every gap in your text with a guess. A vague prompt like "build a task app" leaves the guesses to the tool. These guesses often include things you did not want, such as team features, a pricing page, or a login that lets everyone see everything.
A good prompt removes guesses where a wrong guess is costly. It leaves room for the tool on cheap decisions, such as colors and spacing.
The five parts of a structured prompt
A reliable first prompt has five parts, taken from your earlier scoping work:
| Part | What it states | Why it matters |
|---|---|---|
| Product and user | The app name and who uses it | Sets vocabulary and tone |
| Core flow | The one path a user follows, in order | Keeps the build focused on the hypothesis |
| Data | Tables, fields and allowed values | Prevents invented or missing fields |
| Rules | Who can read and change what | Drives access control |
| Out of scope | Features to leave out | Stops the tool from adding extras |
Here is a prompt that uses all five.
Build a web app called TaskNest for freelancers to track client tasks.
Users: freelancers who sign in with email.
Core flow: a signed-in user creates a task with a title, client name and due date, sees only their own tasks in a list, and marks a task done.
Data: tasks(id, owner_id, title, client_name, due_date, status). status is one of todo, doing, done.
Rules: each user can read and change only their own tasks.
Out of scope for now: teams, file uploads, payments, notifications.
Use a simple, clean layout with a single list page and a create-task form.Notice what it does. The flow is one sentence with a clear order. The status values are listed, so the tool will not invent "in progress" or "blocked". The rule names the owner, so the tool has a reason to add an owner_id filter. The out-of-scope line is as useful as the flow, because builders tend to add features.
Write for testable behavior
Prefer statements you can check by clicking through the app. "Users see only their own tasks" is testable: sign in as two users and compare lists. "The app should be secure" is not testable, and the tool will interpret it however it likes.
Good habits:
- Use the exact names from your data model. If you call it
client_namein one place and "customer" in another, the tool may create two fields. - State allowed values for any field with a fixed set.
- Describe the empty state, such as "show 'No tasks yet' with a create button when the list is empty."
- Say what happens on failure, such as "show an error message if the title is blank."
Iterate in small steps
The first prompt builds the skeleton. After that, change one thing at a time. Large rewrite prompts make builders regenerate pages, and working parts can break without warning.
A useful iteration prompt names the location, the current behavior, and the wanted behavior:
On the task list page, tasks with status "done" still appear at the top.
Sort the list by due_date ascending and show done tasks at the bottom.
Do not change the create-task form or the data model.The last line is a guard. Telling the tool what to leave alone reduces collateral edits.
Common errors
- Asking for everything at once. A prompt with twelve features gives twelve half-finished features. Start with the core flow and add later.
- Describing the interface instead of the behavior. "A blue button in the corner" matters less than "clicking Save stores the task and returns to the list."
- Leaving access rules implicit. Many builders create a working app where every signed-in user sees all rows. State the rule, then verify it yourself.
- Mixing a fix and a feature. If a prompt asks for both and the result breaks, you cannot tell which request caused it.
- Repeating the same failing prompt. If two tries fail, the tool is missing information. Add a concrete example, such as the exact error text or a sample row, instead of rewording.
- Trusting the summary. The tool may say "access rules added" when it only hid data in the interface.
Put the rule in the database when you can
If your builder uses a Postgres backend such as Supabase, you can state the access rule at the database level. Row-level security (RLS) is a database feature that checks a policy on every read and write. Even if the generated interface has a bug, the database refuses rows that belong to someone else.
You can include the SQL in your prompt or run it yourself:
create table tasks (
id uuid primary key default gen_random_uuid(),
owner_id uuid not null references auth.users(id),
title text not null,
client_name text,
due_date date,
status text not null default 'todo' check (status in ('todo', 'doing', 'done')),
created_at timestamptz not null default now()
);
alter table tasks enable row level security;
create policy "owners read own tasks" on tasks
for select using (auth.uid() = owner_id);
create policy "owners insert own tasks" on tasks
for insert with check (auth.uid() = owner_id);
create policy "owners update own tasks" on tasks
for update using (auth.uid() = owner_id) with check (auth.uid() = owner_id);Note there is no delete policy. With RLS on, an operation without a matching policy is denied, so users cannot delete tasks. If you want deletion, add a policy for it. When you paste SQL into a prompt, say "use this schema exactly" so the tool does not rewrite it.
Keep a prompt log
Save each prompt and a one-line result in a document. Builders can drift from earlier instructions as a conversation grows, and a log lets you restate key rules or restart from a clean project. The log also helps when you later move to custom code, because it records the intended behavior.
Exercises
Exercise
A builder generated your task app, but every signed-in user can see every task. Name two places to fix it, and say which one is the stronger guarantee.
Show answer
Fix it in the interface or query by filtering on owner_id, and in the database by adding row-level security policies. The database policy is stronger, because it enforces the rule even if the generated interface or queries have a bug.
Exercise
Rewrite this prompt so it is testable: "Make the task page nice and secure, and add whatever features freelancers need."
Show answer
A good answer names behavior and limits, for example: "On the task list page, show the signed-in user's tasks sorted by due_date ascending, with a 'No tasks yet' empty state. Each user can read and change only their own tasks. Out of scope: teams, payments, notifications." It replaces "nice", "secure" and "whatever features" with checkable statements and an out-of-scope list.
Exercise
Your fix prompt failed twice with the same wrong result. What should you change in the third prompt?
Show answer
Add information instead of rewording. Include the exact error message or a sample of the wrong output, name the page or component, state current and wanted behavior, and add a line saying what not to change.