agentleFS
Rikinshah787Rikinshah787/agent-skills-production-skills/skills/supabase/SKILL.md

supabase

Skill2 starsChanged 4 months agoMITView on GitHub

Use to add a Postgres database, auth, storage, or realtime to an app with the Supabase client — and to lock it down with Row Level Security.

  • Reads credentials
  • Installs packages

32 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use firebase, tailwind and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • xfstudioSkill

    firebase

    Firebase gives you a complete backend in minutes - auth, database, storage, functions, hosting. But the ease of setup hides real complexity. Security rules are your last line of defense, and they're often wrong. Firestore queries are limited, and you learn this after you've designed your data model. This skill covers Firebase Authentication, Firestore, Realtime Database, Cloud Functions, Cloud Storage, and Firebase Hosting. Key insight: Firebase is optimized for read-heavy, denormalized data. I

    Also in 3 projects that use this

  • nth5693Skill

    tailwind

    Also in 4 projects that use this

  • NVIDIASkill

    testing

    Run Python and Rust tests for physicsnemo-curator using uv + pytest with coverage reporting via pytest-cov, and cargo-nextest for Rust tests. Includes benchmark workflows with pytest-benchmark and criterion.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 29 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use when: you need a database plus auth/storage/realtime with minimal backend code.

    line 21
  2. Distinctive:

    Use when: you want a real Postgres you can also hit with SQL, Prisma, or Drizzle.

    line 22
  3. Distinctive:

    Don't use for: pure edge KV/caching (use Redis) or when you need a self-managed DB.

    line 23

“Common” is measured: kept by at least 6 in 10 of the 29 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Supabase — Skillship

Open-source Firebase alternative: hosted Postgres + Auth + Storage + Realtime, queried through auto-generated REST/JS APIs and secured with Postgres Row Level Security (RLS).

🧭 When to use this skill

  • Use when: you need a database plus auth/storage/realtime with minimal backend code.
  • Use when: you want a real Postgres you can also hit with SQL, Prisma, or Drizzle.
  • Don't use for: pure edge KV/caching (use Redis) or when you need a self-managed DB.

⚡ Quickstart

1. Install

npm install @supabase/supabase-js
# For Next.js / SSR cookie-based auth also install:
npm install @supabase/ssr

2. Configure env (from Project → Connect)

# .env.local — the publishable/anon key is safe for the browser; the service_role key is NOT.
NEXT_PUBLIC_SUPABASE_URL=https://<project-ref>.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=<publishable-anon-key>
SUPABASE_SERVICE_ROLE_KEY=<service-role-key>   # server-only, bypasses RLS — never expose

3. Minimal working example

import { createClient } from "@supabase/supabase-js";

const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL!,
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
);

const { data, error } = await supabase.from("instruments").select();

🧩 Common recipes

Recipe: CRUD queries

// SELECT with filter (always filter, even though RLS also applies)
const { data } = await supabase.from("todos").select("*").eq("user_id", userId);

// INSERT
const { data, error } = await supabase.from("todos").insert({ title: "Ship it" }).select();

// UPDATE
await supabase.from("todos").update({ done: true }).eq("id", 42);

// DELETE
await supabase.from("todos").delete().eq("id", 42);

Recipe: Auth (email + password)

await supabase.auth.signUp({ email, password });
await supabase.auth.signInWithPassword({ email, password });
const { data: { user } } = await supabase.auth.getUser();
await supabase.auth.signOut();
// OAuth: await supabase.auth.signInWithOAuth({ provider: "github" });

Recipe: Server client for Next.js (SSR, cookie-based)

// lib/supabase/server.ts
import { createServerClient } from "@supabase/ssr";
import { cookies } from "next/headers";

export async function createClient() {
  const cookieStore = await cookies();
  return createServerClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL!,
    process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
    {
      cookies: {
        getAll: () => cookieStore.getAll(),
        setAll: (list) => list.forEach(({ name, value, options }) =>
          cookieStore.set(name, value, options)),
      },
    }
  );
}

Recipe: Storage upload

await supabase.storage.from("avatars").upload(`${userId}/pic.png`, file, { upsert: true });
const { data } = supabase.storage.from("avatars").getPublicUrl(`${userId}/pic.png`);

Recipe: Row Level Security (the part people skip — don't)

-- Enable RLS on EVERY table in the public schema
alter table todos enable row level security;

-- Users can only read their own rows
create policy "read own todos"
on todos for select
to authenticated
using ( (select auth.uid()) = user_id );

-- Users can only insert rows they own
create policy "insert own todos"
on todos for insert
to authenticated
with check ( (select auth.uid()) = user_id );

Wrap auth.uid() in (select ...) so Postgres caches it per-statement (huge RLS perf win). UPDATE needs both using and with check, and requires a matching SELECT policy to work.

🚀 Ship to production

  • RLS enabled on every table in exposed schemas (public). No RLS = public data.
  • service_role key lives only in server env; never shipped to the browser/bundle.
  • Policies use to authenticated / to anon so they short-circuit for the wrong role.
  • Indexes added on columns used in policies (e.g. user_id).
  • Auth redirect URLs / site URL configured for your production domain.
  • Don't trust user_metadata for authorization — it's user-editable; use app_metadata.

🔐 Security & secrets

  • anon/publishable key: safe in the browser only because RLS gates access. Without policies, an enabled-RLS table returns nothing and a no-RLS table is fully exposed.
  • service_role key: bypasses RLS. Server-side admin tasks only. Treat like a root password.
  • JWTs aren't always fresh — revoking a role in app_metadata won't apply until the token refreshes.

🐛 Common errors & fixes

SymptomLikely causeFix
Query returns [] for logged-in userRLS enabled but no SELECT policy, or auth.uid() is nullAdd a policy; ensure the request carries the user's token
new row violates row-level security policyINSERT with check failsMake inserted user_id equal auth.uid()
UPDATE silently affects 0 rowsMissing SELECT policy alongside UPDATEAdd a SELECT policy for the same rows
Data publicly readableRLS not enabled on the tablealter table X enable row level security;

📚 Sources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.