Blog · 16 November 2026 · 7 minute read
API keys and secrets for vibecoders: where they go, and how not to leak them
What an environment variable is, where each key belongs, the five ways keys leak when you build with AI, and what to do the minute one does.
Why this matters more when an AI writes your code
When you write code by hand, you know where you typed the key. When an AI writes it, the key can end up wherever the model found it convenient: in a config file, in an example, in a comment, in a log line that prints the whole request. The code works, so you do not look. Then you push it.
A leaked payment key or cloud key is not an embarrassment, it is a bill. Automated scanners watch public code for keys and use them within minutes.
What a secret is
A secret is anything that lets a program act as you: an API key, a token, a database password, a webhook signing secret. If someone else having it would let them spend your money, read your data or send mail in your name, it is a secret.
Some values look similar but are public by design, such as a publishable key meant for the browser or an analytics ID. Your provider's documentation says which is which. When in doubt, treat it as a secret.
Where secrets belong
A secret belongs in an environment variable: a named value that lives on the machine running your app, outside the code. Your code reads it by name, for example the variable STRIPE_SECRET_KEY, and never contains the value itself.
In production the variables live in your host's settings. On your own computer they live in a local file that is listed in .gitignore so it is never committed, or better, in your operating system's keychain.
The five ways keys leak
- Committed to the repository, often in a config file or an example the AI generated.
- Pasted into a chat with an AI tool to "help it debug". Assume anything you paste is stored.
- Printed in logs, when code logs a whole request or error object that includes headers.
- Shown in a screenshot or screen recording. Error messages often echo the key you just pasted.
- Put in a variable that is sent to the browser. In many frameworks a prefix on the variable name makes it public.
Rules that prevent almost all of it
- Never paste a secret into a chat. Give your coding tool the variable names, not the values.
- Create a separate key for each tool and each product, so revoking one breaks nothing else.
- Give each key the narrowest permissions that work. A key that can only send email cannot delete your database.
- Add your local secrets file to .gitignore before the first commit, not after.
- Turn on secret scanning in your code host. It catches the mistake before a stranger does.
- Before sharing a screenshot of a terminal, read every line of it.
What to do when a key leaks
Revoke it at the provider immediately and create a new one. Do not start by deleting the commit or the message: the key is already copied, and removing it from view only makes you feel better. Then check the provider's usage log for activity you did not cause, and update the new key wherever the old one was used.
Rotating a key takes two minutes when each product has its own. It takes an afternoon when one key is shared by everything, which is the best argument for separate keys.
How Shipyard handles keys
Shipyard stores your provider tokens in your operating system's keychain and uses them from there. They are not written to a plain file and not sent to our servers, and every log line passes through a filter that masks known secret values. During a launch, each new key goes straight from the provider that issued it into your host's environment variables. Only the variable names are written into your repository, so your coding tool knows what exists without seeing a value.
Launch in an hour, not a weekend
Shipyard connects your accounts once, then sets up the domain, hosting, database, email and payments for every new product.
See how it works