supabase-local-dev-loop
Configure Supabase local development with the CLI, Docker, and migration workflow. Use when initializing a Supabase project locally, starting the local stack, writing migrations, seeding data, or iterating on schema changes. Trigger with phrases like "supabase local dev", "supabase start", "supabase init", "supabase db reset", "supabase local setup".
Best use case
supabase-local-dev-loop is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Configure Supabase local development with the CLI, Docker, and migration workflow. Use when initializing a Supabase project locally, starting the local stack, writing migrations, seeding data, or iterating on schema changes. Trigger with phrases like "supabase local dev", "supabase start", "supabase init", "supabase db reset", "supabase local setup".
Teams using supabase-local-dev-loop should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/supabase-local-dev-loop/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How supabase-local-dev-loop Compares
| Feature / Agent | supabase-local-dev-loop | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Configure Supabase local development with the CLI, Docker, and migration workflow. Use when initializing a Supabase project locally, starting the local stack, writing migrations, seeding data, or iterating on schema changes. Trigger with phrases like "supabase local dev", "supabase start", "supabase init", "supabase db reset", "supabase local setup".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Cursor vs Codex for AI Workflows
Compare Cursor and Codex for AI coding workflows, repository assistance, debugging, refactoring, and reusable developer skills.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
SKILL.md Source
# Supabase Local Dev Loop
## Overview
Run the full Supabase stack locally — Postgres, Auth, Storage, Realtime, Edge Functions, and Studio — using Docker and the Supabase CLI. Local development mirrors production APIs exactly, enabling offline work, fast iteration, and repeatable migration workflows. Schema changes flow through `supabase db diff` to generate migrations, and `supabase db reset` replays them cleanly.
## Prerequisites
- Docker Desktop installed and running (required for all local services)
- Node.js 18+ (for `npx supabase` commands)
- No global install needed — all commands use `npx supabase`
## Instructions
### Step 1: Initialize Project and Start Local Stack
```bash
# Initialize Supabase in your project root
npx supabase init
```
This creates a `supabase/` directory:
```
supabase/
├── config.toml # Local stack configuration (ports, auth settings)
├── migrations/ # SQL migration files (version-controlled)
└── seed.sql # Seed data (runs after migrations on db reset)
```
Start the local stack (first run pulls Docker images — takes a few minutes):
```bash
npx supabase start
```
The CLI prints all local endpoints and keys:
```
API URL: http://localhost:54321
GraphQL URL: http://localhost:54321/graphql/v1
S3 Storage URL: http://localhost:54321/storage/v1/s3
DB URL: postgresql://postgres:postgres@localhost:54322/postgres
Studio URL: http://localhost:54323
Inbucket URL: http://localhost:54324
anon key: eyJhbGciOiJI...
service_role key: eyJhbGciOiJI...
```
Create `.env.local` from these values (git-ignored):
```bash
# .env.local
SUPABASE_URL=http://localhost:54321
SUPABASE_ANON_KEY=<anon-key-from-supabase-start>
SUPABASE_SERVICE_ROLE_KEY=<service-role-key-from-supabase-start>
DATABASE_URL=postgresql://postgres:postgres@localhost:54322/postgres
```
Verify the stack is running:
```bash
npx supabase status
```
### Step 2: Create Migrations and Seed Data
Create a migration file with a descriptive name:
```bash
npx supabase migration new create_profiles
# Creates: supabase/migrations/<timestamp>_create_profiles.sql
```
Write the migration SQL:
```sql
-- supabase/migrations/<timestamp>_create_profiles.sql
create table public.profiles (
id uuid references auth.users(id) primary key,
username text unique not null,
avatar_url text,
created_at timestamptz default now(),
updated_at timestamptz default now()
);
-- Always enable RLS on public tables
alter table public.profiles enable row level security;
create policy "Public profiles are viewable by everyone"
on public.profiles for select
using (true);
create policy "Users can update own profile"
on public.profiles for update
using (auth.uid() = id);
-- Auto-create profile on signup via trigger
create or replace function public.handle_new_user()
returns trigger as $$
begin
insert into public.profiles (id, username)
values (new.id, new.raw_user_meta_data->>'username');
return new;
end;
$$ language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
```
Add seed data for local development:
```sql
-- supabase/seed.sql (runs automatically after migrations on db reset)
insert into auth.users (id, email, raw_user_meta_data)
values
('a1b2c3d4-e5f6-7890-abcd-ef1234567890', 'alice@example.com',
'{"username": "alice"}'),
('b2c3d4e5-f6a7-8901-bcde-f12345678901', 'bob@example.com',
'{"username": "bob"}');
```
Apply migrations and seed data in one command:
```bash
npx supabase db reset
# Drops the database, replays all migrations, runs seed.sql
```
### Step 3: Iterate with Diff-Based Migrations
The core iteration loop: make changes in Studio, diff them into migration files, then verify with a clean reset.
Open Studio at `http://localhost:54323` and make schema changes interactively (add columns, create tables, modify RLS policies). Then capture those changes as a migration:
```bash
# Generate a migration from the diff between migrations and current DB state
npx supabase db diff -f add_bio_to_profiles
# Review the generated file
cat supabase/migrations/*_add_bio_to_profiles.sql
```
The generated migration captures exactly what changed:
```sql
-- Auto-generated by supabase db diff
alter table public.profiles add column bio text;
```
Verify the full migration chain replays cleanly:
```bash
npx supabase db reset
# Success = all migrations + seed apply without errors
```
Push verified migrations to a remote Supabase project:
```bash
# Link to remote project first (one-time)
npx supabase link --project-ref <your-project-ref>
# Push migrations to remote
npx supabase db push
```
Daily workflow summary:
```bash
# Start of day
npx supabase start
# After schema changes in Studio
npx supabase db diff -f descriptive_name
npx supabase db reset # Verify clean replay
# Before committing
npx supabase db reset # Final verification
npm test # Run tests against local instance
# End of day
npx supabase stop
```
## Output
- Local Supabase stack running all services via Docker (Postgres, Auth, Storage, Realtime, Studio)
- Version-controlled migration files in `supabase/migrations/`
- Seed data for repeatable local state
- Diff-based migration workflow for safe schema iteration
- `.env.local` with local connection credentials
## Error Handling
| Error | Cause | Solution |
|-------|-------|----------|
| `Cannot connect to Docker daemon` | Docker not running | Start Docker Desktop, then retry `npx supabase start` |
| `Port 54321 already in use` | Previous instance still running | Run `npx supabase stop` then `npx supabase start` |
| `supabase db reset` fails | Syntax error in migration SQL | Check the failing migration file, fix SQL, re-run reset |
| `Permission denied` on start | Docker socket permissions | Add user to `docker` group: `sudo usermod -aG docker $USER` |
| `supabase db diff` empty | No schema changes detected | Verify changes were made in the local DB, not just Studio UI cache |
| `relation "auth.users" does not exist` | Running migration outside Supabase | Auth schema only exists in the Supabase-managed Postgres instance |
## Examples
### Connect from Application Code
```typescript
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(
process.env.SUPABASE_URL!, // http://localhost:54321 locally
process.env.SUPABASE_ANON_KEY! // Local anon key from supabase start
)
// Fetch profiles — works identically in local and production
const { data, error } = await supabase
.from('profiles')
.select('username, avatar_url')
.limit(10)
```
### Test Against Local Instance with Vitest
```typescript
import { createClient } from '@supabase/supabase-js'
import { describe, it, expect, beforeAll } from 'vitest'
const supabase = createClient(
'http://localhost:54321',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' // Local anon key
)
describe('profiles', () => {
beforeAll(async () => {
// Seed data is already loaded via supabase db reset
})
it('fetches public profiles', async () => {
const { data, error } = await supabase
.from('profiles')
.select('username')
.limit(1)
expect(error).toBeNull()
expect(data).toHaveLength(1)
expect(data![0].username).toBeDefined()
})
it('enforces RLS on update', async () => {
// Anon users cannot update profiles (no auth.uid())
const { error } = await supabase
.from('profiles')
.update({ username: 'hacker' })
.eq('username', 'alice')
expect(error).not.toBeNull()
})
})
```
### Edge Function Local Development
```bash
# Create and serve an Edge Function with hot reload
npx supabase functions new hello-world
npx supabase functions serve --env-file .env.local
# Test it
curl -X POST http://localhost:54321/functions/v1/hello-world \
-H "Authorization: Bearer $SUPABASE_ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "World"}'
```
## Resources
- [Local Development Overview](https://supabase.com/docs/guides/local-development/overview)
- [Supabase CLI Reference](https://supabase.com/docs/reference/cli/introduction)
- [Database Migrations](https://supabase.com/docs/guides/deployment/database-migrations)
- [Edge Functions Quickstart](https://supabase.com/docs/guides/functions/quickstart)
- [Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)
## Next Steps
Proceed to `supabase-sdk-patterns` for production-ready client initialization, typed queries, and real-time subscriptions.Related Skills
workhuman-local-dev-loop
Workhuman local dev loop for employee recognition and rewards API. Use when integrating Workhuman Social Recognition, or building recognition workflows with HRIS systems. Trigger: "workhuman local dev loop".
wispr-local-dev-loop
Wispr Flow local dev loop for voice-to-text API integration. Use when integrating Wispr Flow dictation, WebSocket streaming, or building voice-powered applications. Trigger: "wispr local dev loop".
windsurf-local-dev-loop
Configure Windsurf local development workflow with Cascade, Previews, and terminal integration. Use when setting up a development environment, configuring Turbo mode, or establishing a fast iteration cycle with Windsurf AI. Trigger with phrases like "windsurf dev setup", "windsurf local development", "windsurf dev environment", "windsurf workflow", "develop with windsurf".
webflow-local-dev-loop
Configure a Webflow local development workflow with TypeScript, hot reload, mocked API tests, and webhook tunneling via ngrok. Use when setting up a development environment, configuring test workflows, or establishing a fast iteration cycle with the Webflow Data API. Trigger with phrases like "webflow dev setup", "webflow local development", "webflow dev environment", "develop with webflow".
vercel-local-dev-loop
Configure Vercel local development with vercel dev, environment variables, and hot reload. Use when setting up a development environment, testing serverless functions locally, or establishing a fast iteration cycle with Vercel. Trigger with phrases like "vercel dev setup", "vercel local development", "vercel dev environment", "develop with vercel locally".
veeva-local-dev-loop
Veeva Vault local dev loop for REST API and clinical operations. Use when working with Veeva Vault document management and CRM. Trigger: "veeva local dev loop".
vastai-local-dev-loop
Configure Vast.ai local development with testing and fast iteration. Use when setting up a development environment, testing instance provisioning, or building a fast iteration cycle for GPU workloads. Trigger with phrases like "vastai dev setup", "vastai local development", "vastai dev environment", "develop with vastai".
twinmind-local-dev-loop
Set up local development workflow with TwinMind API integration. Use when building applications that integrate TwinMind transcription, testing API calls locally, or developing meeting automation tools. Trigger with phrases like "twinmind dev setup", "twinmind local development", "twinmind API testing", "build with twinmind".
together-local-dev-loop
Together AI local dev loop for inference, fine-tuning, and model deployment. Use when working with Together AI's OpenAI-compatible API. Trigger: "together local dev loop".
techsmith-local-dev-loop
TechSmith local dev loop for Snagit COM API and Camtasia automation. Use when working with TechSmith screen capture and video editing automation. Trigger: "techsmith local dev loop".
supabase-webhooks-events
Implement Supabase database webhooks, pg_net async HTTP, LISTEN/NOTIFY, and Edge Function event handlers with signature verification. Use when setting up database webhooks for INSERT/UPDATE/DELETE events, sending HTTP requests from PostgreSQL triggers, handling Realtime postgres_changes as an event source, or building event-driven architectures. Trigger with phrases like "supabase webhook", "database events", "pg_net trigger", "supabase LISTEN NOTIFY", "webhook signature verify", "supabase event-driven", "supabase_functions.http_request".
supabase-upgrade-migration
Upgrade Supabase SDK and CLI versions with breaking-change detection and automated code migration. Use when upgrading @supabase/supabase-js (v1→v2 or minor bumps), migrating auth/realtime/storage APIs, or updating the Supabase CLI. Trigger with phrases like "upgrade supabase", "supabase breaking changes", "migrate supabase v2", "update supabase SDK".