Add rls policies: Free AI Prompt | SheCodes

Free AI prompt · The Code Book

Add rls policies

A ready-to-use prompt from the chapter Connecting to a Database. Paste it into Claude, ChatGPT, Lovable, Bolt or any AI coding tool.

The prompt

“My posts table has security turned on but no rules set, so my app can't see anything. Add these rules: anyone can read published posts, signed-in users can create new posts, and each user can only edit or delete their own posts. Walk me through what each rule does in plain English.”

How to use it

  1. Copy the prompt and paste it into your AI coding tool.
  2. Check the result in the preview, then ask for changes one at a time: "make the buttons bigger", "use my brand colours".
  3. Read the chapter to understand why it works and what to do next.

More prompts like this

All prompts

Hook supabase into my project

“Connect Supabase to my project. My Project URL is [paste URL] and my public key is [paste key]. Set up everything needed to start using Supabase, and keep my keys in a safe place so they're never pushed to GitHub. Confirm it's working by loading a row or two from any of my tables.”

Add data to a page

“On my /products page, fetch all rows from the products table in Supabase and display them as cards. Use server-side rendering so the data is available on first load. Each card should show the product name, price, and image. Sort by newest first.”

Save a form to the database

“On my /contact page, when the user submits the form, save the data (name, email, message) to a contact_messages table in Supabase. Show a loading state while saving, a success toast when it works, and an error toast if it fails. Clear the form after a successful save.”

Open a new table safely

“I just created a posts table in Supabase. Grant my app access to it so it stops saying 'permission denied for table', make sure Row-Level Security is turned on, and explain in plain English who can now read and change what.”

Real-time subscription

“In my chat app, subscribe to new messages in the messages table using Supabase Realtime. When a new message is inserted, automatically add it to the displayed message list without a page reload. Clean up the subscription when the component unmounts.”

Optimistic updates

“When the user toggles a checkbox in my todo app, update the UI instantly (don't wait for the database). If the database write fails, revert the UI change and show an error toast. This makes the app feel much faster.”