Sub topic 10
Reviewing and correcting generated output
This chapter assumes you have a data model with ownership fields and have written a structured prompt for an AI app builder. A generated app that looks right can still be wrong underneath. Review it against your spec before you add features.
Review against the spec, not the screen
The builder optimizes for an app that runs. Your spec asks for an app that behaves correctly. Check these four areas in order:
- Core flow. Walk through the flow from your prompt as a new user, start to finish.
- Data. Open the database view. Confirm the tables, field names, types and allowed values match your model.
- Access. Sign in as two different users and try to see each other's records.
- Scope. Look for features you listed as out of scope. Builders often add extras such as team pages or a payments stub.
Common errors in generated apps
- Access rules only in the interface. The list page filters by user, but the database returns every row to anyone who calls it directly.
- Permissive policies. The builder writes a rule such as
using (true)so that queries work, which allows every signed-in user to read everything. - Invented fields. A column like
priorityappears that you never asked for. - Hardcoded secrets. API keys appear in front-end code, where any visitor can read them.
- Fake success. A button shows "Saved!" but the write failed or never ran.
Fix the policy
Suppose you find this policy in the generated database:
create policy "read tasks" on tasks
for select using (true);User B can now read user A's tasks. Replace it with an ownership rule:
drop policy "read tasks" on tasks;
create policy "owners read own tasks" on tasks
for select using (auth.uid() = owner_id);Then repeat the two-user test. Do not assume the fix worked until user B sees an empty list.
Correct with narrow prompts
Ask for one change at a time, name the exact thing that is wrong, and state the expected result. For example: "The tasks table has a priority column that was not requested. Remove it and any UI that uses it. Do not change other tables."
Vague prompts such as "make it more secure" invite rewrites that break parts that already work. Save a version or snapshot before each fix, so you can roll back if the builder damages something.
Keep a review log
Write down each defect, the prompt that fixed it and the check that confirmed it. When you rebuild or change tools later, the log works as a regression checklist.
Exercise
A generated task app hides other users' tasks on the list page, but a teammate shows that calling the data API directly returns all tasks. What is wrong, and where should the fix go?
Show answer
The access rule exists only in the interface. The fix belongs in the database as a row-level security policy, such as using (auth.uid() = owner_id), so the data layer enforces ownership. Then retest with two accounts.