with one click
db-bootstrap
Create standard Supabase project structure
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Create standard Supabase project structure
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Execute story development with selectable automation modes to accommodate different developer preferences, skill levels, and story complexity.
Set up a Kord-aligned documentation baseline (no legacy frameworks)
Create Next Story Task methodology and workflow
Validate Next Story Task methodology and workflow
advanced-elicitation methodology and workflow
No checklists needed - this task facilitates brainstorming sessions, validation is through user interaction methodology and workflow
| name | db-bootstrap |
| description | Create standard Supabase project structure |
| agent | architect |
| subtask | false |
Create standard Supabase project structure
Parameter:* mode (optional, default: interactive)
Purpose:* Definitive pass/fail criteria for task completion
Checklist:*
acceptance-criteria:
- [ ] Data persisted correctly; constraints respected; no orphaned data
type: acceptance-criterion
blocker: true
validation: |
Assert data persisted correctly; constraints respected; no orphaned data
error_message: "Acceptance criterion not met: Data persisted correctly; constraints respected; no orphaned data"
Strategy:* retry
Common Errors:*
Error:* Connection Failed
Error:* Query Syntax Error
Error:* Transaction Rollback
Ask user:
Project name*: (e.g., "mmos-platform")
Include starter templates?*
mkdir -p supabase/{migrations,seeds,tests,rollback,snapshots,docs}
echo "✓ Created directories:
supabase/migrations/ - Schema migrations
supabase/seeds/ - Seed data
supabase/tests/ - Smoke tests
supabase/rollback/ - Rollback scripts
supabase/snapshots/ - Schema snapshots
supabase/docs/ - Documentation"
# Migrations
## Naming: YYYYMMDDHHMMSS_description.sql
Example: 20251026120000_baseline_schema.sql
## Order (within each file):
1. Extensions
2. Tables + Constraints
3. Functions
4. Triggers
5. RLS (enable + policies)
6. Views
## Workflow:
verify-order migration.sql # Check order
dry-run migration.sql # Test
snapshot pre_migration # Create rollback point
apply-migration migration.sql # Apply
smoke-test # Validate
# Seeds
## Types:
- Required: Data app needs to function
- Test: Sample data for development
- Reference: Lookup tables (countries, categories)
## Idempotent pattern:
INSERT INTO table (id, name) VALUES (1, 'value')
ON CONFLICT (id) DO NOTHING;
# Tests
## Smoke tests (post-migration validation):
- Tables exist
- RLS enabled
- Policies installed
- Functions callable
- Basic queries work
## Run: *smoke-test
# Rollback
## Snapshots (automatic):
Created by apply-migration and snapshot commands
Located in: ../snapshots/
## Manual rollback scripts:
Write explicit undo operations for complex migrations
Example: YYYYMMDDHHMMSS_rollback_description.sql
# Local dev
.env
.env.local
.branches
.temp
# OS
.DS_Store
Thumbs.db
# Optional: Snapshots (if too large for git)
# snapshots/*.sql
# Supabase Local Development Config
[api]
enabled = true
port = 54321
[db]
port = 54322
shadow_port = 54320
major_version = 15
[db.pooler]
enabled = true
port = 54329
pool_mode = "transaction"
[studio]
enabled = true
port = 54323
[auth]
enabled = true
site_url = "http://localhost:3000"
# See: https://supabase.com/docs/guides/cli/config
-- Baseline Schema
-- Run after: supabase init
BEGIN;
-- Extensions
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
-- Example table (customize for your project)
CREATE TABLE IF NOT EXISTS public.profiles (
id UUID PRIMARY KEY REFERENCES auth.users(id) ON DELETE CASCADE,
username TEXT UNIQUE,
full_name TEXT,
avatar_url TEXT,
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
-- Updated_at trigger
CREATE OR REPLACE FUNCTION public.handle_updated_at()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER set_updated_at
BEFORE UPDATE ON public.profiles
FOR EACH ROW
EXECUTE FUNCTION public.handle_updated_at();
-- RLS
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users can view own profile"
ON public.profiles FOR SELECT
TO authenticated
USING (auth.uid() = id);
CREATE POLICY "Users can update own profile"
ON public.profiles FOR UPDATE
TO authenticated
USING (auth.uid() = id)
WITH CHECK (auth.uid() = id);
-- Grants
GRANT USAGE ON SCHEMA public TO authenticated, anon;
GRANT SELECT, INSERT, UPDATE ON public.profiles TO authenticated;
COMMIT;
-- Basic smoke test
SET client_min_messages = warning;
\echo 'Checking tables...'
SELECT COUNT(*) AS tables FROM information_schema.tables
WHERE table_schema='public';
\echo 'Checking RLS...'
SELECT COUNT(*) AS rls_enabled FROM pg_tables
WHERE schemaname='public' AND rowsecurity=true;
\echo 'Checking policies...'
SELECT COUNT(*) AS policies FROM pg_policies
WHERE schemaname='public';
\echo '✓ Smoke test complete'
# Migration Log
### Version X.Y.Z - Description (Date)
- Migration: filename.sql
- Status: ✅ Success / ❌ Failed / ⏪ Rolled Back
- Changes: What changed
- Rollback: How to undo
---
## Baseline (Initial)
- Migration: 00000000000000_baseline.sql
- Status: ⏳ Pending
- Changes: Initial project structure
- Rollback: N/A (baseline)
✅ Supabase Project Bootstrapped
Structure created:
supabase/
├── migrations/ (migration files)
├── seeds/ (seed data)
├── tests/ (smoke tests)
├── rollback/ (rollback scripts)
├── snapshots/ (schema snapshots)
├── docs/ (documentation)
├── config.toml (local config)
└── .gitignore
Next steps:
1. Set SUPABASE_DB_URL in .env
2. env-check - Validate setup
3. apply-migration supabase/migrations/00000000000000_baseline.sql
4. smoke-test - Validate baseline
5. snapshot baseline - Create initial snapshot
Documentation:
- supabase/migrations/README.md
- supabase/docs/migration-log.md
Create .env file in project root:
# Supabase Database Connection
# Get from: https://app.supabase.com/project/_/settings/database
# Pooler (recommended for migrations)
SUPABASE_DB_URL="postgresql://postgres.[PASSWORD]@[PROJECT-REF].supabase.co:6543/postgres?sslmode=require"
# Direct (for backups/analysis)
# SUPABASE_DB_URL="postgresql://postgres.[PASSWORD]@[PROJECT-REF].supabase.co:5432/postgres?sslmode=require"
Security*:
supabase/
├── migrations/
├── seeds/
├── tests/
├── rollback/
├── snapshots/
└── docs/
Use for*: Existing projects, simple setups
+ README.md files
+ config.toml
+ .gitignore
+ migration-log.md
Use for*: New projects, team environments
+ baseline.sql migration
+ smoke_test.sql
+ Example profiles table
+ RLS policies
Use for*: Greenfield projects, learning
If supabase/ already exists:
# Backup existing
mv supabase supabase.backup
# Bootstrap new
bootstrap
# Merge as needed
cp supabase.backup/migrations/* supabase/migrations/
Replace baseline.sql with your tables:
create-schemaEdit READMEs to add:
Add to pipeline:
# .github/workflows/db-test.yml
- name: Run smoke tests
run: |
/db-sage
smoke-test
env-checkcreate-schema (or use existing)apply-migration baseline.sqlsmoke-testsnapshot baselineProblem*: supabase/ folder exists
Options*:
Problem*: Insufficient file permissions
Fix*: Check you're in project root with write access
Problem*: Already using Supabase CLI
Solution*: Bootstrap is compatible with Supabase CLI
create-schema - Design schema interactivelyapply-migration {path} - Run first migrationsmoke-test - Validate setupsnapshot baseline - Create initial snapshotenv-check - Validate environment