Copy-paste security prompts for Lovable, Cursor, Bolt and Claude Code
By Milo Kits · Updated
Start with an audit-only prompt that tells your AI coder to list problems and change nothing, then fix one area at a time. The prompts below cover the mistakes that most often leak data in AI-built apps: secret keys in the browser, tables without Row Level Security, public storage, roles users can change, unsigned payment webhooks, missing rate limits and missing security headers. After each fix, re-test from the outside. The AI saying it's fixed isn't proof.
How to use these prompts
Run prompt 1 first and read the list. Don't let the AI change code yet.
Fix one area at a time with the matching prompt, and review the diff before you accept it.
Test the result yourself from the outside: logged out, as a second user, and by searching the live JavaScript.
Never paste real secret keys into an AI chat. Refer to them by name.
1. Audit first, change nothing
Use this before anything else. It gives you a list you can check, instead of a pile of changes.
Fix prompt
Review this app for security problems and do not change any code yet. Check: secret keys in frontend code or VITE_/NEXT_PUBLIC_ variables; database tables without Row Level Security or with policies like using (true); public storage buckets; pages, API routes and functions that work without a signed-in user; places where a user could change their own role; payment code that unlocks features without a verified webhook; missing rate limits on login, signup and password reset; missing security headers. List each finding with the file path, why it matters and the smallest fix. Ask me before changing anything.
2. Move secret keys out of the browser
Anything the browser downloads, anyone can read. Only public keys (like the Supabase publishable or anon key) belong there.
Fix prompt
Find every secret key used in frontend code or in a VITE_ or NEXT_PUBLIC_ variable (OpenAI, Anthropic, Stripe secret, Supabase service_role or sb_secret_, email or SMS providers). Move each one into server-side secrets and call it only from a server function or Edge Function that checks the signed-in user. Keep only public keys in the frontend. Then list which keys I must rotate because they were already shipped.
3. Turn on Row Level Security everywhere
A table without RLS can be read, and often changed, by anyone with the public key that's already in your page.
Fix prompt
List every table in the public schema with its RLS status and current policies. Enable RLS on every table where it's off. For tables with user data, write separate select, insert, update and delete policies so each user can only reach rows where user_id = (select auth.uid()). Show me the SQL before running it, and tell me which tables you think should stay readable by everyone and why.
4. Replace 'using (true)' policies
A common AI shortcut when a query returns nothing. It switches the protection off for that role.
Fix prompt
Find every RLS policy that uses using (true), with check (true), or has no condition, and every policy that applies to the anon role. For each one, tell me what it allows in plain English. Replace it with a policy that only allows the owner (or the right team) unless the data is genuinely public, like a list of published blog posts.
5. Make private files private
Public buckets serve every file to anyone with the link.
Fix prompt
List my storage buckets and say which are public. Make every bucket that holds user uploads, invoices or documents private. Add storage.objects policies so each user can only read and write files in their own folder, and serve private files with short-lived signed URLs.
6. Lock down server functions and API routes
The public key is in your page, so 'the request had our key' doesn't mean 'a real user sent it'.
Fix prompt
For every API route, server action and Edge Function, check whether it requires a signed-in user. Functions that call paid APIs, send email or return private data must read the user from the Authorization header, reject requests without a valid user, and check that the user owns the record they ask for. List each function with what you changed.
7. Stop users making themselves admin
If the role sits in a table users can update, someone can set it to admin on their own row.
Fix prompt
Find where user roles or plan levels are stored. Check whether a normal user can change their own role, plan or credits through the API. Move these fields to a table users can't update, or restrict the update policy so those columns can't change, and check admin access on the server, not only in the UI.
8. Unlock paid features only from a signed webhook
A 'success' page anyone can open isn't proof of payment.
Fix prompt
Check how paid access is switched on. It must happen only when the payment provider's webhook arrives and its signature is verified with the webhook secret, not when the user reaches a success or thank-you page. The price and plan must come from the server or the provider, never from the browser. Show me the webhook handler and the signature check.
9. Add rate limits where it hurts
Login, signup, password reset and anything that costs you money per request.
Fix prompt
Add rate limiting to login, signup, password reset, contact forms and every endpoint that calls a paid AI or email API. Limit per IP and per account, return a clear error when the limit is hit, and tell me where to set a monthly spend limit or budget alert on each paid API.
10. Add security headers
Cheap to add, and they block whole classes of attacks like clickjacking.
Fix prompt
Add security headers for my host ([Netlify / Vercel / other]): Strict-Transport-Security, X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, a Permissions-Policy, frame protection with frame-ancestors, and a Content-Security-Policy in report-only mode first. List every outside domain my app loads scripts, styles, images or API calls from, so the CSP doesn't break anything.
11. Tighten CORS
CORS that echoes any origin with credentials lets other sites read your logged-in users' data.
Fix prompt
Check every place that sets Access-Control-Allow-Origin. Replace * or an echoed Origin header with an explicit list of my own domains, and never combine a wildcard or echoed origin with Access-Control-Allow-Credentials: true.
12. Stop leaking details in errors
Stack traces and raw database errors tell a stranger how your app is built.
Fix prompt
Make sure errors shown to users are short and generic, and that stack traces, SQL errors, internal IDs and environment details are only logged on the server. Remove console.log calls that print tokens, user data or API responses in production.
Can I just ask my AI coder to 'make my app secure'?
You'll usually get a vague answer or changes you can't check. Ask for a list of findings first, with file paths and no changes, then fix one area at a time and test each fix yourself.
Which AI coding tools do these prompts work with?
They're plain English, so they work in Lovable, Bolt, Cursor, Replit, v0, Windsurf and Claude Code. Replace the words in square brackets with your own table, bucket or route names.
How do I know the fix actually worked?
Test the behaviour, not the code. Open private pages logged out, try user A's data as user B, search your live JavaScript for secret keys again, and re-run your free scanner or our header check.
Is it safe to paste my keys into the prompt?
No. Never paste secret keys into a chat with an AI tool. Put them in your platform's secrets storage and refer to them by name.
Do these prompts replace a security review?
No. They fix common, known mistakes. They don't find logic problems specific to your app, and an AI coder can make a fix that looks right and isn't.
This page is general information, not a security audit. Only test apps you own or have permission to test. Platforms and prices change, so check the linked sources for current details. Spotted something out of date? Email hello@milokits.com.