Supabase

From moasq/nanowave · View interactive version

Supabase is an AI agent skill from the GitHub repository moasq/nanowave. Supabase Swift SDK patterns for auth, database, and storage. Use when implementing app features related to supabase.

How to use this skill

Skill file

Supabase Integration

CRITICAL: Backend-First Execution Order

You MUST set up the Supabase backend BEFORE writing any Swift code. Follow this exact order:

Phase 1: Backend Setup (via Supabase MCP)

  1. Create all tables with mcp__supabase__execute_sql — columns, types, foreign keys, constraints, indexes
  2. Enable RLS on every table — ALTER TABLE ... ENABLE ROW LEVEL SECURITY
  3. Create RLS policies for every table — SELECT, INSERT, UPDATE, DELETE as appropriate
  4. Create storage buckets — public for images, private for documents
  5. Create storage policies — per-user folder enforcement on storage.objects
  6. Create triggers — for updated_at, denormalized counters, etc.
  7. Verify with mcp__supabase__list_tables and mcp__supabase__list_storage_buckets
  8. Check auth config with mcp__supabase__get_auth_config to confirm providers are enabled (auto-configured by nanowave)

Phase 2: Swift Code

  1. Write Config/AppConfig.swift — Supabase URL + anon key
  2. Write SupabaseService.swift — shared client
  3. Write models with Codable + CodingKeys matching the table columns you just created
  4. Write services that query the tables you just created
  5. Write views

NEVER skip Phase 1. If you write Swift code that references tables that don't exist, the app will crash at runtime.

Client Initialization

Initialize SupabaseClient once in a shared service. Use PKCE auth flow (default for mobile).

import Supabase

@Observable
final class SupabaseService {
    static let shared = SupabaseService()
    let client: SupabaseClient

    private init() {
        client = SupabaseClient(
            supabaseURL: URL(string: AppConfig.supabaseURL)!,
            supabaseKey: AppConfig.supabaseAnonKey
        )
    }
}

AppConfig Pattern

Store Supabase credentials as static constants — injected by nanowave during build.

enum AppConfig {
    static let supabaseURL = "https://PROJECT_REF.supabase.co"
    static let supabaseAnonKey = "YOUR_ANON_KEY"
}

Key Rules

Available MCP Tools

References

Core

Storage

Management API

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.