AI
50 AI Prompts for Supabase and Firebase Development
Developer-tested AI prompts for Supabase database design, Row Level Security, auth, Edge Functions, Firebase Firestore data modeling, Security Rules, and choosing between the two platforms.
Why Supabase and Firebase Developers Benefit from AI Prompts
Backend-as-a-service platforms like Supabase and Firebase give developers a database, auth, storage, and serverless functions without managing infrastructure. The trade-off is that both platforms have their own query languages, security rule syntax, and data modeling patterns that are specific enough to trip up AI models without clear context.
Supabase Row Level Security policies, written in PostgreSQL policy syntax, are the most common area where developers reach for AI — the syntax is powerful but unfamiliar to developers coming from application-layer authorization. Firebase Security Rules have a similar learning curve. The prompts in this guide cover both, with enough context to produce policies that actually work.
- Generate Supabase RLS policies for multi-tenant and user-owned data patterns
- Build Supabase auth flows with social providers, magic links, and MFA
- Design Firestore data models with correct collection/document nesting
- Write Firebase Security Rules that enforce user ownership and role permissions
- Create Supabase Edge Functions and Firebase Cloud Functions for server-side logic
Supabase Database Design and RLS Prompts
Supabase uses PostgreSQL, which means you get the full power of SQL with foreign keys, indexes, views, and stored functions. Row Level Security (RLS) is PostgreSQL policy syntax that runs in the database before any query — it filters which rows a user can read, insert, update, or delete based on the JWT claims passed from Supabase Auth.
The most common RLS patterns are user-owned rows (a user can only see their own data), team-shared rows (all members of a team can see team data), and admin bypass (admin users bypass all filters). These prompts generate working policy SQL for all three patterns.
Act as a Supabase and PostgreSQL RLS expert.
Task:
Write Row Level Security policies for a multi-tenant SaaS.
Table: projects
Columns: id (uuid), tenant_id (uuid), name (text),
created_by (uuid, FK to auth.users), created_at
Access rules:
- SELECT: users can only read projects in their tenant
(tenant_id matches the user claim from auth.jwt())
- INSERT: authenticated users can create projects in their tenant
- UPDATE: only the project creator or a user with role admin in their tenant
- DELETE: only users with role admin in their tenant
User role is stored in a separate table:
tenant_members(tenant_id, user_id, role) where role is owner, admin, or member
Provide:
1. Enable RLS statement
2. Each policy as CREATE POLICY with a descriptive name
3. A helper function get_my_tenant_id() that reads from JWT claims
4. How to pass tenant_id in the JWT using Supabase custom claimsSupabase Auth and User Management Prompts
Supabase Auth handles email/password, magic link, and OAuth providers out of the box. The auth.users table stores the identity data while your application tables store profile data. The standard pattern is a profiles table that has a one-to-one relation with auth.users, populated by a database trigger on new user creation.
These prompts generate the profiles table setup with trigger, social auth configuration, magic link flows, and the custom claims hook for adding roles and tenant IDs to the JWT token.
Act as a Supabase Auth expert.
Task:
Set up the user profile pattern for a Supabase application.
Requirements:
1. Create a profiles table:
- id: uuid, references auth.users(id) on delete cascade
- username: text, unique, 3-30 chars
- display_name: text
- avatar_url: text
- created_at: timestamptz, default now()
2. Database trigger:
Automatically create a profiles row when a new auth.users row is inserted
Set display_name from the user email local part (before the @)
3. RLS for profiles:
- SELECT: anyone can read profiles (public profiles)
- UPDATE: users can only update their own profile
4. Custom claims hook (using Supabase auth.hook):
Add user_role and tenant_id to the JWT access token
Reading from a tenant_members table
Provide all SQL as a single migration file.Supabase Edge Functions and Realtime Prompts
Supabase Edge Functions are Deno-based serverless functions that run on the Supabase global edge network. They are used for webhook processing, third-party API integration, and server-side logic that needs access to environment secrets. Unlike client-side code, Edge Functions can hold API keys safely.
Supabase Realtime lets clients subscribe to database changes via WebSockets. These prompts generate Edge Functions for common webhook patterns and Realtime subscription code for React applications.
Act as a Supabase Edge Functions expert.
Task:
Write a Supabase Edge Function that handles a Stripe webhook.
Webhook events to handle:
- checkout.session.completed: update user plan in profiles table
- customer.subscription.deleted: downgrade user to free plan
- invoice.payment_failed: mark user as payment_failed in profiles
Requirements:
- Verify the Stripe webhook signature using STRIPE_WEBHOOK_SECRET env var
- Return 400 for invalid signatures
- Use the Supabase admin client (service role) to update the database
- Log each event type and outcome
- Return 200 for unhandled event types (do not throw)
Use: Deno, Stripe Deno SDK, Supabase JS client with service role key
Include: how to deploy with supabase functions deploy and set secretsFirebase Firestore Data Modeling Prompts
Firestore is a NoSQL document database where data modeling decisions have a major impact on query performance and cost. Unlike SQL, Firestore cannot perform arbitrary joins — data must be denormalized or structured so that the queries you need can be satisfied by reading a single collection.
The most important Firestore data modeling decision is whether to use subcollections or arrays for one-to-many relationships. Subcollections are better for large collections that need independent querying. Arrays (as document fields) are better for small, bounded lists that are always read with the parent document. These prompts generate data models optimized for specific query patterns.
Act as a Firebase Firestore data modeling expert.
Task:
Design a Firestore data model for a task management application.
Entities:
- User: id, email, displayName, photoURL
- Workspace: id, name, ownerId, memberIds (list of user IDs), createdAt
- Project: id, workspaceId, name, status, createdAt
- Task: id, projectId, title, description, status, assigneeId, dueDate, createdAt
- Comment: id, taskId, authorId, text, createdAt
Query requirements:
- Get all workspaces where the current user is a member
- Get all projects in a workspace
- Get all tasks in a project, filterable by status and assignee
- Get all comments for a task, ordered by createdAt
- Get all tasks assigned to the current user across all projects
For each collection:
- Show the document path and structure
- Identify which fields need indexes
- Show the Firestore query for each access pattern aboveFirebase Security Rules Prompts
Firebase Security Rules control who can read and write to Firestore, Storage, and the Realtime Database. The rules syntax is a custom language that evaluates to allow or deny for each database operation. The most common patterns are allowing users to read and write only their own documents and restricting write access to authenticated users.
Security Rules are tested using the Firebase Emulator Suite and the Rules Playground in the Firebase console. These prompts generate rules for common access patterns and include comments explaining the logic so they are easy to audit and modify.
Act as a Firebase Security Rules expert.
Task:
Write Firestore Security Rules for a multi-workspace task application.
Collections and access requirements:
workspaces/{workspaceId}:
- Read: any authenticated user who is in memberIds array
- Create: any authenticated user (they become the owner)
- Update: only the workspace owner
- Delete: only the workspace owner
workspaces/{workspaceId}/projects/{projectId}:
- Read/Write: any workspace member
workspaces/{workspaceId}/projects/{projectId}/tasks/{taskId}:
- Read: any workspace member
- Create/Update: any workspace member
- Delete: only the task creator (check createdBy field) or workspace owner
Provide:
- Complete firestore.rules file
- A helper function isWorkspaceMember(workspaceId) for reuse across rules
- Comments explaining the logic for each rule
- How to test these rules using the Firebase EmulatorSupabase vs Firebase: Choosing the Right Platform
Supabase and Firebase solve the same problem — a managed backend for apps — but they make different trade-offs. Supabase is built on PostgreSQL, which means SQL queries, joins, and the full relational model. Firebase uses NoSQL document storage (Firestore), which scales horizontally with no schema enforcement but requires careful data modeling.
For teams that know SQL and need relational data, Supabase is the better fit. For teams building real-time mobile apps with offline support, Firebase has more mature SDKs. Both have generous free tiers, both support auth and storage, and both can run AI-generated code well when given clear context about which platform is in use.
- Choose Supabase: relational data, complex queries with joins, PostgreSQL extensions (pgvector, PostGIS)
- Choose Supabase: team with SQL experience, need for real-time via Postgres changes
- Choose Firebase: offline-first mobile apps (Android/iOS with Firebase SDK)
- Choose Firebase: simpler document-based data with Google ecosystem integration
- Either works well for: web apps, Next.js, React Native, auth, file storage, and serverless functions
FAQ
What is the best way to use AI for Supabase development?
Always specify Supabase (not just PostgreSQL) and include your table schema when generating RLS policies or queries. For Edge Functions, mention Deno since the runtime is different from Node.js. For auth flows, specify whether you are using the Supabase JS client v1 or v2 since the API changed significantly between versions.
Can AI generate Supabase RLS policies?
Yes. Paste the table schema and describe who should be able to read, insert, update, and delete each table. Specify whether the user identity comes from auth.uid() (standard Supabase auth) or a custom JWT claim. The prompt in Section 2 shows the full structure for multi-tenant RLS policies.
How do I prompt AI for Supabase auth setup?
Describe the auth method (email/password, magic link, OAuth provider), the profile data you need to store beyond the auth.users table, and whether you need custom JWT claims for roles or tenant IDs. The prompt in Section 3 covers the profiles trigger pattern and custom claims hook.
Can AI help me model Firestore data?
Yes. Describe your entities and — most importantly — the queries you need to run. Firestore data modeling is driven by query patterns, not entity relationships. AI designs the collection structure, identifies required indexes, and shows the Firestore query for each access pattern when given this information.
What is the difference between Supabase and Firebase?
Supabase uses PostgreSQL (relational, SQL queries, joins). Firebase uses Firestore (NoSQL document store, no joins). Supabase is open source and can be self-hosted. Firebase is a Google proprietary service. Both provide auth, file storage, and serverless functions. Choose Supabase for relational data and SQL familiarity; choose Firebase for offline-first mobile apps.
Can AI write Firebase Security Rules?
Yes. Describe each collection path, who can read and write it, and the conditions (user must be authenticated, user ID must match the document owner field, user must be in a members array). AI generates the rules syntax and helper functions. Always test generated rules in the Firebase Emulator before deploying.
Can AI help me migrate from Firebase to Supabase?
Yes. Describe your Firestore collections and documents, and AI maps them to a PostgreSQL schema with equivalent tables and indexes. For auth migration, both platforms support email/password so user records transfer cleanly. Data migration from Firestore to PostgreSQL requires a script to read Firestore and write to Supabase — AI can generate that script when given both schemas.
Which BaaS is better for a new project in 2026?
For most new web projects, Supabase is the better default because PostgreSQL gives you more query flexibility, the data is easier to export and migrate, and the open-source codebase means you are not locked into a single vendor. Firebase remains the better choice for Android and iOS apps that need the offline sync SDK, and for teams already in the Google Cloud ecosystem.
Related free tools
If you want to turn this topic into action, use one of ShortIQ's free tools for campaign planning, UTM structure, or QR distribution.
Continue Reading
Explore more guides on link shortener SaaS strategy, Bitly alternatives, and white label link management.
Free newsletter
Get new guides in your inbox
We publish practical guides on dev tooling, prompt engineering, marketing workflows, and deployment. No fluff — straight to the point.
No spam. Unsubscribe any time.
Was this article helpful?
Tell us if this guide solved the problem or what was still missing. We use this to improve the blog and only follow up if you explicitly allow it.