AGENT SKILL

supabase

Use for any MDE request clearly involving Supabase, including Database, Auth, RLS, migrations, RPC/functions, Realtime, Storage, pgvector, Edge Functions, logs, live database behavior, Postgres schema/SQL/indexes/locking/performance/tenant isolation, and Supabase-specific bugs/errors/failures. Known Supabase/RLS failures stay with this domain owner rather than generic systematic-debugging.

License 许可
MIT
所属仓库
amoai-tech/mdeai
最近更新
2026-11-13
Stars
★ 2
Forks
1

01 前言 Front Matter

name
supabase
metadata
{ "mde-version": "2.0.1", "verified-package": "@supabase/supabase-js ^2.106.1" }
description
Use for any MDE request clearly involving Supabase, including Database, Auth, RLS, migrations, RPC/functions, Realtime, Storage, pgvector, Edge Functions, logs, live database behavior, Postgres schema/SQL/indexes/locking/performance/tenant isolation, and Supabase-specific bugs/errors/failures. Known Supabase/RLS failures stay with this domain owner rather than generic systematic-debugging.

02 资源文件 65

03 SKILL.md 正文

Supabase — official upstream + MDE overlay

Source order

  1. Inspect current MDE schema, migrations, Supabase clients, generated types, and live read-only state when authorized.
  2. Read references/official/supabase/SKILL.md for current platform/security/CLI guidance.
  3. For any Postgres change, also read references/official/supabase-postgres-best-practices/SKILL.md and the matching rule files.
  4. Check current Supabase changelog/docs for version-sensitive behavior.
  5. Apply MDE-specific project rules and invariants below.

Do not rely on remembered Supabase CLI/API/security behavior when current official guidance can prove it.

Ownership

Own Supabase schema/migrations, RLS/Auth, database functions/RPCs, Realtime, Storage, pgvector, Edge Functions, live DB verification, and Postgres behavior. Domain skills own business rules; stripe owns payment semantics; mastra owns agent/workflow semantics.

Current MDE invariants

  • Every exposed table must have an explicit access model; RLS is the database boundary, not frontend filtering.
  • Never authorize from user-editable metadata; use trusted app metadata or relational ownership.
  • Never expose service-role/secret keys to browser code. Privileged credentials are not authorization; authenticate and authorize the actor before privileged writes.
  • Every new or changed RPC/function must classify EXECUTE access explicitly and prove direct allow/deny calls for the intended roles.
  • For exposed tables, treat table grants and RLS policies as separate gates and test both.
  • Treat SECURITY DEFINER, storage policies, exposed views, and cross-tenant access as security-critical changes.
  • UPDATE policies need both visibility and write checks; test allow and deny paths.
  • Current migration mode: imperative. supabase/config.toml has [db.migrations] schema_paths = [] and no active [experimental.pgdelta] block.
  • Create imperative migrations with supabase migration new <name> and edit the CLI-generated file. Never invent migration timestamps or filenames manually.
  • Treat declarative schema guidance as conditional/future-only until MDE intentionally adopts it. On legacy migra, schema_paths configures declarative files; on pg-delta, schema_paths is ignored and declarative changes use supabase/schemas/ with supabase db schema declarative sync.
  • For S3/S4 database work, prove tenant deny cases, replay/idempotency where relevant, and actual live/read-only state when authorized.

Workflow

  1. Classify: schema/migration, RLS/Auth, RPC/function, Realtime, Storage, Edge Function, vector/search, or performance.
  2. Load official Supabase guidance plus official Postgres rules for any SQL/schema work. For version-sensitive CLI work, run supabase --version and confirm the command/flags against --help or current docs.
  3. Load only the matching MDE reference/project rule already in this skill directory.
  4. Inspect current migration/schema conventions before editing.
  5. Make the smallest safe change; do not use privileged code to bypass an unexplained permission failure.
  6. Verify positive and negative cases, then run advisors/tests when the environment supports them.

MDE references

Preserve the existing MDE topic files and references/project-rules/ for repository-specific conventions. Treat historical inventories or counts as stale unless current code/live state confirms them.

Verification

For auth/RLS/storage/functions: prove authorized success and unauthorized denial. For migrations: prove ordering, replay safety, and schema state. For performance: use evidence such as EXPLAIN/advisors rather than intuition. S3/S4 changes require independent code-review and task-verifier.

References

upstream.yaml is the canonical upstream provenance record. The vendored official files it identifies are pinned and read-only:

  • references/official/supabase/SKILL.md
  • references/official/supabase-postgres-best-practices/SKILL.md

MDE project rules — read the matching file before changing that area:

  • references/project-rules/supabase-migrations.md — migration file shape and ordering
  • references/project-rules/supabase-rls-policies.md — policy authoring
  • references/project-rules/supabase-declarative-schema.md — conditional/future declarative-schema workflow
  • references/project-rules/supabase-database-functions.md — function and RPC rules
  • references/project-rules/supabase-edge-functions.md — edge function conventions
  • references/project-rules/supabase-realtime.md — realtime publication and channels
  • references/project-rules/supabase-patterns.md — recurring MDE patterns
  • references/project-rules/supabase-sql-style.md — SQL formatting

references/postgres/ (34 files) — read for query and connection problems: conn-pooling.md, conn-limits.md, conn-idle-timeout.md, conn-prepared-statements.md, advanced-jsonb-indexing.md, advanced-full-text-search.md, data-batch-inserts.md.

Realtime and security detail: references/realtime/rls-policy-cookbook.md, references/realtime/migration-from-postgres-changes.md, references/docs/rls-row-level-security.md, references/docs/testing.md.

Storage: references/storage/rls-policies.md, references/storage/api-cheatsheet.md.

Maps of the current database: references/tables-overview.md, references/edge-functions-inventory.md, references/ai-edge-functions.md.

04 同仓库更多 Skills