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

Rules that prevent almost all 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

Read next

API keys and secrets for vibecoders: where they go, and how not to leak them – Shipyard