Staging vs Production: Why You Need Both Even Solo

Production is the copy of your app that real users touch. Staging is a second copy with its own database and its own keys, where a mistake cannot reach a customer. You need both even if you are the only person on the project, because an AI agent holding a live database connection can run a destructive command in seconds, and a prompt is not a permission.
In July 2025, Jason Lemkin, founder of the SaaStr community, was building an app with Replit’s agent when it deleted his production database. The records covered more than 1,200 executives. He had told the agent to freeze changes, and it ran the destructive command anyway. Replit’s CEO called it “unacceptable and should never be possible,” and the company said it was rolling out automatic separation of development and production databases (The Register). The data was recovered in the end (Fast Company), which is not something to plan on. The lesson is not that one tool is bad. A freeze instruction in a prompt is a request. A separate database is a wall.
What has to differ between staging and production?
Three things. If any one is shared, you do not have staging, you have a second URL.
| Production | Staging | |
|---|---|---|
| Database | Real users, real rows | Its own project, fake rows |
| Keys | Live Stripe, live email, real AI keys | Test-mode Stripe, a sandbox email setup, a separate AI key with a low spend cap |
| URL and logins | Your domain | A different URL, with its own test accounts |
Everything else should be identical. Staging earns its keep by being boring.
Do I really need this if nobody uses my app yet?
Not a full one. Before the first stranger signs up, a local copy is enough, as long as your agent cannot reach the only copy of anything you would hate to rebuild. Lemkin’s records were months of his own work, not customers. The day someone you do not know creates an account, a second project becomes worth an afternoon. Then run every schema change there first (migrations without losing data).
How to set it up in the tools you probably use
Lovable. Lovable used to offer separate Test and Live databases. It retired that beta on October 23, 2026, and the old Test databases were fully deleted on December 1 (Lovable docs). Today, new projects run on one database, and the replacement is drafts, which are copies of your project where you try changes before accepting them. Read the fine print on drafts before trusting them as staging (drafts docs):
- A draft on Lovable’s built-in backend usually gets its own database filled with example data. A banner above the preview says so. No banner means you are editing live data.
- If your project uses your own Supabase project, drafts share your live backend. Data you change in a draft changes your live app, and deleting the draft does not undo it.
- In every draft, secrets and connected services use their live values. An email your app sends from a draft is a real email, and with your own live Stripe key, a payment is real.
Accepting a draft also changes your live database structure right away, before you publish. So a draft protects your code and, on the built-in backend, your data. It does not protect you from your own live keys.
Supabase. The free plan gives you two active projects, so the cheap staging is a second project you create yourself. Free projects pause after a week of inactivity (pricing), so expect to unpause it. On the Pro plan you can use branching, where each branch has its own database and credentials. Branches start with no data from production, which is deliberate, and OAuth and SMTP secrets arrive as placeholders, so “Google login works in prod but not on the branch” is expected until you set branch secrets (branching docs). Branches also need the GitHub integration or the CLI, and each one is billed per hour on top of the Pro plan (billing), so delete what you are not using. For most solo builders, the second free project is the realistic default.
Vercel. Every project has Local, Preview and Production environments, and each can hold different environment variables (Vercel docs). Set your database URL and secret keys separately for Preview and Production. A named staging environment needs a Pro plan, but a Preview that always points at the staging database does the same job.
Stripe. Test mode and live mode use different keys and different webhook endpoints, and objects you create in a sandbox are not usable in live mode (Stripe go-live checklist). Here is the gotcha: a price ID like price_... from your sandbox does not exist in live mode, so a hardcoded one is a checkout button that dies on launch day. Keep price IDs in environment variables, one per environment.
What does your laptop point at?
This is the step people skip, and it is what the Replit story was really about: the agent that was supposed to be developing had a path to the production database. Having a staging project means nothing if the .env file on your machine, which your coding agent reads, still holds the production database URL.
Your keys and URLs live in environment variables, settings stored outside your code. Put staging values in your local ones and keep production values only in your host’s dashboard. On Vercel, vercel env pull writes your Development variables to .env.local, but it merges into an existing file and keeps entries that exist only locally (Vercel CLI docs). A production URL you pasted there months ago will survive every pull. Open the file and look.
Four ways staging quietly fails
- Same keys in both. The most common failure by far. Compare the
SUPABASE_URLin each environment. The project ID in the hostname must differ. If it matches, there is one database. - Staging that emails real people. Seed data from a real export plus a working email key equals a customer getting “Welcome!” from your test run. Use designated test addresses such as Resend’s
[email protected], which exist so your tests do not hurt your sending reputation (Resend docs). Do not rely on app code alone: give staging its own email API key with no real recipients, so a skipped guard still cannot reach a customer. - Schema drift. You fix a column in the staging dashboard, forget production, and the next deploy breaks. Make every database change a migration (a small SQL file in your repo that describes one change) and apply the same files to both. If a change only exists in a dashboard, it does not exist.
- Copying production data down. It makes staging realistic and puts your users’ personal data somewhere with weaker protection. Generate fake rows instead.
Pin it with a test that checks behavior
Environment rules rot. Someone fixes a bug at midnight, a new email call skips the guard, and staging mails a customer again. Write a test for what the app does for a user, not for how it is wired. “A staging signup never emails a real person and never touches the production database” is a behavior. “The variable MAIL_MODE equals sandbox” is wiring, and it keeps passing while the behavior breaks.
Here is a scratch version you can run with node --test (Node 22, no installs), with package.json set to {"type":"module"}. The environments:
export const envs = { production: { db: "https://prodref.supabase.co", mailAllowlist: null },};The first version of the code, which forgets the rule:
import { envs } from "./envs.js";export function signup(envName, email, { saveUser, sendMail }) { const env = envs[envName]; saveUser(env.db, email); sendMail(email);}The tests:
import { test } from "node:test";import assert from "node:assert";import { signup } from "./signup.js";
function spies() { const saved = [], mailed = []; return { saved, mailed, saveUser: (db, e) => saved.push([db, e]), sendMail: (e) => mailed.push(e) };}
test("a staging signup never emails a real person and never touches the production database", () => { const s = spies(); assert.deepEqual(s.mailed, []);});
test("staging still emails the safe test address", () => { const s = spies();});
test("a production signup saves to production and sends the welcome email", () => { const s = spies();});Run it and the first test fails: two pass, one fails, because staging emailed a stranger. Now add the guard:
const allowed = !env.mailAllowlist || env.mailAllowlist.includes(email);if (allowed) sendMail(email);Replace the sendMail(email); line with those two lines and all three pass. The third test proves the fix did not switch email off everywhere. Because the tests only look at what a user would experience, a later “fix” that breaks either side fails a test.
Note what the saved-rows assertions do. They name the exact row that must exist. An earlier draft of this test checked every saved row with every, and every on an empty list is true, so a signup that dropped all staging users passed too. A test needs a positive control: something that must be there, not only something that must be absent.
Test the real environments too
That test proves the code obeys envs.js. It cannot prove your deployed staging has a different database. On Vercel, pull both environments and compare (needs a linked project and Vercel CLI 64.6 or newer):
vercel env pull .env.preview --environment=previewvercel env pull .env.prod --environment=productiona=$(grep '^SUPABASE_URL=' .env.preview); b=$(grep '^SUPABASE_URL=' .env.prod)if [ -z "$a" ] || [ -z "$b" ]; then echo "missing value, cannot compare"elif [ "$a" != "$b" ]; then echo "different, good"else echo "SAME DATABASE"; fiVercel cannot pull Secret variables back (their values are write-only after saving), so a missing value means “cannot compare”, not “same”. Keep the database URL as a Config variable, or compare the project ref in the Supabase dashboard by hand.
Add .env.preview and .env.prod to .gitignore and delete them after, since the second one holds production values. Better still, make the app refuse to start in staging when its database host matches the production one, so the check runs on every deploy.
A prompt to start with
Audit how this app separates staging from production. List every environment variable and say which ones differ per environment. Flag any place a production URL, key or database is hardcoded or shared with staging. Do not change anything yet. Then write a seed script (a file that fills a database with fake rows) for staging. Then write tests of behavior, not wiring: a staging signup sends no email to a real address and writes nothing to the production database. Show me each test failing before you fix the code, then passing.
The one check an engineer does by hand
Prove the wall is there. In staging, create a record called STAGING TEST DELETE ME. Then open your production database in the dashboard and look for it. It should not be there. Then ask your AI tool to delete a row in staging and confirm production does not change. Delete the test record afterward. Two minutes, and it is the only evidence that counts.
Staging is item 6 on the vibe coding launch checklist, and keeping agents away from production data is item 7. It is also the cure for one of the six failures in what breaks when your app gets real users. If you are still deciding what to protect first, start with the 20-minute security check, and make sure no key from either environment leaked into your frontend.
The Get AI Native ebook goes deeper on this. It is free, and the expected launch is around Christmas. Join the waitlist on the homepage.