Lovable Backend Prompts: 15 for Roles, Jobs and RLS
Prompt builder · five steps · no account
Step 1 of 5
What are you building?
Building something else? Describe it to the AI generator
Ask Lovable for a rate limiter and you get a dashboard that displays limits without enforcing them. Ask for roles and you get a table nobody reads at request time. These 15 prompts specify enforcement in the database, and this page shows what Lovable's own scans catch, what they cost, and what only a query as the wrong user proves.
By Marco Kohns · Prompts written and run by us
Short answers
Short answers
Where do I start?
The RBAC rules engine, before any screen that depends on a role. Then soft delete and recovery, before any bulk write. Then ingest, then observability.
Pick by situation →What does a run cost?
? credits
Not measured for this category yet. The SaaS foundation run, which provisioned a backend with roles checked in the database, cost 10.4 credits; a backend prompt is that kind of build.
See what we do know →Does Lovable secure the backend itself?
Partly. It writes access rules when a feature stores user data, runs a Quick scan on every publish, and offers a free Deep scan. On our project the chat said the dependencies were clean while the Security view listed 2 high-severity issues.
What the scans showed →Lovable Cloud or my own Supabase?
Either. The built-in backend is on by default and provisions database, auth and storage together; your own Supabase project connects one per Lovable project, and the docs say switching is never automatic. The prompts fit both.
From the docs →15
Backend Logic prompts in this category
↳ Copy-paste, free
0of 15
Prompts from this category run in Lovable
↳ Next run: Role-Based Access Control Rules Engine
3runs
Measured so far across the library
↳ 1.8 to 10.4 credits each
27
Upvotes since Jan 2026
↳ One per visitor, self-reported
Data basis: no prompt run in this category yet; every card says so. The scan findings come from one session on 26 September 2026 in Marco's own workspace, the credit figures from the three measured runs elsewhere in the library, and the policy claims from the four kit schemas whose verification queries were executed. Docs checked 22 October 2026.
Find a prompt
What has to be enforced?
Cards are sorted by build order. Each says whether we ran it in Lovable, and if not, shows a question mark instead of a guess.
Showing 15 prompts
- Step 1 · Access▲ 1
Role-Based Access Control Rules Engine
Role-based access control with permissions and roles as rows and one database function can() that every policy and server function calls, deny by default.
Run it when: first, before any screen that depends on knowing who may see it.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 1 · Access▲ 1
Session Management System
Server-side session records checked on every request, a Security page to sign out one or all other devices, password-change sign-out and a new-device email.
Run it when: sessions have to end, be listed, or be revoked from another device.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 1 · Access
API Key Manager Dashboard
An API key manager that generates keys on the server, shows each key once, stores only SHA-256 hashes, and supports scope, expiry, revoke and rotation with a grace window.
Run it when: other systems call your app and each needs its own revocable key.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 1 · Access▲ 1
API Rate Limiter Dashboard
Per-key sliding-window rate limits enforced in the request handler, limit headers on every response, a 429 with Retry-After, tiers stored as rows and an admin dashboard.
Run it when: an endpoint is public, paid or AI-backed and a runaway caller would cost money.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 2 · Recovery▲ 1
Soft Delete & Data Recovery System
Soft delete with a 30-day Trash, restore that brings children back in one transaction, and row-level security that hides deleted rows from every list, search and count.
Run it when: before the first import or bulk edit, so mistakes have an undo.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Ingest
Data Import (CSV Upload) Pipeline
A four-step CSV import that maps columns, names every row error before writing, and commits in one transaction that rolls back completely when any row fails.
Run it when: an old spreadsheet has to come in with validation and a dry run.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Ingest▲ 3
Inventory Tracker
Inventory for 1 to 5 locations where stock is always computed from insert-only movements with actor and reason, plus low-stock views, a ledger and stock counts.
Run it when: quantities change from several places and must never go negative.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Events
Webhook Listener & Event Processor
Webhook receivers per source that verify signatures, store the raw payload, answer 200 within a second, and process idempotently on the provider's event id.
Run it when: a webhook is received by the integration prompt and now has to be processed, retried and replayed.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Events▲ 1
Background Job & Queue Monitor
A job monitor where every job reports state to a registry, with queue depth and oldest age, retry policies per type, a dead-letter queue and Stuck flags.
Run it when: anything runs on a schedule or after a request returns.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 3 · Events
Real-Time Notifications System
In-app notifications created only by a server function from a type registry, delivered live, with read state synced across tabs within 2 seconds and per-type preferences.
Run it when: users should see a change without refreshing, with the fan-out rules stated.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Standalone▲ 1
Redirect & URL Manager
Short links on your own domain at /go/{slug} with editable destinations, allowlisted domains, per-link click counts by day and referrer, and change history.
Run it when: short links or moved pages need a table and a 301, with the loop case handled.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 4 · Observe▲ 2
API Error Tracker
An API error tracker that groups failures by endpoint, error type and stack hash, sanitises context to 8 KB, reopens resolved issues as Regressed and flags hourly surges.
Run it when: an integration can fail silently, which is every integration.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 4 · Observe▲ 15
Internal Metrics Dashboard
An internal dashboard where each metric has an owner, a one-sentence definition and one read-only SQL query, snapshotted daily at 06:00 UTC with staleness flagged.
Run it when: the numbers have a truth source and someone decides from them each morning.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock - Step 4 · Observe
User Management Admin Dashboard
An internal admin dashboard to search accounts, view their state and run 5 account actions through role-checked server functions, each written to an insert-only admin_actions log.
Run it when: an admin has to act on users, and every action should be audited.
Not run yet · credits ?Pro version adds the growth-channel instructionsUnlock
Building the whole backend? The bundle has all 15 as one kit in build order, with every Pro version unlocked, plus 137 more prompts.
See what is in the 152-prompt bundleDisclosure: if you create a Lovable account through links on this page, we may earn a commission. It costs you nothing and does not change what we recommend.
Measured run
No backend prompt has been run yet. Here is what the scans showed on the one backend we built.
▍Context
Add role-based access control to an existing multi-workspace app: permissions and roles are rows, one check answers every access question, workspace admins manage roles through a permission matrix, and every change is audited. The one job: every action in the app is allowed or denied by one rule set an admin can read.
▍Core Features
1. Permission registry: keys in resource.verb form (project.create, member.invite, billing.view) with descriptions, seeded from the app's existing actions
2. Roles per workspace: Owner, Admin and Member are system roles that cannot be deleted; custom roles start as a copy of one
3. One database function can(user, permission, workspace), used by row-level security policies and server functions; deny by default, new permissions included
4. Matrix: roles as columns, permissions as rows grouped by resource, saved after a preview of who is affected
5. One role per member per workspace
▍Role Model & Precedence
▍Safe-Guard Instructions
- The UI hides what a user cannot do; the server check enforces it
- New code uses can() and never checks role names inline
▍Distribution hooks · Pro
Locked. The Pro version adds the growth-channel instructions for this screen.
- 01
The backend we have is the SaaS foundation from 26 September
Lovable enabled the built-in backend mid-build and reported roles checked in the database on every read and write. That project is where the scans below ran.
- 02
We asked the chat for a deep security scan
It ran the checks it can start itself, reported no findings, said the dependency audit was a little out of date, and told us the in-depth review has to start from the Security view. That message cost 1.3 credits.
- 03
Then we opened More > Security
Quick scan: automatic, free, last run 6 hours earlier. Deep scan: recommended, about 4 minutes, free, not scanned yet. Project dependencies: 53 packages, 2 known issues.
- 04
Run deep scan, 3 minutes
Both cards came back free and up to date, no issues found. Lovable's docs now put the Deep scan at 3 to 13 minutes and say both scans are free.
- 05
The dependency panel disagreed with the chat
Expanded, it listed @tanstack/react-start with 2 high-severity advisories, four minutes after the chat had said no vulnerable packages were found. The panel is the one to read.
- 06
What the first backend run adds
The RBAC prompt in a fresh project, balance before and after, every question recorded, and the verification queries from the kits run as a member and as an admin.




Credit math
What a backend run is likely to cost, from the runs we have
No figure for this category yet. The closest measured run is the SaaS foundation, which provisioned the backend, auth and roles for 10.4 credits. Scans are free; asking the chat to scan is not.
| Plan | Daily build credits | A backend-provisioning run (10.4) | Unused credits |
|---|---|---|---|
| Free | 5 a day, max 30 a month | Two days of daily credits plus 0.4 of a third. Plus 20 Cloud credits a month for what the backend consumes while running. | Daily credits do not roll over |
| Pro | 5 a day, plus 100 monthly plan credits from $25 | 5 from the day's credits, 5.4 from plan credits, on a fresh day | Plan credits roll over, expire after 2 months |
| Business | 5 a day, plus 100 monthly plan credits from $50 | Same split as Pro | Same as Pro |
Lovable's own examples, for scale
- “Add authentication”
- 1.20
- Asking the chat for a security scan (our run)
- 1.30
- Deep scan from the Security view
- 0.00
- A Plan mode message
- 1.00 plus research
Sources: Lovable docs, Credits and usage (illustrative) and Security view; the 1.3 is our own reading from the billing page, 26 September 2026. Checked 22 October 2026.
Three ways to spend less
- Scan from the Security view, never from the chat. Both scans are free there and the Deep scan refreshes the quick checks. The chat message that asks for one is billed and cannot start the deep review.
- Put the rule in the prompt, before the screen. A policy Lovable wrote for a screen is read-only in the database view and changes through chat, so a wrong rule costs a second build message. A stated rule costs nothing.
- Build recovery before the import. Undo is one prompt before the bulk write and a restore job after it.
Start here
Which backend prompt should you run first?
Pick the sentence that sounds like your project.
Rules first, then the things they protect
- 01Role-Based Access Control Rules Engine · one check function, deny by default
- 02Session Management System · sessions that end and can be revoked
- 03API Key Manager Dashboard · revocable keys, hashed at rest
- 04API Rate Limiter Dashboard · a limit that refuses, with the refusal shown
Build order
Four steps. Access rules before the things they protect, recovery before bulk writes.
01
Access
RBAC · Sessions · Keys
Roles as rows, one check function, deny by default. Nothing below is safe without it.
02
Recovery
Soft delete & restore
The undo, before the first import or bulk edit.
03
Ingest & events
Import · Webhooks · Jobs
Data coming in and work running later, each with its retry and its failure state.
04
Observe
Errors · Metrics · Users
Dashboards last, on a truth source the earlier prompts already write.
Anatomy
What each section of a backend prompt does
| Section | What it tells Lovable | What you get without it |
|---|---|---|
| Context | What is enforced, where, and by which single function | A screen that displays the rule and enforces nothing |
| Core features | Rows first, the check function second, the admin UI last | The admin matrix before the thing it toggles |
| Rules section | Precedence, scope, what wins when two roles disagree, decided in the database | An inline role check in every component, each slightly different |
| Build order | The check function before any screen that depends on a role | Screens that work until a second user signs in |
| Safe-guards | Deny by default; never a permissive stub; every change audited | A stub that returns true and passes the preview |
| Before building | Ask questions first, save answers to project knowledge | A role model guessed from the app name |
A one-line prompt gets you
- A permissions table nobody reads at request time
- A rate-limit screen that limits nothing
- A hidden flag instead of a recovery path
- A policy you cannot edit in the view and did not specify
A prompt from this page gets you
- One check function the whole app calls
- Refusals with the reason shown
- An undo before the first bulk write
- A rule the Quick scan has nothing to say about
Fixes
Where backend prompts go wrong, and the line that fixes it
Already built something that works for one user? Paste the fix line into your existing project.
Symptom
The permission check always returns true
Cause: Lovable stubbed the function to make the screen render and nothing asked it to finish. This site's own legacy database shipped a plan check that always returned false.
Fix line
Replace the stubbed can() function with one that reads the actor's roles and permissions from the database on every call. Deny by default. Then show me a query as a member that is refused.
Symptom
The dependency panel says 2 high, the chat says clean
Cause: the chat can only run the checks it can start itself; the Security view holds the dependency audit.
Fix line
Open More > Security, run the Deep scan, then update the packages the dependency panel flags and re-run. Do not change any policy or table while doing this.
Symptom
An import duplicated half the rows and there is no undo
Cause: the import was built before soft delete and batches.
Fix line
Add an imports table with one row per batch. Every imported row carries its batch id. Add a restore action that soft-deletes every row of a batch and a dry run that reports counts before writing.
Symptom
A rate limit that displays and never refuses
Cause: the prompt described a dashboard of limits and never the refusal.
Fix line
Enforce the limit server-side on every call to [endpoint]. When exceeded, refuse with a 429, a retry-after value and a logged row. The dashboard reads those rows; it enforces nothing.
Upvotes
Which Backend Logic prompts do builders upvote?
Upvotes since January 2026, one per visitor. Small numbers: read them as a hint, never as a ranking.
- Internal Metrics Dashboard15
- Inventory Tracker3
- API Error Tracker2
- Soft Delete & Data Recovery System1
- Background Job & Queue Monitor1
- File Manager with Upload/Tags1
The Complete Lovable Bundle
All 15 backend prompts in build order, plus every other prompt
Every prompt and kit, every Pro version unlocked. One payment, no subscription.
One payment. No subscription, no renewal, ever.
FAQ
Questions about Backend Logic prompts
Can Lovable handle backend logic, or is it frontend only?+×
It generates both. Lovable's docs, read on 22 October 2026, describe a built-in backend with a database, storage, authentication, realtime and functions, enabled for a workspace by default; enabling any one of database, users or storage provisions all three. The constraint is that backend code fails invisibly: a wrong colour is obvious in the preview and a permissive permission check is not.
Does Lovable write row-level security on its own?+×
The docs say Lovable sets up these rules automatically when it builds features that store user data, and that the policies are read-only in More > Database > Policies, so a change goes through chat. The same docs warn that server code using the service role bypasses those rules and has to check permissions itself. The prompts here state the rule so the generated policy is the one you meant, and the kits ship the verification queries that prove it.
What do Lovable's security scans check, and what do they cost?+×
Per the docs: the Quick scan runs automatically on every publish and takes seconds; the Deep scan includes it, reviews all application code for access control, unauthenticated endpoints, injection, leaked secrets, payments, authentication and exposed personal data, and takes 3 to 13 minutes. Both are free and consume no credits. Fix actions use an account's 10 free fixes, restored 24 hours after use. A chat message asking for a scan is billed; ours cost 1.3 credits.
Is Lovable Cloud the same as Supabase?+×
The docs now call it the built-in backend and say you can connect your own Supabase project instead, one per Lovable project, billed by Supabase, with no automatic migration in either direction. Some features need the built-in one: the in-editor Database, Users and Storage views, managed backups, SAML SSO. The RLS and function concepts in these prompts apply unchanged on both.
How is the backend billed separately from building?+×
Build credits pay for messages; run credits pay for what the backend does while hosted, metered in six categories: database, AI, compute, network, storage and realtime, visible under More > Usage. Free, Pro and Business each get 20 Cloud credits and 4 AI credits a month as a grant the docs label temporary, and neither rolls over.
Which of these prompts have been run?+×
None of the 15 yet. The rule pattern they encode was run: the SaaS foundation prompt built roles checked in the database for 10.4 credits, and all four kit schemas on the templates page execute with their verification queries passing as a member and as an admin. The scans on this page ran on that foundation project.
Where is the line between backend logic and an API integration?+×
Backend logic is your own server-side behaviour: roles, sessions, quotas, jobs, imports, recovery. An integration is your app talking to someone else's service. Webhooks sit on the line: receiving and verifying one is on the API page, processing it is the Webhook Listener prompt here.
What we have not tested yet
- All 15 prompts in this category. Their cards show a question mark until we run them.
- A policy Lovable generated on its own, queried as a second user, against the same policy written from a prompt here.
- Lovable Cloud against a connected Supabase project on the same prompt.
- The 10 free fix actions in the Security view: how many a generated backend needs.
Next run: Role-Based Access Control Rules Engine, the prompt excerpted above. How we test prompts
Who wrote this
Marco Kohns wrote these prompts and ran the scans shown above. Lovable Prompts is independent and not affiliated with Lovable.
“Try in Lovable” links are affiliate links: we may earn a commission when you create an account through them. The Pro versions and the bundle are our own paid products. Neither decides which prompt we tell you to start with.
Related reading
- free build kits with executed RLS schemas · Every policy tested on a Postgres cluster.
- SaaS starter schema · Non-members read zero rows, verified.
- API and webhook prompts · Receiving is integration; processing is backend.
- SaaS prompts · Entitlement before billing.
- the mistake with its own CVE · Trusting generated access control.
- where the Cloud panel lives in the editor · Database, users, storage, jobs.
- Lovable vs Replit · The incident worth knowing about.
- Plan mode for the fix that keeps failing · Lovable's debugging order.
- the admin dashboard kit · Aggregates that stay under RLS.
- the CRM kit · Reassignment blocked by policy.
- Lovable and Supabase · The docs on Cloud, migrations and RLS checks.
- admin dashboard prompts · Ten briefs that keep the aggregate function non-definer.
Other prompt categories
Sources
- Lovable docs: Built-in backend (Cloud)
- Lovable docs: Database access rules
- Lovable docs: Security overview
- Lovable docs: Security view
- Lovable docs: Security best practices
- Lovable docs: Project usage and run credits
- Lovable docs: Connect your own Supabase project
- CVE record: CVE-2025-48757 (MITRE)
All read on 22 Oct 2026.