Skip to main content
Technical Enough
Next: Build Plan and launch

The pre-flight check: secrets, money, data, and the law

Chapter 2 of 7 in Launch and Run · 33 min

Two days before the club's launch, you show the site to the one engineer you know. She loads the home page with DevTools open on the Network tab, the list of every request the page sent. She picks one of the JavaScript files her browser downloaded with the page, searches it for the letters sb_secret, which is how every secret key from your database service begins, and turns the laptop toward you. The database's secret key is in that file, where any visitor can copy it, and with that key a stranger can read and change every row in your database. You had kept the key in the .env file and on the host's Environment Variables screen, where it belongs. But at some point the agent gave the variable a name that starts with NEXT_PUBLIC_, and Next.js copies the value of every variable with that prefix into the JavaScript that each visitor's browser downloads. Every page on the site works, which is why nothing warned you.

After Review what the AI built, you have a working site whose code you have reviewed. Before real members use it, run a pre-flight check: a short checklist you go through before launch, the way a pilot goes through one before takeoff. It covers the four things a working site can still get wrong: secrets, money, data, and the law.

When a working site causes you harm, the cause is usually a setting or a step you left undone at launch, not bad code.

The pre-flight checklist run before shipping to real usersA checklist card titled pre-flight checklist. Five rows, each marked with a clay tick: secrets live in environment variables and never in git; personal data is kept minimal and every piece is located; money carries a billing alert and a hard cap on every spend; rate limits sit on every endpoint with a per-user cap on metered ones; and the kill switch is written down and used once before launch. Caption: the first run takes about 40 minutes, and every later run takes a few.PRE-FLIGHT CHECKLISTSECRETSin environment variables, never in gitPERSONAL DATAminimal, and you know where each piece sitsMONEYa billing alert and a hard cap on every spendRATE LIMITSon every endpoint, a per-user cap on metered onesKILL SWITCHwritten down, and used once before launchThe first run takes about 40 minutes, and every later run takes a few.

The checklist card has five rows: secrets, personal data, money, rate limits, and a kill switch. Secrets, personal data and money are the first three checks below, and the law, the fourth, gets its own drawing near the end. The last two rows take a few minutes each.

  • Rate limits. A rate limit is a cap on how much one account can send in a given time. Put one on every endpoint (every address on your server that requests are sent to), and put a daily limit for each member on every metered feature, one that costs you money each time it runs. The club's metered feature is the Tidy page, so only signed-in members can use it, and each member can tidy a set number of messages a day.
  • A kill switch. A kill switch is a way to turn one feature off quickly while the rest of the site keeps running. The club has two: one hides the Tidy page, and one replaces the Join button with a line saying that joining is paused. Ask the agent to add each one as a setting you can change without editing code, write the steps down, and use each one once before launch.

Secrets: check that no secret key is in a page or in git

A secret is a private value that the site uses and that visitors must never see. In Part I the site had one, and now it has four. Each one lets the person who holds it do something specific:

  • The database's secret key can read and change every row in your database. The rules you set on each table in Add accounts and member-only pages do not apply to it.
  • The payment company's secret key can make any request to your account at the payment company, including a refund.
  • The signing secret is the value your site uses to check that a message really came from the payment company. A person who has it can sign a fake message saying that a member paid.
  • MODEL_API_KEY is the Tidy page's key from Environments: why it works on your machine and breaks online. A person who has it can use the AI service, and the charges go to you.

Coding agents leak secrets in two places. The first is an environment file that git has saved: the .env file holds the keys, but .gitignore, the list of files git must never save, never got the line that excludes it, so the keys end up in git's history and in the copy of your project on GitHub. The second is the mistake in the opening scene, a variable whose name starts with NEXT_PUBLIC_. Next.js copies the value of every such variable into the JavaScript that visitors download, so that prefix is only for values that anyone may see. Other frameworks have a prefix of their own, such as VITE_ in a project built with Vite. The fix starts with one renamed line, shown here as a diff (the before-and-after of a change):

- const secretKey = process.env.NEXT_PUBLIC_SUPABASE_SECRET_KEY;
+ const secretKey = process.env.SUPABASE_SECRET_KEY;

In that line, process.env is how the code reads an environment variable. You rename the variable the same way in the .env file and on the host's Environment Variables screen. Without the prefix, code that runs in the browser cannot read the value at all. So if a page stops working after the rename, that page was using the secret key in the browser, and you ask the agent to move that work to the server, which is where Backend, where the real work happens said a secret has to stay. FuelTheFam, our family nutrition app, works the same way: a fridge photo goes to our server, and our server calls the model, so no phone ever holds the key.

Some keys are made to be public, and those stay where they are. The database's publishable key belongs in the page, and it is safe there because every table has a rule.

To finish this check, ask the agent to search the project and its git history for anything that looks like a secret key, to list every variable whose name starts with NEXT_PUBLIC_, and to confirm that .gitignore lists .env. A key that has been in a page or in a shared repository has to be treated as copied, because anyone with access can still read it in every earlier save point. Revoke it at the service that issued it (cancel it so it stops working) and create a new one. Do this the same day, because automated programs watch public repositories and use any keys they find within minutes.

Money: set alerts and limits at each service that handles your money

Each outside service your site uses handles money in its own way, so go through them one at a time.

  • The host. Check first that your plan allows what the site now does. Vercel's free plan is for personal, non-commercial use, and its guidelines count taking payments from visitors as commercial use, so the club moves to the paid plan before launch. On the paid plan you set a budget for the month. The host emails you as your spending approaches the budget, and you can have it pause the site when the budget is reached.
  • The database. On the free plan of the service this course uses, you are not charged. Its paid plan has a setting called the spend cap, which keeps you from being charged for usage beyond what the plan includes. Leave that setting on.
  • The payment company. It does not send you a bill, because it keeps its fee from each payment. You can lose money there through refunds and disputes. Turn on its email notices for successful payments and for disputes, so that you learn about each one on the day it happens.

The fourth service is the AI provider, the company whose model the Tidy page calls. One tidied message costs a fraction of a cent, which sounds safe until something calls the model in a loop. A bug that retries a failed call a few times a second, left running overnight, makes a few hundred thousand calls, and a fraction of a cent multiplied that many times is a bill in the hundreds of dollars by morning. Set two things on the provider's billing page:

  • The billing alert at an amount that would annoy you, so you hear about unusual spending early.
  • The hard cap at an amount that would hurt, where the provider stops serving requests whether or not you are awake.

With both set, you wake up to an email saying the cap was reached, not an invoice. The daily limit for each member, from the checklist above, keeps one account or one bug from using up the whole cap. Decide also what a member sees when a limit is reached: the Tidy page should say that tidying is not available right now and keep the pasted message on the screen, and it should not show an error page.

You might object that you reviewed this code line by line, so checking again feels like distrusting your own review. But in the pre-flight you check the protections that still hold when something outside the code you reviewed goes wrong. A written instruction is not one of those protections: in July 2025 a coding agent on Replit deleted a live production database during an explicit code freeze, a period when no changes are allowed, against instructions on record.

In the pre-flight you check protections that work whether or not anyone follows instructions: a spending cap, a file git ignores, and a revoked key still protect you at 2 a.m., whatever the instructions say.

Data: store only what you need, and know which companies receive it

Personal data is any information about a person who can be identified, such as a name, an email address, or a photo. Your site does not keep its members' personal data to itself. It sends some of it to every outside service it uses:

  • The database and sign-in service holds each member's name, email address, and RSVPs.
  • The payment company holds the card details, and the name and email address on each payment.
  • The email service receives every address the site writes to, and the text of each message.
  • The host records every request in its log.
  • The AI provider receives every message pasted into the Tidy page, and a message copied from a group chat can have members' names in it.

Every outside service your site uses receives some of your members' personal data. The data is sent as soon as a member uses the feature that depends on that service: a message pasted into the Tidy page goes to the AI provider when the member presses the button.

What each company does with the data after that depends on its own terms. On your side, you take an inventory of your data, the way you listed what you store in Data, where information lives. List every piece of personal data your site touches, write one location beside each (which table, which log, which outside service), and remove anything without a clear job. Error trackers, services that record your site's errors, keep whatever passes through them, so check the logs for email addresses you never decided to store.

Then check who can read what you store. Run the two-account test from Add accounts and member-only pages once more, and ask the agent to list every table in the database with the rule on it. Auth, who you are vs. what you can do said you would come back to this permission check before launch.

This check ends with the sentence your privacy page must contain, the one that says what you keep, who receives it, and when you delete it. Here is ours for FuelTheFam, whose fridge feature turns a photo of an open fridge into a shopping list:

Photos you upload are sent to our AI provider to create your shopping list, are not used to train the provider's models, and are deleted from our servers after 30 days.

Every clause is a claim someone can check. "Sent to our AI provider" names a company that receives the data, as the list above did. "To create your shopping list" is the only purpose; if you also use the photos to improve the feature or in your demos, the sentence must say so, or it is false. "Not used to train the provider's models" describes what another company does, so write it only after you have read the provider's terms for data sent through its API, and note the date you checked. "Deleted after 30 days" needs a number you chose plus a deletion job, a scheduled task that actually deletes the photos; the template phrase "as long as necessary" promises nothing, and regulators know it.

The running club's version has more to cover, because the site keeps accounts and takes payments:

We keep your name and email address for as long as you are a member, and we delete them within 30 days after your membership ends. Card payments are handled by our payment company, and we never see your card number. A message pasted into the Tidy page is sent to our AI provider to produce the tidied post and is not kept on our servers.

Check each clause the same way before you publish it. The 30 days need a deletion job, and "not kept on our servers" is true only if neither the database nor a log stores the message.

The law: the documents your site needs at launch

Around that sentence, every site needs two documents at launch, and a site with an AI feature needs a third. Each is a page or less.

  • The privacy page. The retention sentence, the one above saying how long you keep data, is at its center; around it, list what you collect, where each piece is stored, and a working email address for deletion requests, which for the club is help@runclub.example. A manual process is fine at your scale; anyone whose email you store can ask what you hold and have it erased, whether or not the page says so.
  • The terms. What a member may do and what you do not promise. The club takes money, so its terms also say what a membership includes, how to cancel, and when a refund is given. On a site with an AI feature, the terms say that generated output can be wrong, before anyone relies on it.
  • The AI disclosure. Only a site with an AI feature needs this one, and the club's Tidy page is an AI feature. The disclosure is a visible line near the input saying that the replies are generated, and a law requires it. Article 50 of the EU AI Act, the duty to tell people they are interacting with an AI system, has applied since August 2, 2026, and the Digital Omnibus adopted in June 2026 left that date unchanged while moving the high-risk deadlines to December 2027 and August 2028. Systems already on the market get one later date, December 2, 2026, for Article 50's watermarking duty, the duty to mark generated content in a machine-readable way. FuelTheFam's shopping list reaches a user without anyone on our team reading it first, so that user should be told that a model produced it.

These documents are the minimum to have in place on launch day. The duties that depend on what your site collects and what it sells (consent banners, accessibility, the rules for checkout and subscriptions, the app stores) get two chapters of their own, straight after the launch chapter: The law of what you collect: privacy, consent, and tracking and The law of what you sell: accessibility, subscriptions, and the app stores.

The three documents a first ship needs, with the dates that matterThree document cards left to right. Privacy: what you collect and where each piece sits, the retention sentence, plus a working email for deletion requests. Terms: what the user may do, and that generated output can be wrong, with refund language the day you charge. AI disclosure: a visible line near the input saying the replies are generated, flagged with the EU AI Act Article 50 date, applying from August 2, 2026, and a note that the watermarking duty for systems already on the market follows on December 2, 2026. Caption: drafted with AI in an afternoon, verified line by line.PRIVACYwhat you collect andwhere each piece sits;the retention sentenceplus a working email for deletionTERMSwhat the user may do;generated outputcan be wrongrefund language when you chargeAI DISCLOSUREa visible line nearthe input: thesereplies are generatedwatermarking follows Dec 2, 2026EU · FROM AUG 2, 2026Drafted with AI in an afternoon, verified line by line.

The drawing shows the three documents as cards: the privacy page with the retention sentence and a working email for deletion, the terms with the line that generated output can be wrong and refund language for when you charge, and the AI disclosure with its EU dates. Its caption says you can draft them with AI in an afternoon and then verify them line by line.

Record the results in the idea file and the Build Plan

A pre-flight check helps you later only if you can tell what you checked and when, so write the results down in two places.

In the idea file, add a line or two for each check, with the month you ran it. Write the limits as numbers, so that a year from now you can tell that each one was a decision and not an accident. These are the club's lines:

Pre-flight, November
Secrets:  none in a page or in git; .env is in .gitignore;
          database secret key replaced after the leak
Money:    host on the paid plan with a monthly budget;
          alert and hard cap at the AI provider;
          emails for payments and disputes turned on
Limits:   Tidy for signed-in members only, 20 a day each;
          Tidy and Join can each be turned off, tried once
Data:     names, emails, and RSVPs in the database;
          card details only at the payment company
Law:      privacy page and terms published;
          AI line shown on the Tidy page

In the Build Plan, fill in three rows of the stack field now, while the facts are in front of you: the Data row says what personal data you store and where, the Hosting row names the host, the plan, and the monthly budget, and the Monitoring row says which alerts are set and which inbox they go to. You complete the other rows in the next chapter.

Try it now

The full pre-flight takes about 40 minutes. The checks themselves cost nothing, and the one cost this chapter can add is a paid plan at your host, if your site takes payments and the free plan does not allow that. You arrive with the working, reviewed site from Review what the AI built. You leave with all four checks passed or fixed, the results in your idea file, and three rows of the Build Plan filled in, ready for launch day in the next chapter.

No setup: Pick a site where you have an account, open DevTools on the Network tab, and reload the page. Note every request that goes to an address other than the site's own, because each of those addresses belongs to a company that receives something about your visit. If the site has an AI feature, use it once and find that request: a request to the site's own domain name means the key stayed on the server, and a request straight to an AI provider's address with a key in its headers (the extra information sent with a request) is a leaked key. Then read the site's privacy page clause by clause, as above, and note what it leaves out: whether it names the companies you just saw, and whether it says when your data is deleted.

With your tools: Open Claude Code in the running-club folder, or in your own project, and start with: "Search this project and its git history for anything that looks like a secret key, confirm that .gitignore lists .env, and list every environment variable whose name starts with NEXT_PUBLIC_, saying for each one whether it is safe for visitors to see." Fix what it finds, and revoke and replace any key that was exposed. Set the alerts, the budget, and the caps yourself, on each service's own billing page. Then ask for the inventory: "List every piece of personal data this site stores or sends to another company, and where each one goes." Draft your retention sentence from those facts. If a fix touched code, run the five payment tests and the two-account test again. Codex and Cursor accept the same requests in their chat panels. If nothing is installed yet, The Setup Clinic covers the install.

Either way, finish by adding the lines from the section above to the idea file. If you took the first path, write them for the site you looked at, using what you found.

Chapter Summary

  • You run the pre-flight check on your real site before real members use it, and it covers the four things a working site can still get wrong: secrets, money, data, and the law.
  • The club's site has four secrets: the database's secret key, the payment company's secret key and signing secret, and the Tidy page's MODEL_API_KEY. None of them belongs in a page or in git.
  • Keys leak in two places: an environment file git was never told to ignore, and an environment variable whose name starts with NEXT_PUBLIC_, which Next.js copies into the JavaScript every visitor downloads.
  • A key that has been in a page or in a shared repository stays exposed even after you remove it, so revoke it at the service that issued it and create a new one.
  • Go through money one service at a time: a plan at the host that allows a site that takes payments, with a monthly budget; the spend cap at the database; emails for payments and disputes at the payment company; and a billing alert and a hard cap at the AI provider.
  • Written instructions do not enforce anything; caps, files git ignores, and revoked keys keep protecting you no matter what goes wrong or who caused it.
  • Every outside service your site uses receives some of your members' personal data, so store the minimum and keep a location written beside every piece.
  • Your privacy page's retention sentence is checkable clause by clause: who receives the data, for what purpose, whether it trains models, and when it is deleted.
  • At launch a site needs a privacy page and terms. A site with an AI feature also needs a visible AI disclosure, which Article 50 of the EU AI Act has required since August 2, 2026.
  • Your idea file now has a dated line for each check, and three rows of the Build Plan's stack field are filled in; take both to Finish your Build Plan and launch, where you complete the plan and launch.

Sources

  • Business Insider and Fortune reporting on the Replit coding agent deleting a live production database (July 2025).
  • EU AI Act, Article 50 transparency obligations, applicable from August 2, 2026, with the Article 50(2) watermarking duty for systems already on the market from December 2, 2026; European Commission Digital Omnibus package (adopted June 2026), which moved the high-risk deadlines to December 2027 and August 2028 but left Article 50 unchanged (last verified July 2026).
  • Anthropic and OpenAI API data-use and retention documentation (last verified July 2026).
  • Vite and Next.js documentation on environment variables exposed to client code via the VITE_ and NEXT_PUBLIC_ prefixes (last verified November 2026).
  • GitGuardian, The State of Secrets Sprawl, on leaked credentials found and used in public repositories.
  • Supabase documentation on API keys, for the publishable and secret keys, the sb_secret_ prefix, and the secret key bypassing Row Level Security, and on cost control, for the Spend Cap and the Free Plan (last verified November 2026).
  • Stripe documentation on API keys, for what a secret key can do, on webhooks, for the signing secret, and its account checklist, for email notices about successful payments and disputes (last verified November 2026).
  • Vercel's Terms of Service and Fair Use Guidelines, on the Hobby plan being for personal, non-commercial use, and its documentation on Spend Management, for budgets, email notices, and pausing a project (last verified November 2026).