---
name: pre-launch-secrets-sweep
description: Checks a web app for secret keys that would ship to the browser or to git, before it goes live. Use when the user asks whether their keys are safe, whether anything secret is exposed or leaked, whether a .env file is a problem, or wants a secrets check before launching, deploying or making a repository public. Knows which keys are meant to be public (Supabase anon and publishable keys, Firebase web keys, Stripe publishable keys) and does not flag them.
allowed-tools: Read Grep Glob
license: MIT
---

# Pre-launch secrets sweep

Find secrets that would reach a visitor's browser or a git repository. Report them in plain language. Change nothing.

## Rules

- **Read only.** Use Read, Grep and Glob. Do not edit, create, move or delete anything, and do not run commands. If the user wants a fix applied, finish the report first and let them ask.
- **Never print a whole secret.** Show the first 6 characters, then `…`, then the last 4, for example `sk-ant…9f2c`. This applies everywhere in your reply, including quoted lines of code.
- **Do not flag keys that are meant to be public.** Listing them as problems teaches the user to ignore the report. Put them under "Meant to be public" instead.
- **Two lists of things that are not problems, never mixed.** "Meant to be public" holds only keys and values designed for the browser. "Kept private correctly" holds secret keys and secret files that are handled the right way. A secret key, or a file that holds one, never goes under "Meant to be public". Anything reported under Problems goes in neither list.
- Do not guess. If you could not check something, say so under "Not checked".

## Step 1: Work out what runs where

A secret is only a problem in two places: code the browser downloads, and files git keeps.

- **Browser code**: `src/`, `app/`, `pages/`, `components/`, `public/`, `static/`, and build output (`dist/`, `build/`, `out/`, `.next/static/`, `.output/public/`).
- **Server code** (a secret read from the environment here is fine): `supabase/functions/`, `api/`, `server/`, `functions/`, `netlify/functions/`, files named `*.server.*`, Next.js route handlers (`app/**/route.ts`), `pages/api/`, and files starting with `"use server"`. In Next.js, a file in `app/` without `"use client"` runs on the server, but anything it imports into a client component still ships.
- A hard-coded secret is a problem **anywhere**, server code included, because the file goes to git.

## Step 2: Look in the places search tools skip

Search tools can skip files that `.gitignore` hides, and those are exactly the files that matter here. So ask for them by name:

1. Glob for `.env`, `.env.*`, `**/.env`, `**/.env.*`. Read each one you find. If Glob finds none, still try to Read `.env`, `.env.local` and `.env.production` at the project root.
2. Glob for build output: `dist/**/*.js`, `build/**/*.js`, `out/**/*.js`, `.next/static/**/*.js`, `.output/public/**/*.js`. Grep each folder that exists by passing it as the `path`, using the patterns in step 3. Built files are one very long line, so report the file and the masked key, and say the line number is not useful.
3. Read `.gitignore`.

## Step 3: Search for secrets

Grep the whole project, then the build folders by path, for these.

| What | Looks like |
| --- | --- |
| Anthropic key | `sk-ant-` |
| OpenAI key | `sk-proj-`, or `sk-` followed by 20 or more letters and digits |
| Stripe secret or restricted key | `sk_live_`, `sk_test_`, `rk_live_`, `rk_test_` |
| Stripe webhook secret | `whsec_` |
| Supabase secret key (new style) | `sb_secret_` |
| Supabase service_role key (old style) | a long `eyJ…` token, see below |
| GitHub token | `ghp_`, `github_pat_` |
| AWS access key | `AKIA` followed by 16 capitals and digits |
| Slack token | `xoxb-`, `xoxp-` |
| Resend, SendGrid, Groq, Replicate | `re_`, `SG.`, `gsk_`, `r8_` |
| Private key file | `-----BEGIN` … `PRIVATE KEY-----` |
| Database address with a password | `postgres://` or `postgresql://` with `user:password@` |

Also grep for the names, not just the values: `service_role`, `SERVICE_ROLE`, `SECRET`, `PRIVATE_KEY`, `PASSWORD`, `dangerouslyAllowBrowser`.

**Telling the two old-style Supabase keys apart.** Both start with `eyJ` and look the same. The middle part (between the two dots) says which it is. If it contains any of these, it is the **service_role** key, which bypasses every access rule:

`c2VydmljZV9yb2xl` · `NlcnZpY2Vfcm9sZ` · `zZXJ2aWNlX3JvbG`

If it contains one of these instead, it is the **anon** key, which is safe: `ImFub24i` · `Jhbm9uI` · `iYW5vbiI`. If you find neither, say you could not tell and ask the user to check the key's label in the Supabase dashboard.

**Public-prefixed variables.** Anything named `VITE_…`, `NEXT_PUBLIC_…`, `PUBLIC_…`, `REACT_APP_…`, `EXPO_PUBLIC_…` or `NUXT_PUBLIC_…` is copied into the browser bundle at build time. Flag one when its value matches the table above, or when its name contains `SECRET`, `PRIVATE`, `SERVICE_ROLE`, `PASSWORD` or names an AI or payment provider's API key (`VITE_OPENAI_API_KEY`). The prefix is the problem: the fix is a server-side call, not a rename alone.

## Step 4: Check the .env files

For each `.env` file that holds a real secret:

- If `.gitignore` does not cover it, it is a problem: it will be committed, or already has been.
- If `.gitignore` covers it and its secrets have no public prefix, it is fine. Mention it in one line under "Kept private correctly" as a server-only file that git ignores.
- You cannot see git history with these tools. Say so under "Not checked" and give the user this command: `git log --all --oneline -- .env`. Any output means the file was committed at some point and its keys need replacing.

A `.env` file that `.gitignore` covers goes under "Kept private correctly" even if it holds only public values, never under "Meant to be public". The public values inside it are listed under "Meant to be public" one by one.

`.env.example`, `.env.sample` and `.env.template` with placeholder values (`your-key-here`, `xxx`, empty) are fine and should be committed. They hold no secret, so mention them under "Meant to be public". Flag them only if they hold a real-looking key.

## What is meant to be public

Do not report these as problems. List every one you found under "Meant to be public", one line each, so the user can see it was looked at and cleared. Only keys and values built for the browser belong here (plus placeholder templates such as `.env.example`). Nothing secret goes in this list.

- **Supabase anon key** (old `eyJ…` style with the anon marker) and **publishable key** (`sb_publishable_…`). They are designed for the browser. What protects the data is row-level security, which this skill does not check.
- **Supabase project URL** (`https://….supabase.co`).
- **Firebase web config**, including `apiKey: "AIza…"`. It identifies the project; Firebase security rules protect the data.
- **Stripe publishable key** (`pk_live_…`, `pk_test_…`).
- Other keys built for the browser: Clerk publishable (`pk_…`), PostHog (`phc_…`), Sentry DSN, Google Maps keys, Mapbox public tokens (`pk.`), Algolia search-only keys.

One exception: an `AIza…` key used for **Gemini** (sent to `generativelanguage.googleapis.com`, or named `GEMINI` or `GOOGLE_AI`) is a paid API key and is a problem in browser code. An `AIza…` key inside a Firebase config object is not.

## What is kept private correctly

Secrets that are handled the right way are not problems either. List each one you found under "Kept private correctly", one line each, so the user can see where their secrets are and that they were checked:

- A `.env` (or `.env.local`, `.env.production` and similar) that `.gitignore` covers and whose secrets have no public prefix.
- A secret key read from the environment in server code (for example `Deno.env.get("SUPABASE_SERVICE_ROLE_KEY")` in `supabase/functions/`, or `process.env.STRIPE_SECRET_KEY` in an API route), with no value written in the file, and not found in the build output.

Only list a secret here if it passes every check in this skill. A secret in a file git does not ignore, or one that reaches the build, is a problem and goes under Problems only.

## Output

Reply with this and nothing before it. Use plain words: the reader may not be an engineer.

```
Secrets sweep: <N> problem(s) found

Checked: <one line: which folders, how many .env files, which build folders>

## Problems

1. <What it is, in plain words> — `<file>:<line>`
   Found: `<masked key>`
   Why it matters: <one sentence on what someone could do with it>
   What to do: <numbered or short steps>

## Meant to be public (not problems)

- `<file>:<line>` <a key or value built for the browser, and why it is fine, one line>

## Kept private correctly (not problems)

- `<file>:<line>` <a secret key or secret file, and how it is kept out of the browser and git, one line>

## Not checked

- <what these tools could not see>
```

- Order problems by damage: keys that unlock the whole database or move money first, then keys that cost money, then the rest.
- One problem per place it appears. If the same key is in source and in the build output, list both, because both need clearing.
- Every "What to do" for a leaked key starts with **replace the key** in the provider's dashboard (rotate it). Deleting the line does not make a leaked key secret again. Then say where the key should live instead: a server-side function (a Supabase Edge Function, an API route) that reads it from the environment, with the browser calling that function.
- For build output: fix the source, rebuild, and check the new build is clean.
- If there are no problems, write `Secrets sweep: 0 problems found`, write "None." under Problems, and still fill in "Meant to be public", "Kept private correctly" and "Not checked". If a "not problems" list has nothing in it, write "None." under it. Do not invent a problem to have something to say.

<!--
MIT License

Copyright (c) 2026 PT Maverick Rintis Karya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
