By the end of this lesson you will keep every secret key out of your code, your GitHub repo and the browser, put a spending limit on each key, and know exactly what to do if one leaks.
You need: a project with Git set up (previous lesson) and your coding agent · Time: 7 minutes
A secret is any text that lets someone act as you or spend your money. Think of it like your UPI PIN: whoever has it can pay from your account.
- API keys, like your AllModelAPI key, which pays for every AI request.
- Secret or service keys of your database (for example the Supabase secret key).
- Payment keys, like the Razorpay Key Secret or Stripe secret key.
- Passwords and connection strings for databases, email services and admin accounts.
Leaks are common, and AI makes them more common. GitGuardian found 28.65 million new secrets pushed to public GitHub in 2025, and commits co-written with Claude Code leaked secrets at about 3.2%, against a 1.5% baseline for all public commits. 64% of valid secrets found in 2022 were still working four years later, because nobody revoked them. (GitGuardian 2026 report, press release)
Why?The agent is trying to make the code work quickly. Writing the key straight into the code works, so it sometimes does that. You are the one who has to insist on the safe place.
Log in free to read the rest of this lesson
Every lesson is free. A free account unlocks all of them and saves your progress.
Still to come in this lesson:
- Keep secrets in .env, and .env out of Git
- Anything in the browser is public
- Which keys may be public, and which never
- Put a spending limit on every key
- If a key leaks, act in this order
- Recap