supabase-edge-functions

A set of coding rules for Supabase Edge Functions, which are server-side TypeScript or JavaScript functions that run on Supabase’s edge infrastructure. The rules cover imports, shared code, dependencies, and use of the Deno runtime.

In plain words
What is it for?
Use it when writing or reviewing Supabase Edge Functions, especially when choosing Web APIs, organising shared utilities, and declaring versioned external packages.
Why use it?
It keeps Edge Functions consistent and avoids common dependency and project-structure problems.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/chand1012/cursorrules/supabase-edge-functions
Clone the repo
git clone --depth 1 https://github.com/chand1012/cursorrules
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,039 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 94% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01039
Opus 5 $0.00000 $0.00519
Sonnet 5 $0.00000 $0.00208
Haiku 4.5 $0.00000 $0.00104

Measured 2d ago against content hash 25a6dd4b1f37, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

supabase-edge-functions scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

94% identical to coding-rules-for-supabase-edge-functions — 5 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

frameworks/supabase-edge-functions.mdc · 116 lines

How it starts

The opening of the file, as written. The whole thing — 116 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing Supabase Edge Functions

You're an expert in writing TypeScript and Deno JavaScript runtime. Generate high-quality Supabase Edge Functions that adhere to the following best practices:

Guidelines

  1. Try to use Web APIs and Deno’s core APIs instead of external dependencies (eg: use fetch instead of Axios, use WebSockets API instead of node-ws)
  2. If you are reusing utility methods between Edge Functions, add them to supabase/functions/_shared and import using a relative path. Do NOT have cross dependencies between Edge Functions.
  3. Do NOT use bare specifiers when importing dependecnies. If you need to use an external dependency, make sure it's prefixed with either npm: or jsr:. For example, @supabase/supabase-js should be written as npm:@supabase/supabase-js.
  4. For external imports, always define a version. For example, npm:@express should be written as npm:[email protected].
  5. For external dependencies, importing via npm: and jsr: is preferred. Minimize the use of imports from @deno.land/x , esm.sh and @unpkg.com . If you have a package from one of those CDNs, you can replace the CDN hostname with npm: specifier.
  6. You can also use Node built-in APIs. You will need to import them using node: specifier. For example, to import Node process: `import process from "node:process". Use Node APIs when you find gaps in Deno APIs.
  7. Do NOT use import { serve } from "https://deno.land/[email protected]/http/server.ts". Instead use the built-in Deno.serve.
  8. Following environment variables (ie. secrets) are pre-populated in both local and hosted Supabase environments. Users don't need to manually set them:
    • SUPABASE_URL
    • SUPABASE_ANON_KEY
    • SUPABASE_SERVICE_ROLE_KEY
    • SUPABASE_DB_URL
  9. To set other environment variables (ie. secrets) users can put them in a env file and run the supabase secrets set --env-file path/to/env-file
  10. A single Edge Function can handle multiple routes. It is recommended to use a library like Express or Hono to handle the routes as it's easier for developer to understand and maintain. Each route must be prefixed with /function-name so they are routed correctly.
  11. File write operations are ONLY permitted on /tmp directory. You can use either Deno or Node File APIs.
  12. Use EdgeRuntime.waitUntil(promise) static method to run long-running tasks in the background without blocking response to a request. Do NOT assume it is available in the request / execution context.

Read the full file on GitHub · 116 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 116 lines · 0 tokens per session scan A 25a6dd4b1f37

Subscribe to this mod's changes

supabase-edge-functions is a cursor rule published in the GitHub repository chand1012/cursorrules (13 stars, last pushed 9mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,039 tokens. A static security scan graded it A with 0 findings. It is 94% identical to coding-rules-for-supabase-edge-functions, differing in 5 lines, and is treated as a copy.