| name | supabase-schema-from-requirements |
| description | Design Supabase Postgres schema from business requirements with migrations, RLS, and types.
Use when translating specifications into database tables, creating migration files,
adding Row Level Security policies, or generating TypeScript types from schema.
Trigger with phrases like "supabase schema", "design database supabase",
"schema from requirements", "supabase migration", "supabase tables from spec".
|
| allowed-tools | Read, Write, Bash(supabase:*), Bash(npx:*) |
| version | 1.53.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","supabase","database","migration","schema-design","postgres","rls"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Supabase Schema from Requirements
Overview
Translate business requirements into a production-ready Postgres schema inside Supabase, covering the full path from specification to applied migration: entity extraction, tables with proper types and constraints, Row Level Security policies, performance indexes, timestamp triggers, and TypeScript type generation. Getting this right early matters because every downstream feature — auth, storage, realtime, edge functions — depends on well-designed tables.
Prerequisites
- Supabase CLI installed (
npm install -g supabase) and project linked (supabase link)
@supabase/supabase-js v2+ installed in the project
- Business requirements, PRD, or specification document identifying entities and access rules
- Local Supabase running (
supabase start) or a linked remote project
Instructions
Step 1: Parse Requirements and Create Migration
Read the requirements document and extract entities, attributes, relationships, and access control rules. Map each entity to a Postgres table.
Entity extraction example (project management app):
| Entity | Key Columns | Relationships |
|---|
| Organization | name, slug, plan | has many Projects, has many Members |
| Project | name, description, status | belongs to Organization, has many Tasks |
| Task | title, priority, status, due_date | belongs to Project, assigned to User |
| Member | role (owner/admin/member) | junction linking User to Organization |
Create the migration file:
npx supabase migration new create_tables
Write the migration SQL using standard Postgres data types (uuid, text, integer, boolean, timestamptz, jsonb):
Full worked migration (project-management app — tables, FKs, indexes, moddatetime triggers): references/worked-schema-examples.md.
Data type selection guide: