set-up-supabase
Skill7 starsChanged 16 days agoMITView on GitHub
Use when a project starts using Supabase or its supabase/ folder is missing or half-set-up — wires the CLI local stack, migrations as the only schema path, generated types, per-environment config, and one client seam per context so the secret key never reaches a bundle.
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- VelimirMueller/ai-development-skillsword for word, first seen Oct 25, 2026
Other versions1 project uses a version of this.
Word for word · 1
- VelimirMueller/ai-development-skills★ 7100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository156 other files it gives its agents.
- skills/swift/swiftui-design-principles/AGENTS.mdAGENTS.md
- skills/swift/ios-code-audit/CLAUDE.mdCLAUDE.md
- skills/swift/swift-focusengine-pro/llms.txtllms.txt
- build-llm-seamSkill
- build-mcp-serverSkill
- build-rag-pipelineSkill
- secure-llm-featuresSkill
- set-up-llm-evalsSkill
- build-nextjs-backendSkill
- build-supabase-edge-functionSkill
- configure-backend-testsSkill
- design-http-apiSkill
- harden-backendSkill
- scaffold-fastapi-serviceSkill
- scaffold-go-serviceSkill
- scaffold-hono-serviceSkill
- secure-supabase-rlsSkill
- set-up-backend-authSkill
- set-up-background-jobsSkill
- set-up-databaseSkill
- set-up-nextjs-supabase-authSkill
- set-up-observabilitySkill
- build-cliSkill
- release-cliSkill
- set-up-dev-toolchainSkill
- audit-securitySkill
- audit-toolchainSkill
- extend-skillsetSkill
- promote-releaseSkill
- set-up-stack-profileSkill
- write-commit-messagesSkill
- write-pull-requestsSkill
- analyze-complexitySkill
- apply-algorithmsSkill
- apply-design-patternsSkill
- apply-design-principlesSkill
- apply-solidSkill
- choose-data-structureSkill
- debug-systematicallySkill
- enforce-dependency-ruleSkill
- refactor-safelySkill
- slice-and-estimateSkill
- write-clean-testsSkill
- write-readable-codeSkill
- clean-frontend-scaffoldingSkill
- configure-accessibilitySkill
- configure-analyticsSkill
- configure-ciSkill
- configure-error-trackingSkill
- configure-lintingSkill
- configure-test-stackSkill
- configure-typescriptSkill
- create-moduleSkill
- optimize-performanceSkill
- scaffold-frontend-projectSkill
- set-up-authSkill
- set-up-design-systemSkill
- set-up-document-headSkill
- set-up-error-boundariesSkill
- set-up-feature-flagsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 0 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Read .claude/stack-profile.md if present (backend.track, database.orm, hosting, package_manager, frontend.meta).
- Very specific: line 40
If database.orm: drizzle: Supabase migrations stay the only DDL path (RLS, grants, triggers and functions are SQL).
- Very specific: line 59
Read the generated file before committing: extensions you enabled yourself can appear as DROP EXTENSION.
- Very specific: line 129
Add a "db:types" script (or a just/mise task per task_runner) and commit the output.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Set Up Supabase
1. Audit current state
Read .claude/stack-profile.md if present (backend.track, database.orm, hosting, package_manager, frontend.meta). If absent, detect; ask one question only when the answer changes the output (for example Drizzle owning DDL, see step 3).
ls supabase/config.toml supabase/migrations supabase/seed.sql supabase/tests 2>/dev/null
grep -n "pgdelta\|schema_paths" supabase/config.toml 2>/dev/null # diff engine in use
grep -rn "createClient\|createBrowserClient\|createServerClient" src app lib --include=*.ts --include=*.tsx 2>/dev/null | head -20
grep -rn "service_role\|SERVICE_ROLE\|sb_secret_\|SUPABASE_SECRET" --include=*.ts --include=*.tsx --include=.env* . 2>/dev/null | grep -v node_modules | head
git ls-files | grep -E "\.env($|\.)" | grep -v example # committed env files = finding
ls .github/workflows 2>/dev/null; cat package.json 2>/dev/null | grep -n "supabase"Findings to record: secret/service_role key outside a server-only file, anon/service_role legacy names, a Dashboard-edited remote with no migrations, a client created inline in a component.
2. Decide what to do
- No
supabase/→ full setup (steps 4–8). supabase/exists, no migrations but a live remote → baseline pull first (step 4, "existing project").- Clients scattered or secret key in a client-reachable file → step 7 plus rotate the key if it was ever committed (security-baseline.md, rule 1).
- Everything present and
supabase db resetpasses → report "already in place" and stop.
3. Detect track and pick the schema workflow
| Signal | Track |
frontend.meta: next or next in package.json | Next.js: cookie clients come from set-up-nextjs-supabase-auth |
backend.track: hono / Node server | server client with the publishable key plus the caller's JWT |
| Vite SPA only | browser client only; admin work goes to an Edge Function (build-supabase-edge-function) |
Schema workflow: plain migrations (supabase migration new) are the default. Declarative schemas (supabase/schemas/ + db schema declarative sync) are opt-in: they need the pg-delta engine, which is pre-1.0 and still under [experimental.pgdelta]. Both end in files under supabase/migrations/, and only those reach a remote. Reasons and the switch: supabase-patterns.md.
If database.orm: drizzle: Supabase migrations stay the only DDL path (RLS, grants, triggers and functions are SQL). Drizzle reads the schema; do not run drizzle-kit push against a remote.
4. Install only what's missing
pnpm add -D supabase # CLI as a project dependency, pinned by the lockfile
pnpm add @supabase/supabase-js # + @supabase/ssr on Next/SSR (set-up-nextjs-supabase-auth)
pnpm supabase init # only if supabase/config.toml is missingDocker (or a compatible runtime) must run for supabase start. Use the package runner form (pnpm supabase …) everywhere below. Versions: stack-versions.md.
Existing remote project (tables made in the Dashboard):
pnpm supabase login && pnpm supabase link --project-ref <project-ref>
pnpm supabase db pull # writes supabase/migrations/<ts>_remote_schema.sql; accept "mark as applied"Read the generated file before committing: extensions you enabled yourself can appear as DROP EXTENSION.
5. Generate the seams: folder, first migration, seed
supabase/
config.toml # committed; secrets only via env("NAME")
migrations/ # committed; applied in order; never edited once pushed
seed.sql # committed; fake data only, never a production dump
tests/ # pgTAP, see secure-supabase-rls
functions/ # see build-supabase-edge-functionFirst migration closes the default-grant hole before any table exists:
pnpm supabase migration new baseline_privileges < /dev/null # closed stdin: the command waits for input in a non-TTY shellFill it with the alter default privileges block from rls-patterns.md ("Rule: no automatic grants"). In config.toml keep [api] schemas = ["public"] unless you have a dedicated API schema, and set [auth] site_url and additional_redirect_urls per environment.
.gitignore: .env* (except .env.example), supabase/.temp, supabase/.branches, supabase/functions/.env.
6. Environment per environment
| Var | Where | Exposure |
NEXT_PUBLIC_SUPABASE_URL / VITE_SUPABASE_URL / SUPABASE_URL | all | public |
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY / VITE_… / SUPABASE_PUBLISHABLE_KEY | all | public (sb_publishable_…) |
SUPABASE_SECRET_KEY (sb_secret_…) | server runtime only | never a public prefix |
One Supabase project per environment (local stack, staging, production); keys differ per project. Never add SUPABASE_ANON_KEY / SUPABASE_SERVICE_ROLE_KEY to new code: those are the legacy keys. Validate at startup with the project's env seam (validate-env for Vite, nextjs-backend-patterns.md for Next). Layout and naming: config.md.
7. Client seams — one module per context
src/libs/supabase/ (Next/React) or the equivalent seam folder:
// browser.ts — public key, runs in the browser; Realtime and non-auth queries only, never auth
import { createBrowserClient } from '@supabase/ssr'; // Vite SPA without SSR: createClient from supabase-js
import type { Database } from './database.types';
export const createClient = () =>
createBrowserClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
);On Next.js the session cookie is httpOnly (set-up-nextjs-supabase-auth), so this client cannot read the session and never signs anyone in. Auth is server-side only; the browser client exists for Realtime and non-auth queries. Realtime needs a token client-side — see the pattern in that skill.
// admin.ts — secret key, bypasses RLS, server only
import 'server-only';
import { createClient } from '@supabase/supabase-js';
import type { Database } from './database.types';
export const supabaseAdmin = createClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.SUPABASE_SECRET_KEY!,
{ auth: { persistSession: false, autoRefreshToken: false, detectSessionInUrl: false } },
);The per-request server client (cookies) is in set-up-nextjs-supabase-auth. Call supabaseAdmin only from code that already authorized the caller: it bypasses RLS. Types:
pnpm supabase gen types --lang typescript --local > src/libs/supabase/database.types.tsAdd a "db:types" script (or a just/mise task per task_runner) and commit the output.
8. Wire CI and deploy
- PR job:
supabase start,supabase db reset(proves the chain from zero),supabase test db,supabase db advisors --local --fail-on error, regenerate types and fail ongit diff. - Deploy: either Supabase's GitHub integration (preview branch per PR, migrations applied on merge) or a GitHub Actions job running
supabase link+supabase db push. Pick one. Workflow files and token scopes: supabase-patterns.md. - Remote changes only through merged migrations.
supabase db push --dry-runbefore the first push.
9. Verify
typecheck is tsc --noEmit in a Next.js app (one tsconfig); add "typecheck": "tsc --noEmit" to package.json if it is missing.
pnpm supabase start && pnpm supabase db reset # migrations + seed apply cleanly
pnpm supabase test db # pgTAP green (or "no tests" before secure-supabase-rls)
pnpm supabase db advisors --local --type security # no ERROR-level findings
pnpm typecheck # Database types resolve
pnpm build && ! grep -rEl "sb_secret_|SUPABASE_SECRET_KEY" .next/static dist 2>/dev/null # nothing in client outputExpected: every command exits 0 and the last grep prints nothing.
References
- supabase-patterns.md — migrations vs declarative, branching, keys, types, CI.
- ../secure-supabase-rls/SKILL.md — the next step for every new table.
- ../_shared/stack-versions.md, ../_shared/service-layout.md, ../_shared/config.md.
- ../../core/_shared/stack-profile.md, ../../core/_shared/security-baseline.md.
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
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.

