# Fuego: make this app secure

You are an AI coding agent. The person you're helping wants their app checked for the security holes hackers look for, and fixed. Fuego (https://fuegoredteam.com) does the checking from the outside and tells you exactly what to fix. Follow these steps in order. Keep the person informed in plain, friendly language, without jargon.

Fuego only runs read-only checks, and only on sites whose owner has proven they control them. Never try to check a site the person doesn't own.

## Option A: you can run shell commands (Claude Code, Cursor, Windsurf, Codex...)

Use the REST API at `https://fuegoredteam.com/api/v1`. Every response is JSON with a `next` field that tells you what to do next. Follow it.

1. **Ask** the person for their email and their app's live address (for example `myapp.com` or `myapp.lovable.app`). If the code is a project you can see, suggest the address from its config.

2. **Start.** This emails them a 6-digit code:
   ```sh
   curl -s https://fuegoredteam.com/api/v1/start -H 'content-type: application/json' \
     -d '{"email":"PERSON@EMAIL","site":"myapp.com"}'
   ```

3. **Ask for the code** from their email (it may land in spam), then trade it for a token:
   ```sh
   curl -s https://fuegoredteam.com/api/v1/token -H 'content-type: application/json' \
     -d '{"email":"PERSON@EMAIL","code":"123456"}'
   ```
   Keep the `token` private. Don't print it back to the person, commit it, or write it into the project.

4. **Get the ownership tag:**
   ```sh
   curl -s https://fuegoredteam.com/api/v1/sites/myapp.com -H "authorization: Bearer $TOKEN"
   ```
   Add `ownership.meta_tag` inside the `<head>` of the site's homepage: `index.html` for Vite/React/Lovable/Bolt, or `metadata.other` in the root layout for Next.js (`other: { "fuego-red-team": "CODE" }`). Then deploy or publish the site. If you can't deploy, ask the person to.

5. **Verify** once the tag is live. The first check starts automatically:
   ```sh
   curl -s -X POST https://fuegoredteam.com/api/v1/sites/myapp.com/verify -H "authorization: Bearer $TOKEN"
   ```
   Poll `GET /api/v1/sites/myapp.com` every 10 to 15 seconds until `state` is `checked`. If verification fails, read `last_verification_error`. Usually the deploy hasn't finished yet.

6. **Fix.** Each item in `findings` has a `priority`, a plain explanation, a `fix`, and an `ai_fix_prompt` written for you. Work in priority order ("Fix today" first). Make each change in the codebase, keep existing features working, and explain to the person what you changed. Some things only the person can do, like rotating a leaked key in a provider's dashboard. Tell them clearly, step by step.

7. **Confirm.** After deploying the fixes, run a fresh check and read the results again:
   ```sh
   curl -s -X POST https://fuegoredteam.com/api/v1/sites/myapp.com/check -H "authorization: Bearer $TOKEN"
   ```
   Free sites can re-check once a day. When everything passes, tell the person they're all good. They can turn on nightly monitoring at the `url` in the response.

## Option B: you support MCP (Claude, Cursor, VS Code...)

Connect the remote MCP server at `https://fuegoredteam.com/api/mcp` (Streamable HTTP, no OAuth). It exposes these tools: `start`, `sign_in`, `site_status`, `verify`, `check`, `add_site` and `list_sites`. They follow the same steps as above. In Claude Code:

```sh
claude mcp add --transport http fuego https://fuegoredteam.com/api/mcp
```

## Option C: you can't run commands or call tools (Lovable, Bolt, v0 chat...)

Ask the person to sign up at https://fuegoredteam.com with their app's address. Fuego gives them a meta tag and a prompt to paste back to you. Add the tag to the `<head>` of `index.html` and publish. When their report is ready, they'll paste each fix prompt to you.

## While you wait, check the basics yourself

These are the most common holes in AI-built apps. Fix any you find:

- **Secret keys in frontend code.** Anything in `VITE_*`, `NEXT_PUBLIC_*` or `PUBLIC_*` variables, or in client components, ships to every visitor. Move calls that need secret keys (OpenAI, Anthropic, Stripe secret, Supabase `service_role`/`sb_secret_`) into a server function. Tell the person to rotate any key that was ever public.
- **Supabase tables without Row Level Security.** Enable RLS on every table, and add policies so users only read and write their own rows (`user_id = auth.uid()`).
- **Open storage.** User uploads belong in private buckets served with signed URLs.
- **Firebase rules in test mode.** Replace `allow read, write: if true` with rules that require sign-in and ownership.
- **`.env` files or `.git` deployed publicly.** Make sure neither is in the build output.
