---
name: supabase-edge-functions
description: Write, deploy and troubleshoot Supabase Edge Functions, including secrets, CORS, auth checks and logs, with deploys only after approval. Use when the user asks to create, update, deploy or debug a Supabase Edge Function or webhook handler.
---

# Supabase Edge Functions

## Steps

1. See what exists with `list_edge_functions`, and read a function's code with `get_edge_function`.
2. For a new function or a change, write TypeScript for the Deno runtime:
   - handle CORS preflight (`OPTIONS`) when browsers call it;
   - verify the caller, either a Supabase JWT from the Authorization header or a webhook signature, before doing work;
   - read config from `Deno.env.get(...)`, never hard-coded.
   Check current patterns with `search_docs`.
3. Secrets: list the environment variables the function needs. Set them with `create_edge_function_secret` only after the user approves each name. Never echo secret values back.
4. Show the full code and the target project. After the user's yes, deploy with `deploy_edge_function`.
5. Verify by calling the function, or asking the user to, then read `get_logs` for the edge function service and fix any errors with another approved deploy.

## Report

The function name and URL, secrets set (names only), and how it was verified.
