1
0
Fork 0
fahrPool/.claude/skills/supabase-local-dev/SKILL.md

3.3 KiB

name description
supabase-local-dev Reference for working with this project's self-hosted Supabase stack — CLI working directory, the two parallel stacks running on this machine, test admin credentials, and pgTAP fixture conventions. Use whenever running supabase CLI commands, writing/debugging pgTAP tests, or verifying RLS behavior live.

Supabase Local Dev — Reference

Run CLI commands from the repo root, never from web/

npx supabase status
npx supabase start
npx supabase db reset
npx supabase test db

All of these must run from the repository root (where supabase/ lives), not from web/. Running them from web/ fails silently or picks up the wrong project config.

Two parallel stacks — don't mix them

This machine typically runs two independent Supabase stacks at once:

  1. Local Supabase CLI dev stack (npx supabase start) — containers named supabase_*_fundament-auth-rollen, API on http://127.0.0.1:54321, Postgres on port 54322. This is the stack all automated task/review verification in this project uses.
  2. Docker-Compose "master" stack (docker compose up -d, defined in the repo's docker-compose.yaml) — containers named aushilfsfahrer-*, Kong gateway on http://localhost:8000, Postgres on port 5432. This is what the user runs to click through the live app.

Both can be running simultaneously. web/.env.local (gitignored, per-worktree) determines which one a local npm run dev talks to — check its NEXT_PUBLIC_SUPABASE_URL before assuming which stack you're hitting. Get the CLI stack's current anon key and URL with npx supabase status (repo root) rather than hardcoding a previously-seen value — it can change between resets.

Test admin account

admin@aushilfsfahrer.local / Admin123!, role admin, exists in the local CLI dev stack. Its password gets reset periodically during development (out-of-band, via the GoTrue admin API) and isn't reliably documented anywhere — if login fails, reset it yourself:

curl -s -X PUT http://127.0.0.1:54321/auth/v1/admin/users/<user-id> \
  -H "apikey: <SERVICE_ROLE_KEY from npx supabase status>" \
  -H "Authorization: Bearer <SERVICE_ROLE_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"password":"Admin123!"}'

If the user doesn't exist at all, create it via POST /auth/v1/admin/users with email_confirm: true, then set its role in public.profiles via docker exec -i supabase_db_fundament-auth-rollen psql -U postgres -d postgres.

pgTAP fixture conventions

Tests live in supabase/tests/*.sql. Standard pattern for simulating a specific user's RLS context:

insert into auth.users (id, email) values ('<uuid>', 'someone@test.local');
-- a trigger auto-creates a matching public.profiles row with role='readonly'
update public.profiles set role = 'fahrer' where id = '<uuid>';

set local role authenticated;
set local request.jwt.claims to '{"sub": "<uuid>", "role": "authenticated"}';
-- ... run assertions as this user ...
reset role;

Every test file wraps its whole body in begin; ... rollback; so fixtures never persist. Run the full suite with npx supabase test db (after npx supabase db reset to apply migrations fresh) — check the file for the current select plan(N); count before adding tests, and update it.