[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D9QH73M6QC3W56XGXPAT9F":3,"skill-same:01M7D9QH73M6QC3W56XGXPAT9F":87},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":65,"commitSha":66,"skillDirectory":67,"forksCount":14,"repositoryHtmlUrl":68,"repositoryHomepageUrl":6,"ownerHtmlUrl":69,"ownerBlogUrl":70,"ownerDescription":71,"updatedAt":72,"install":73,"resources":86},"01M7D9QH73M6QC3W56XGXPAT9F","Supabase Testing",null,"Testing patterns for Supabase applications covering auth flow testing, Row Level Security policy testing, realtime subscription testing, and edge function testing","GrupoANDevelopment-m\u002Falberto-ai","GrupoANDevelopment-m","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F257455179?v=4","01M7D69X2N2KEVN0SJF6WGM6SH","Antônio  Ndombe","01M7D69X3P5JTT8H8S904N3888",0,"MIT","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fsupabase-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: \"Supabase Testing\"\ndescription: \"Testing patterns for Supabase applications covering auth flow testing, Row Level Security policy testing, realtime subscription testing, and edge function testing\"\nversion: 1.0.0\nauthor: thetestingacademy\nlicense: MIT\ntags: [supabase, rls, auth, realtime, edge-functions, postgres, storage, migrations, row-level-security, testing]\ntestingTypes: [unit, integration, e2e]\nframeworks: [vitest, jest, playwright]\nlanguages: [typescript, javascript]\ndomains: [web, api, backend]\nagents: [claude-code, cursor, github-copilot, windsurf, codex, aider, continue, cline, zed, bolt, gemini-cli, amp]\n---\n\n# Supabase Testing Skill\n\nYou are an expert QA engineer specializing in testing Supabase-powered applications. When the user asks you to write, review, or debug tests for Supabase auth, Row Level Security, realtime subscriptions, edge functions, or storage, follow these detailed instructions.\n\n## Core Principles\n\n1. **Local-first testing** -- Always use Supabase CLI (`supabase start`) to run a local Postgres instance with all Supabase features. Never test directly against production.\n2. **RLS is your security boundary** -- Row Level Security policies are the most critical code in a Supabase app. Test every policy with multiple user roles and edge cases.\n3. **Test auth flows end-to-end** -- Supabase auth involves email confirmation, magic links, OAuth redirects, and JWT tokens. Test the full flow, not just the API call.\n4. **Realtime requires connection testing** -- Subscription tests must establish actual WebSocket connections. Mock-only tests miss critical reconnection and conflict scenarios.\n5. **Edge functions are isolated** -- Supabase Edge Functions run in Deno. Test them independently with their own test runner before integration testing.\n6. **Storage policies mirror RLS** -- Storage bucket policies follow the same RLS pattern. Apply the same testing rigor to file access as to row access.\n7. **Migration testing prevents data loss** -- Every schema migration should be tested against a snapshot of production-like data to verify both the up and down paths.\n\n## Project Structure\n\nAlways organize Supabase testing with this structure:\n\n```\nsupabase\u002F\n  config.toml\n  migrations\u002F\n    20240101000000_create_profiles.sql\n    20240102000000_add_rls_policies.sql\n  functions\u002F\n    hello-world\u002F\n      index.ts\n    send-notification\u002F\n      index.ts\n  seed.sql\n  tests\u002F\n    rls\u002F\n      profiles.test.ts\n      posts.test.ts\n      comments.test.ts\n    migrations\u002F\n      migration.test.ts\nsrc\u002F\n  lib\u002F\n    supabase\u002F\n      client.ts\n      server.ts\n      middleware.ts\n  __tests__\u002F\n    unit\u002F\n      auth.test.ts\n      database.test.ts\n    integration\u002F\n      auth-flow.test.ts\n      realtime.test.ts\n      storage.test.ts\n    e2e\u002F\n      signup-login.spec.ts\n      crud-with-rls.spec.ts\n    helpers\u002F\n      supabase-test-utils.ts\n      test-users.ts\n      seed-test-data.ts\n```\n\n## Supabase Local Setup for Testing\n\n### Configuration\n\n```toml\n# supabase\u002Fconfig.toml\n[project]\nid = \"my-project\"\n\n[db]\nport = 54322\n\n[auth]\nsite_url = \"http:\u002F\u002Flocalhost:3000\"\nenable_signup = true\n\n[auth.email]\nenable_confirmations = false  # Disable for testing\ndouble_confirm_changes = false\n\n[auth.external.google]\nenabled = false\n```\n\n### Test Helper Setup\n\n```typescript\n\u002F\u002F __tests__\u002Fhelpers\u002Fsupabase-test-utils.ts\nimport { createClient, SupabaseClient } from '@supabase\u002Fsupabase-js';\n\nconst SUPABASE_URL = process.env.SUPABASE_URL || 'http:\u002F\u002F127.0.0.1:54321';\nconst SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';\nconst SUPABASE_SERVICE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';\n\n\u002F\u002F Anon client (respects RLS)\nexport function createAnonClient(): SupabaseClient {\n  return createClient(SUPABASE_URL, SUPABASE_ANON_KEY);\n}\n\n\u002F\u002F Service role client (bypasses RLS)\nexport function createServiceClient(): SupabaseClient {\n  return createClient(SUPABASE_URL, SUPABASE_SERVICE_KEY);\n}\n\n\u002F\u002F Authenticated client for a specific user\nexport async function createAuthenticatedClient(\n  email: string,\n  password: string\n): Promise\u003CSupabaseClient> {\n  const client = createAnonClient();\n  const { error } = await client.auth.signInWithPassword({ email, password });\n  if (error) throw new Error(`Auth failed for ${email}: ${error.message}`);\n  return client;\n}\n\n\u002F\u002F Create a test user and return authenticated client\nexport async function createTestUser(\n  email?: string,\n  password?: string,\n  metadata?: Record\u003Cstring, unknown>\n): Promise\u003C{ client: SupabaseClient; userId: string; email: string }> {\n  const testEmail = email || `test-${Date.now()}-${Math.random().toString(36).slice(2)}@test.com`;\n  const testPassword = password || 'TestPassword123!';\n\n  const serviceClient = createServiceClient();\n\n  \u002F\u002F Create user via service role (bypasses email confirmation)\n  const { data: user, error } = await serviceClient.auth.admin.createUser({\n    email: testEmail,\n    password: testPassword,\n    email_confirm: true,\n    user_metadata: metadata || {},\n  });\n\n  if (error) throw new Error(`Failed to create test user: ${error.message}`);\n\n  const client = await createAuthenticatedClient(testEmail, testPassword);\n\n  return {\n    client,\n    userId: user.user.id,\n    email: testEmail,\n  };\n}\n\n\u002F\u002F Cleanup test data\nexport async function cleanupTestUser(userId: string): Promise\u003Cvoid> {\n  const serviceClient = createServiceClient();\n  await serviceClient.auth.admin.deleteUser(userId);\n}\n\n\u002F\u002F Reset database to clean state\nexport async function resetDatabase(): Promise\u003Cvoid> {\n  const serviceClient = createServiceClient();\n\n  \u002F\u002F Delete all non-system data in reverse dependency order\n  await serviceClient.from('comments').delete().neq('id', '00000000-0000-0000-0000-000000000000');\n  await serviceClient.from('posts').delete().neq('id', '00000000-0000-0000-0000-000000000000');\n  await serviceClient.from('profiles').delete().neq('id', '00000000-0000-0000-0000-000000000000');\n}\n```\n\n```typescript\n\u002F\u002F __tests__\u002Fhelpers\u002Ftest-users.ts\nimport { createTestUser, cleanupTestUser } from '.\u002Fsupabase-test-utils';\nimport type { SupabaseClient } from '@supabase\u002Fsupabase-js';\n\ninterface TestUserContext {\n  client: SupabaseClient;\n  userId: string;\n  email: string;\n}\n\nexport class TestUserManager {\n  private users: TestUserContext[] = [];\n\n  async createUser(\n    role: string = 'user',\n    metadata: Record\u003Cstring, unknown> = {}\n  ): Promise\u003CTestUserContext> {\n    const user = await createTestUser(undefined, undefined, { role, ...metadata });\n    this.users.push(user);\n    return user;\n  }\n\n  async createAdmin(): Promise\u003CTestUserContext> {\n    return this.createUser('admin');\n  }\n\n  async createModerator(): Promise\u003CTestUserContext> {\n    return this.createUser('moderator');\n  }\n\n  async cleanup(): Promise\u003Cvoid> {\n    for (const user of this.users) {\n      await cleanupTestUser(user.userId).catch(() => {});\n    }\n    this.users = [];\n  }\n}\n```\n\n## Row Level Security (RLS) Testing\n\n### Schema and Policies\n\n```sql\n-- supabase\u002Fmigrations\u002F20240101000000_create_profiles.sql\nCREATE TABLE profiles (\n  id UUID REFERENCES auth.users(id) ON DELETE CASCADE PRIMARY KEY,\n  username TEXT UNIQUE NOT NULL,\n  bio TEXT,\n  avatar_url TEXT,\n  is_public BOOLEAN DEFAULT true,\n  created_at TIMESTAMPTZ DEFAULT now(),\n  updated_at TIMESTAMPTZ DEFAULT now()\n);\n\nALTER TABLE profiles ENABLE ROW LEVEL SECURITY;\n\n-- Anyone can view public profiles\nCREATE POLICY \"Public profiles are viewable by everyone\"\n  ON profiles FOR SELECT\n  USING (is_public = true);\n\n-- Users can view their own profile (even if private)\nCREATE POLICY \"Users can view own profile\"\n  ON profiles FOR SELECT\n  USING (auth.uid() = id);\n\n-- Users can update only their own profile\nCREATE POLICY \"Users can update own profile\"\n  ON profiles FOR UPDATE\n  USING (auth.uid() = id)\n  WITH CHECK (auth.uid() = id);\n\n-- Users can insert their own profile\nCREATE POLICY \"Users can insert own profile\"\n  ON profiles FOR INSERT\n  WITH CHECK (auth.uid() = id);\n\n-- Only admins can delete profiles\nCREATE POLICY \"Admins can delete profiles\"\n  ON profiles FOR DELETE\n  USING (\n    EXISTS (\n      SELECT 1 FROM profiles\n      WHERE id = auth.uid()\n      AND (auth.jwt() -> 'user_metadata' ->> 'role') = 'admin'\n    )\n  );\n```\n\n```sql\n-- supabase\u002Fmigrations\u002F20240102000000_create_posts.sql\nCREATE TABLE posts (\n  id UUID DEFAULT gen_random_uuid() PRIMARY KEY,\n  author_id UUID REFERENCES profiles(id) ON DELETE CASCADE NOT NULL,\n  title TEXT NOT NULL,\n  content TEXT NOT NULL,\n  published BOOLEAN DEFAULT false,\n  created_at TIMESTAMPTZ DEFAULT now(),\n  updated_at TIMESTAMPTZ DEFAULT now()\n);\n\nALTER TABLE posts ENABLE ROW LEVEL SECURITY;\n\n-- Anyone can view published posts\nCREATE POLICY \"Published posts are viewable by everyone\"\n  ON posts FOR SELECT\n  USING (published = true);\n\n-- Authors can view their own drafts\nCREATE POLICY \"Authors can view own drafts\"\n  ON posts FOR SELECT\n  USING (auth.uid() = author_id);\n\n-- Authenticated users can create posts\nCREATE POLICY \"Authenticated users can create posts\"\n  ON posts FOR INSERT\n  WITH CHECK (auth.uid() = author_id);\n\n-- Authors can update their own posts\nCREATE POLICY \"Authors can update own posts\"\n  ON posts FOR UPDATE\n  USING (auth.uid() = author_id)\n  WITH CHECK (auth.uid() = author_id);\n\n-- Authors can delete their own posts\nCREATE POLICY \"Authors can delete own posts\"\n  ON posts FOR DELETE\n  USING (auth.uid() = author_id);\n```\n\n### RLS Policy Tests\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Frls\u002Fprofiles.test.ts\nimport { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest';\nimport {\n  createAnonClient,\n  createServiceClient,\n  resetDatabase,\n} from '..\u002F..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002F..\u002Fhelpers\u002Ftest-users';\n\ndescribe('Profiles RLS Policies', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(async () => {\n    serviceClient = createServiceClient();\n  });\n\n  afterAll(async () => {\n    await users.cleanup();\n  });\n\n  beforeEach(async () => {\n    await resetDatabase();\n  });\n\n  describe('SELECT policies', () => {\n    it('should allow anyone to view public profiles', async () => {\n      const { userId } = await users.createUser();\n\n      \u002F\u002F Create a public profile via service role\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: 'publicuser',\n        bio: 'Public bio',\n        is_public: true,\n      });\n\n      \u002F\u002F Anonymous client should see the profile\n      const anonClient = createAnonClient();\n      const { data, error } = await anonClient\n        .from('profiles')\n        .select('*')\n        .eq('id', userId)\n        .single();\n\n      expect(error).toBeNull();\n      expect(data).toBeDefined();\n      expect(data!.username).toBe('publicuser');\n    });\n\n    it('should hide private profiles from anonymous users', async () => {\n      const { userId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: 'privateuser',\n        bio: 'Private bio',\n        is_public: false,\n      });\n\n      const anonClient = createAnonClient();\n      const { data } = await anonClient\n        .from('profiles')\n        .select('*')\n        .eq('id', userId);\n\n      expect(data).toEqual([]);\n    });\n\n    it('should allow users to view their own private profile', async () => {\n      const { client, userId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: 'myprofile',\n        bio: 'My private bio',\n        is_public: false,\n      });\n\n      const { data, error } = await client\n        .from('profiles')\n        .select('*')\n        .eq('id', userId)\n        .single();\n\n      expect(error).toBeNull();\n      expect(data!.username).toBe('myprofile');\n    });\n\n    it('should hide private profiles from other authenticated users', async () => {\n      const { userId: ownerId } = await users.createUser();\n      const { client: otherClient } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: ownerId,\n        username: 'secretuser',\n        is_public: false,\n      });\n\n      const { data } = await otherClient\n        .from('profiles')\n        .select('*')\n        .eq('id', ownerId);\n\n      expect(data).toEqual([]);\n    });\n  });\n\n  describe('INSERT policies', () => {\n    it('should allow users to create their own profile', async () => {\n      const { client, userId } = await users.createUser();\n\n      const { error } = await client.from('profiles').insert({\n        id: userId,\n        username: `user-${Date.now()}`,\n        bio: 'My bio',\n      });\n\n      expect(error).toBeNull();\n    });\n\n    it('should prevent users from creating profiles for other users', async () => {\n      const { client } = await users.createUser();\n      const { userId: otherUserId } = await users.createUser();\n\n      const { error } = await client.from('profiles').insert({\n        id: otherUserId,\n        username: 'impersonator',\n      });\n\n      expect(error).not.toBeNull();\n      expect(error!.code).toBe('42501'); \u002F\u002F RLS violation\n    });\n\n    it('should prevent anonymous users from creating profiles', async () => {\n      const anonClient = createAnonClient();\n\n      const { error } = await anonClient.from('profiles').insert({\n        id: '550e8400-e29b-41d4-a716-446655440000',\n        username: 'anonymous',\n      });\n\n      expect(error).not.toBeNull();\n    });\n  });\n\n  describe('UPDATE policies', () => {\n    it('should allow users to update their own profile', async () => {\n      const { client, userId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: `user-${Date.now()}`,\n        bio: 'Original bio',\n      });\n\n      const { error } = await client\n        .from('profiles')\n        .update({ bio: 'Updated bio' })\n        .eq('id', userId);\n\n      expect(error).toBeNull();\n\n      const { data } = await client\n        .from('profiles')\n        .select('bio')\n        .eq('id', userId)\n        .single();\n\n      expect(data!.bio).toBe('Updated bio');\n    });\n\n    it('should prevent users from updating other profiles', async () => {\n      const { userId: ownerId } = await users.createUser();\n      const { client: attackerClient } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: ownerId,\n        username: `target-${Date.now()}`,\n        bio: 'Original',\n      });\n\n      const { data } = await attackerClient\n        .from('profiles')\n        .update({ bio: 'Hacked!' })\n        .eq('id', ownerId)\n        .select();\n\n      \u002F\u002F RLS silently filters -- no rows affected\n      expect(data).toEqual([]);\n\n      \u002F\u002F Verify original is unchanged\n      const { data: original } = await serviceClient\n        .from('profiles')\n        .select('bio')\n        .eq('id', ownerId)\n        .single();\n\n      expect(original!.bio).toBe('Original');\n    });\n  });\n\n  describe('DELETE policies', () => {\n    it('should allow admins to delete profiles', async () => {\n      const { client: adminClient } = await users.createAdmin();\n      const { userId: targetId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: targetId,\n        username: `delete-target-${Date.now()}`,\n      });\n\n      \u002F\u002F Admin needs their own profile for the policy check\n      const adminUserId = (await adminClient.auth.getUser()).data.user!.id;\n      await serviceClient.from('profiles').insert({\n        id: adminUserId,\n        username: `admin-${Date.now()}`,\n      });\n\n      const { error } = await adminClient\n        .from('profiles')\n        .delete()\n        .eq('id', targetId);\n\n      expect(error).toBeNull();\n    });\n\n    it('should prevent non-admin users from deleting profiles', async () => {\n      const { client: regularClient } = await users.createUser();\n      const { userId: targetId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: targetId,\n        username: `no-delete-${Date.now()}`,\n      });\n\n      const { data } = await regularClient\n        .from('profiles')\n        .delete()\n        .eq('id', targetId)\n        .select();\n\n      \u002F\u002F Should not delete anything\n      expect(data).toEqual([]);\n    });\n  });\n});\n```\n\n### Posts RLS Tests\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Frls\u002Fposts.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport {\n  createAnonClient,\n  createServiceClient,\n} from '..\u002F..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002F..\u002Fhelpers\u002Ftest-users';\n\ndescribe('Posts RLS Policies', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(() => {\n    serviceClient = createServiceClient();\n  });\n\n  afterAll(async () => {\n    await users.cleanup();\n  });\n\n  it('should allow anyone to see published posts', async () => {\n    const { userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `author-${Date.now()}`,\n    });\n\n    await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Published Post',\n      content: 'This is public',\n      published: true,\n    });\n\n    const anonClient = createAnonClient();\n    const { data } = await anonClient\n      .from('posts')\n      .select('*')\n      .eq('published', true);\n\n    expect(data!.length).toBeGreaterThan(0);\n    expect(data!.some((p) => p.title === 'Published Post')).toBe(true);\n  });\n\n  it('should hide draft posts from anonymous users', async () => {\n    const { userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `draft-author-${Date.now()}`,\n    });\n\n    const { data: insertedPost } = await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Secret Draft',\n      content: 'Not published',\n      published: false,\n    }).select().single();\n\n    const anonClient = createAnonClient();\n    const { data } = await anonClient\n      .from('posts')\n      .select('*')\n      .eq('id', insertedPost!.id);\n\n    expect(data).toEqual([]);\n  });\n\n  it('should allow authors to see their own drafts', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `my-draft-author-${Date.now()}`,\n    });\n\n    await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'My Draft',\n      content: 'Work in progress',\n      published: false,\n    });\n\n    const { data } = await client\n      .from('posts')\n      .select('*')\n      .eq('author_id', userId)\n      .eq('published', false);\n\n    expect(data!.length).toBeGreaterThan(0);\n    expect(data![0].title).toBe('My Draft');\n  });\n\n  it('should prevent users from creating posts as another author', async () => {\n    const { client } = await users.createUser();\n    const { userId: otherUserId } = await users.createUser();\n\n    const { error } = await client.from('posts').insert({\n      author_id: otherUserId,\n      title: 'Impersonation Post',\n      content: 'Not my account',\n    });\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should prevent users from updating other authors posts', async () => {\n    const { userId: authorId } = await users.createUser();\n    const { client: attackerClient } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: authorId,\n      username: `update-target-${Date.now()}`,\n    });\n\n    const { data: post } = await serviceClient.from('posts').insert({\n      author_id: authorId,\n      title: 'Original Title',\n      content: 'Original content',\n      published: true,\n    }).select().single();\n\n    const { data } = await attackerClient\n      .from('posts')\n      .update({ title: 'Hacked Title' })\n      .eq('id', post!.id)\n      .select();\n\n    expect(data).toEqual([]);\n  });\n});\n```\n\n## Auth Flow Testing\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Fauth-flow.test.ts\nimport { describe, it, expect, afterAll } from 'vitest';\nimport { createAnonClient, createServiceClient } from '..\u002Fhelpers\u002Fsupabase-test-utils';\n\ndescribe('Supabase Auth Flows', () => {\n  const createdUserIds: string[] = [];\n\n  afterAll(async () => {\n    const serviceClient = createServiceClient();\n    for (const id of createdUserIds) {\n      await serviceClient.auth.admin.deleteUser(id).catch(() => {});\n    }\n  });\n\n  describe('Email\u002FPassword Sign Up', () => {\n    it('should sign up a new user with email and password', async () => {\n      const client = createAnonClient();\n      const email = `signup-${Date.now()}@test.com`;\n\n      const { data, error } = await client.auth.signUp({\n        email,\n        password: 'TestPassword123!',\n      });\n\n      expect(error).toBeNull();\n      expect(data.user).toBeDefined();\n      expect(data.user!.email).toBe(email);\n      createdUserIds.push(data.user!.id);\n    });\n\n    it('should reject signup with weak password', async () => {\n      const client = createAnonClient();\n\n      const { error } = await client.auth.signUp({\n        email: `weak-${Date.now()}@test.com`,\n        password: '123',\n      });\n\n      expect(error).not.toBeNull();\n    });\n\n    it('should reject duplicate email signup', async () => {\n      const client = createAnonClient();\n      const email = `dup-${Date.now()}@test.com`;\n\n      \u002F\u002F First signup\n      const { data } = await client.auth.signUp({\n        email,\n        password: 'TestPassword123!',\n      });\n      createdUserIds.push(data.user!.id);\n\n      \u002F\u002F Second signup with same email\n      const { data: dup, error } = await client.auth.signUp({\n        email,\n        password: 'AnotherPassword123!',\n      });\n\n      \u002F\u002F Supabase returns a fake user for security (no error), but no session\n      expect(dup.session).toBeNull();\n    });\n  });\n\n  describe('Email\u002FPassword Sign In', () => {\n    it('should sign in with correct credentials', async () => {\n      const serviceClient = createServiceClient();\n      const email = `signin-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      const { data, error } = await client.auth.signInWithPassword({\n        email,\n        password: 'TestPassword123!',\n      });\n\n      expect(error).toBeNull();\n      expect(data.session).toBeDefined();\n      expect(data.session!.access_token).toBeDefined();\n      expect(data.user!.email).toBe(email);\n    });\n\n    it('should reject incorrect password', async () => {\n      const serviceClient = createServiceClient();\n      const email = `wrongpw-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'CorrectPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      const { error } = await client.auth.signInWithPassword({\n        email,\n        password: 'WrongPassword123!',\n      });\n\n      expect(error).not.toBeNull();\n      expect(error!.message).toContain('Invalid login credentials');\n    });\n\n    it('should reject non-existent email', async () => {\n      const client = createAnonClient();\n\n      const { error } = await client.auth.signInWithPassword({\n        email: 'doesnotexist@test.com',\n        password: 'TestPassword123!',\n      });\n\n      expect(error).not.toBeNull();\n    });\n  });\n\n  describe('Session Management', () => {\n    it('should return a valid session after sign in', async () => {\n      const serviceClient = createServiceClient();\n      const email = `session-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      const { data: sessionData } = await client.auth.getSession();\n      expect(sessionData.session).not.toBeNull();\n      expect(sessionData.session!.expires_at).toBeDefined();\n    });\n\n    it('should sign out and invalidate session', async () => {\n      const serviceClient = createServiceClient();\n      const email = `signout-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      const { error } = await client.auth.signOut();\n      expect(error).toBeNull();\n\n      const { data } = await client.auth.getSession();\n      expect(data.session).toBeNull();\n    });\n  });\n\n  describe('User Metadata', () => {\n    it('should store and retrieve user metadata', async () => {\n      const serviceClient = createServiceClient();\n      const email = `meta-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n        user_metadata: { role: 'editor', displayName: 'Test Editor' },\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      const { data } = await client.auth.getUser();\n      expect(data.user!.user_metadata.role).toBe('editor');\n      expect(data.user!.user_metadata.displayName).toBe('Test Editor');\n    });\n\n    it('should update user metadata', async () => {\n      const serviceClient = createServiceClient();\n      const email = `update-meta-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n        user_metadata: { displayName: 'Original' },\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      await client.auth.updateUser({\n        data: { displayName: 'Updated' },\n      });\n\n      const { data } = await client.auth.getUser();\n      expect(data.user!.user_metadata.displayName).toBe('Updated');\n    });\n  });\n});\n```\n\n## Realtime Subscription Testing\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Frealtime.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createServiceClient } from '..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002Fhelpers\u002Ftest-users';\nimport type { RealtimeChannel } from '@supabase\u002Fsupabase-js';\n\ndescribe('Supabase Realtime Subscriptions', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n  const channels: RealtimeChannel[] = [];\n\n  beforeAll(() => {\n    serviceClient = createServiceClient();\n  });\n\n  afterAll(async () => {\n    \u002F\u002F Unsubscribe all channels\n    for (const channel of channels) {\n      await channel.unsubscribe();\n    }\n    await users.cleanup();\n  });\n\n  it('should receive INSERT events on subscribed table', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `realtime-${Date.now()}`,\n    });\n\n    const receivedEvents: any[] = [];\n\n    const channel = client\n      .channel('posts-inserts')\n      .on(\n        'postgres_changes',\n        { event: 'INSERT', schema: 'public', table: 'posts' },\n        (payload) => receivedEvents.push(payload)\n      )\n      .subscribe();\n\n    channels.push(channel);\n\n    \u002F\u002F Wait for subscription to be established\n    await new Promise((resolve) => setTimeout(resolve, 1000));\n\n    \u002F\u002F Insert a post via service client\n    await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Realtime Test Post',\n      content: 'Testing realtime',\n      published: true,\n    });\n\n    \u002F\u002F Wait for the event to arrive\n    await new Promise((resolve) => setTimeout(resolve, 2000));\n\n    expect(receivedEvents.length).toBeGreaterThan(0);\n    expect(receivedEvents[0].new.title).toBe('Realtime Test Post');\n    expect(receivedEvents[0].eventType).toBe('INSERT');\n  });\n\n  it('should receive UPDATE events', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `rt-update-${Date.now()}`,\n    });\n\n    const { data: post } = await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Before Update',\n      content: 'Original',\n      published: true,\n    }).select().single();\n\n    const updateEvents: any[] = [];\n\n    const channel = client\n      .channel('posts-updates')\n      .on(\n        'postgres_changes',\n        { event: 'UPDATE', schema: 'public', table: 'posts', filter: `id=eq.${post!.id}` },\n        (payload) => updateEvents.push(payload)\n      )\n      .subscribe();\n\n    channels.push(channel);\n\n    await new Promise((resolve) => setTimeout(resolve, 1000));\n\n    await serviceClient\n      .from('posts')\n      .update({ title: 'After Update' })\n      .eq('id', post!.id);\n\n    await new Promise((resolve) => setTimeout(resolve, 2000));\n\n    expect(updateEvents.length).toBeGreaterThan(0);\n    expect(updateEvents[0].new.title).toBe('After Update');\n    expect(updateEvents[0].old.title).toBe('Before Update');\n  });\n\n  it('should receive DELETE events', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `rt-delete-${Date.now()}`,\n    });\n\n    const { data: post } = await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'To Be Deleted',\n      content: 'Bye',\n      published: true,\n    }).select().single();\n\n    const deleteEvents: any[] = [];\n\n    const channel = client\n      .channel('posts-deletes')\n      .on(\n        'postgres_changes',\n        { event: 'DELETE', schema: 'public', table: 'posts' },\n        (payload) => deleteEvents.push(payload)\n      )\n      .subscribe();\n\n    channels.push(channel);\n\n    await new Promise((resolve) => setTimeout(resolve, 1000));\n\n    await serviceClient.from('posts').delete().eq('id', post!.id);\n\n    await new Promise((resolve) => setTimeout(resolve, 2000));\n\n    expect(deleteEvents.length).toBeGreaterThan(0);\n    expect(deleteEvents[0].old.id).toBe(post!.id);\n  });\n\n  it('should handle channel disconnection gracefully', async () => {\n    const { client } = await users.createUser();\n\n    const channel = client\n      .channel('disconnect-test')\n      .on('postgres_changes', { event: '*', schema: 'public', table: 'posts' }, () => {})\n      .subscribe();\n\n    channels.push(channel);\n\n    await new Promise((resolve) => setTimeout(resolve, 500));\n\n    \u002F\u002F Unsubscribe\n    const status = await channel.unsubscribe();\n    expect(status).toBe('ok');\n  });\n});\n```\n\n## Storage Bucket Testing\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Fstorage.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createServiceClient } from '..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002Fhelpers\u002Ftest-users';\n\ndescribe('Supabase Storage', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(async () => {\n    serviceClient = createServiceClient();\n\n    \u002F\u002F Ensure test bucket exists\n    await serviceClient.storage.createBucket('avatars', {\n      public: false,\n      fileSizeLimit: 1024 * 1024, \u002F\u002F 1MB\n      allowedMimeTypes: ['image\u002Fpng', 'image\u002Fjpeg', 'image\u002Fwebp'],\n    }).catch(() => {}); \u002F\u002F Ignore if already exists\n  });\n\n  afterAll(async () => {\n    await users.cleanup();\n  });\n\n  it('should allow authenticated users to upload to their folder', async () => {\n    const { client, userId } = await users.createUser();\n\n    const file = new Blob(['fake image data'], { type: 'image\u002Fpng' });\n\n    const { data, error } = await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Favatar.png`, file, {\n        contentType: 'image\u002Fpng',\n      });\n\n    expect(error).toBeNull();\n    expect(data!.path).toBe(`${userId}\u002Favatar.png`);\n  });\n\n  it('should prevent users from uploading to other user folders', async () => {\n    const { client } = await users.createUser();\n    const { userId: otherUserId } = await users.createUser();\n\n    const file = new Blob(['fake data'], { type: 'image\u002Fpng' });\n\n    const { error } = await client.storage\n      .from('avatars')\n      .upload(`${otherUserId}\u002Fmalicious.png`, file, {\n        contentType: 'image\u002Fpng',\n      });\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should enforce file size limits', async () => {\n    const { client, userId } = await users.createUser();\n\n    \u002F\u002F Create a file larger than 1MB limit\n    const largeFile = new Blob([new ArrayBuffer(2 * 1024 * 1024)], { type: 'image\u002Fpng' });\n\n    const { error } = await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Ftoo-large.png`, largeFile);\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should enforce allowed MIME types', async () => {\n    const { client, userId } = await users.createUser();\n\n    const file = new Blob(['not an image'], { type: 'application\u002Fpdf' });\n\n    const { error } = await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Fdoc.pdf`, file, {\n        contentType: 'application\u002Fpdf',\n      });\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should generate signed URLs for private files', async () => {\n    const { client, userId } = await users.createUser();\n\n    const file = new Blob(['test data'], { type: 'image\u002Fpng' });\n    await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Fsigned-test.png`, file, { contentType: 'image\u002Fpng' });\n\n    const { data, error } = await client.storage\n      .from('avatars')\n      .createSignedUrl(`${userId}\u002Fsigned-test.png`, 60);\n\n    expect(error).toBeNull();\n    expect(data!.signedUrl).toContain('token=');\n  });\n});\n```\n\n## Edge Function Testing\n\n```typescript\n\u002F\u002F supabase\u002Ffunctions\u002Fhello-world\u002Findex.ts\nimport { serve } from 'https:\u002F\u002Fdeno.land\u002Fstd@0.177.0\u002Fhttp\u002Fserver.ts';\nimport { createClient } from 'https:\u002F\u002Fesm.sh\u002F@supabase\u002Fsupabase-js@2';\n\nserve(async (req) => {\n  try {\n    const { name } = await req.json();\n\n    if (!name) {\n      return new Response(\n        JSON.stringify({ error: 'Name is required' }),\n        { status: 400, headers: { 'Content-Type': 'application\u002Fjson' } }\n      );\n    }\n\n    \u002F\u002F Verify auth\n    const authHeader = req.headers.get('Authorization');\n    if (!authHeader) {\n      return new Response(\n        JSON.stringify({ error: 'Unauthorized' }),\n        { status: 401, headers: { 'Content-Type': 'application\u002Fjson' } }\n      );\n    }\n\n    const supabase = createClient(\n      Deno.env.get('SUPABASE_URL')!,\n      Deno.env.get('SUPABASE_ANON_KEY')!,\n      { global: { headers: { Authorization: authHeader } } }\n    );\n\n    const { data: { user } } = await supabase.auth.getUser();\n\n    return new Response(\n      JSON.stringify({ message: `Hello ${name}!`, userId: user?.id }),\n      { status: 200, headers: { 'Content-Type': 'application\u002Fjson' } }\n    );\n  } catch (error) {\n    return new Response(\n      JSON.stringify({ error: 'Internal error' }),\n      { status: 500, headers: { 'Content-Type': 'application\u002Fjson' } }\n    );\n  }\n});\n```\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Fedge-functions.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createTestUser, cleanupTestUser } from '..\u002Fhelpers\u002Fsupabase-test-utils';\n\nconst FUNCTIONS_URL = 'http:\u002F\u002F127.0.0.1:54321\u002Ffunctions\u002Fv1';\n\ndescribe('Edge Function: hello-world', () => {\n  let accessToken: string;\n  let userId: string;\n\n  beforeAll(async () => {\n    const user = await createTestUser();\n    userId = user.userId;\n\n    const { data } = await user.client.auth.getSession();\n    accessToken = data.session!.access_token;\n  });\n\n  afterAll(async () => {\n    await cleanupTestUser(userId);\n  });\n\n  it('should return greeting with user info', async () => {\n    const response = await fetch(`${FUNCTIONS_URL}\u002Fhello-world`, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application\u002Fjson',\n        Authorization: `Bearer ${accessToken}`,\n      },\n      body: JSON.stringify({ name: 'World' }),\n    });\n\n    expect(response.status).toBe(200);\n    const data = await response.json();\n    expect(data.message).toBe('Hello World!');\n    expect(data.userId).toBe(userId);\n  });\n\n  it('should return 400 when name is missing', async () => {\n    const response = await fetch(`${FUNCTIONS_URL}\u002Fhello-world`, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application\u002Fjson',\n        Authorization: `Bearer ${accessToken}`,\n      },\n      body: JSON.stringify({}),\n    });\n\n    expect(response.status).toBe(400);\n    const data = await response.json();\n    expect(data.error).toBe('Name is required');\n  });\n\n  it('should return 401 without auth header', async () => {\n    const response = await fetch(`${FUNCTIONS_URL}\u002Fhello-world`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application\u002Fjson' },\n      body: JSON.stringify({ name: 'World' }),\n    });\n\n    expect(response.status).toBe(401);\n  });\n});\n```\n\n## Database Migration Testing\n\n```typescript\n\u002F\u002F supabase\u002Ftests\u002Fmigrations\u002Fmigration.test.ts\nimport { describe, it, expect, beforeAll } from 'vitest';\nimport { createServiceClient } from '..\u002F..\u002F__tests__\u002Fhelpers\u002Fsupabase-test-utils';\n\ndescribe('Database Migration Verification', () => {\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(() => {\n    serviceClient = createServiceClient();\n  });\n\n  it('should have profiles table with correct columns', async () => {\n    const { data, error } = await serviceClient.rpc('get_table_columns', {\n      p_table: 'profiles',\n    });\n\n    \u002F\u002F Alternatively, query information_schema directly\n    const { data: columns } = await serviceClient\n      .from('information_schema.columns' as any)\n      .select('column_name, data_type, is_nullable')\n      .eq('table_name', 'profiles')\n      .eq('table_schema', 'public');\n\n    const columnNames = columns!.map((c: any) => c.column_name);\n\n    expect(columnNames).toContain('id');\n    expect(columnNames).toContain('username');\n    expect(columnNames).toContain('bio');\n    expect(columnNames).toContain('avatar_url');\n    expect(columnNames).toContain('is_public');\n    expect(columnNames).toContain('created_at');\n  });\n\n  it('should have RLS enabled on all tables', async () => {\n    const { data: tables } = await serviceClient.rpc('check_rls_enabled');\n\n    \u002F\u002F All public tables should have RLS enabled\n    const publicTables = ['profiles', 'posts', 'comments'];\n    for (const table of publicTables) {\n      const tableInfo = tables?.find((t: any) => t.tablename === table);\n      expect(tableInfo?.rowsecurity, `RLS not enabled on ${table}`).toBe(true);\n    }\n  });\n\n  it('should have correct foreign key relationships', async () => {\n    \u002F\u002F Verify posts.author_id references profiles.id\n    const { data: fks } = await serviceClient\n      .from('information_schema.referential_constraints' as any)\n      .select('constraint_name')\n      .eq('constraint_schema', 'public');\n\n    expect(fks!.length).toBeGreaterThan(0);\n  });\n});\n```\n\n## Best Practices\n\n1. **Always use `supabase start` for local testing** -- Never test against production or staging Supabase instances. Local testing is fast, isolated, and free.\n2. **Test every RLS policy with at least 3 roles** -- For each policy, test as the resource owner, a different authenticated user, and an anonymous user.\n3. **Use the service role client for test setup only** -- Create test data with the service role client, but run actual tests with anon or authenticated clients to verify RLS.\n4. **Clean up test users after each suite** -- Use a TestUserManager that tracks created users and deletes them in afterAll to prevent test database bloat.\n5. **Disable email confirmation for test environments** -- Set `enable_confirmations = false` in the local config to avoid needing to handle email verification in tests.\n6. **Test RLS with both SELECT and the actual operation** -- A user may be able to SELECT a row but not UPDATE or DELETE it. Test each operation independently.\n7. **Verify RLS failures are silent, not errors** -- Supabase RLS violations on UPDATE\u002FDELETE return empty results, not errors. Assert on the returned data being empty.\n8. **Test realtime with proper timeouts** -- Realtime events have latency. Use adequate waits (1-2 seconds) between subscribing and expecting events.\n9. **Use unique identifiers in test data** -- Include timestamps or random strings in test usernames and emails to prevent collisions between parallel test runs.\n10. **Test storage policies separately from application logic** -- Storage bucket policies are independent of table RLS. Write dedicated storage tests.\n\n## Anti-Patterns to Avoid\n\n1. **Testing against production Supabase** -- Production testing creates real data, costs money, and risks exposing test users. Always use local instances.\n2. **Using the service role client in application tests** -- The service role bypasses RLS entirely. If your tests use it for data access, they cannot verify security policies.\n3. **Not testing RLS at all** -- Many teams skip RLS testing because it requires user management. This is the most critical security boundary in a Supabase app.\n4. **Sharing test users between test files** -- Parallel test execution with shared users causes race conditions. Each test file should create its own users.\n5. **Testing only SELECT policies** -- INSERT, UPDATE, and DELETE policies have different USING and WITH CHECK clauses. Test each operation type.\n6. **Ignoring the difference between USING and WITH CHECK** -- USING filters rows you can see, WITH CHECK validates the new row on INSERT\u002FUPDATE. Both need testing.\n7. **Hardcoding Supabase keys in test files** -- Use environment variables or read from the local Supabase config. Hardcoded keys get committed to version control.\n8. **Not testing auth edge cases** -- Token expiry, session refresh, and concurrent sessions are common sources of production bugs. Test these flows.\n9. **Skipping migration rollback tests** -- Only testing the `up` migration is not enough. Verify that `down` migrations cleanly reverse schema changes.\n10. **Testing realtime without actually subscribing** -- Mocking the realtime client misses connection issues, reconnection logic, and message ordering problems.\n\n## Running Tests\n\n- Start local Supabase: `supabase start`\n- Run all tests: `pnpm vitest run`\n- Run RLS tests: `pnpm vitest run __tests__\u002Fintegration\u002Frls`\n- Run auth tests: `pnpm vitest run __tests__\u002Fintegration\u002Fauth-flow.test.ts`\n- Run realtime tests: `pnpm vitest run __tests__\u002Fintegration\u002Frealtime.test.ts`\n- Run edge function tests: `supabase functions serve && pnpm vitest run __tests__\u002Fintegration\u002Fedge-functions.test.ts`\n- Reset local database: `supabase db reset`\n- View local Supabase dashboard: `open http:\u002F\u002F127.0.0.1:54323`\n- Stop local Supabase: `supabase stop`\n","# Supabase Testing Skill\n\nYou are an expert QA engineer specializing in testing Supabase-powered applications. When the user asks you to write, review, or debug tests for Supabase auth, Row Level Security, realtime subscriptions, edge functions, or storage, follow these detailed instructions.\n\n## Core Principles\n\n1. **Local-first testing** -- Always use Supabase CLI (`supabase start`) to run a local Postgres instance with all Supabase features. Never test directly against production.\n2. **RLS is your security boundary** -- Row Level Security policies are the most critical code in a Supabase app. Test every policy with multiple user roles and edge cases.\n3. **Test auth flows end-to-end** -- Supabase auth involves email confirmation, magic links, OAuth redirects, and JWT tokens. Test the full flow, not just the API call.\n4. **Realtime requires connection testing** -- Subscription tests must establish actual WebSocket connections. Mock-only tests miss critical reconnection and conflict scenarios.\n5. **Edge functions are isolated** -- Supabase Edge Functions run in Deno. Test them independently with their own test runner before integration testing.\n6. **Storage policies mirror RLS** -- Storage bucket policies follow the same RLS pattern. Apply the same testing rigor to file access as to row access.\n7. **Migration testing prevents data loss** -- Every schema migration should be tested against a snapshot of production-like data to verify both the up and down paths.\n\n## Project Structure\n\nAlways organize Supabase testing with this structure:\n\n```\nsupabase\u002F\n  config.toml\n  migrations\u002F\n    20240101000000_create_profiles.sql\n    20240102000000_add_rls_policies.sql\n  functions\u002F\n    hello-world\u002F\n      index.ts\n    send-notification\u002F\n      index.ts\n  seed.sql\n  tests\u002F\n    rls\u002F\n      profiles.test.ts\n      posts.test.ts\n      comments.test.ts\n    migrations\u002F\n      migration.test.ts\nsrc\u002F\n  lib\u002F\n    supabase\u002F\n      client.ts\n      server.ts\n      middleware.ts\n  __tests__\u002F\n    unit\u002F\n      auth.test.ts\n      database.test.ts\n    integration\u002F\n      auth-flow.test.ts\n      realtime.test.ts\n      storage.test.ts\n    e2e\u002F\n      signup-login.spec.ts\n      crud-with-rls.spec.ts\n    helpers\u002F\n      supabase-test-utils.ts\n      test-users.ts\n      seed-test-data.ts\n```\n\n## Supabase Local Setup for Testing\n\n### Configuration\n\n```toml\n# supabase\u002Fconfig.toml\n[project]\nid = \"my-project\"\n\n[db]\nport = 54322\n\n[auth]\nsite_url = \"http:\u002F\u002Flocalhost:3000\"\nenable_signup = true\n\n[auth.email]\nenable_confirmations = false  # Disable for testing\ndouble_confirm_changes = false\n\n[auth.external.google]\nenabled = false\n```\n\n### Test Helper Setup\n\n```typescript\n\u002F\u002F __tests__\u002Fhelpers\u002Fsupabase-test-utils.ts\nimport { createClient, SupabaseClient } from '@supabase\u002Fsupabase-js';\n\nconst SUPABASE_URL = process.env.SUPABASE_URL || 'http:\u002F\u002F127.0.0.1:54321';\nconst SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';\nconst SUPABASE_SERVICE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';\n\n\u002F\u002F Anon client (respects RLS)\nexport function createAnonClient(): SupabaseClient {\n  return createClient(SUPABASE_URL, SUPABASE_ANON_KEY);\n}\n\n\u002F\u002F Service role client (bypasses RLS)\nexport function createServiceClient(): SupabaseClient {\n  return createClient(SUPABASE_URL, SUPABASE_SERVICE_KEY);\n}\n\n\u002F\u002F Authenticated client for a specific user\nexport async function createAuthenticatedClient(\n  email: string,\n  password: string\n): Promise\u003CSupabaseClient> {\n  const client = createAnonClient();\n  const { error } = await client.auth.signInWithPassword({ email, password });\n  if (error) throw new Error(`Auth failed for ${email}: ${error.message}`);\n  return client;\n}\n\n\u002F\u002F Create a test user and return authenticated client\nexport async function createTestUser(\n  email?: string,\n  password?: string,\n  metadata?: Record\u003Cstring, unknown>\n): Promise\u003C{ client: SupabaseClient; userId: string; email: string }> {\n  const testEmail = email || `test-${Date.now()}-${Math.random().toString(36).slice(2)}@test.com`;\n  const testPassword = password || 'TestPassword123!';\n\n  const serviceClient = createServiceClient();\n\n  \u002F\u002F Create user via service role (bypasses email confirmation)\n  const { data: user, error } = await serviceClient.auth.admin.createUser({\n    email: testEmail,\n    password: testPassword,\n    email_confirm: true,\n    user_metadata: metadata || {},\n  });\n\n  if (error) throw new Error(`Failed to create test user: ${error.message}`);\n\n  const client = await createAuthenticatedClient(testEmail, testPassword);\n\n  return {\n    client,\n    userId: user.user.id,\n    email: testEmail,\n  };\n}\n\n\u002F\u002F Cleanup test data\nexport async function cleanupTestUser(userId: string): Promise\u003Cvoid> {\n  const serviceClient = createServiceClient();\n  await serviceClient.auth.admin.deleteUser(userId);\n}\n\n\u002F\u002F Reset database to clean state\nexport async function resetDatabase(): Promise\u003Cvoid> {\n  const serviceClient = createServiceClient();\n\n  \u002F\u002F Delete all non-system data in reverse dependency order\n  await serviceClient.from('comments').delete().neq('id', '00000000-0000-0000-0000-000000000000');\n  await serviceClient.from('posts').delete().neq('id', '00000000-0000-0000-0000-000000000000');\n  await serviceClient.from('profiles').delete().neq('id', '00000000-0000-0000-0000-000000000000');\n}\n```\n\n```typescript\n\u002F\u002F __tests__\u002Fhelpers\u002Ftest-users.ts\nimport { createTestUser, cleanupTestUser } from '.\u002Fsupabase-test-utils';\nimport type { SupabaseClient } from '@supabase\u002Fsupabase-js';\n\ninterface TestUserContext {\n  client: SupabaseClient;\n  userId: string;\n  email: string;\n}\n\nexport class TestUserManager {\n  private users: TestUserContext[] = [];\n\n  async createUser(\n    role: string = 'user',\n    metadata: Record\u003Cstring, unknown> = {}\n  ): Promise\u003CTestUserContext> {\n    const user = await createTestUser(undefined, undefined, { role, ...metadata });\n    this.users.push(user);\n    return user;\n  }\n\n  async createAdmin(): Promise\u003CTestUserContext> {\n    return this.createUser('admin');\n  }\n\n  async createModerator(): Promise\u003CTestUserContext> {\n    return this.createUser('moderator');\n  }\n\n  async cleanup(): Promise\u003Cvoid> {\n    for (const user of this.users) {\n      await cleanupTestUser(user.userId).catch(() => {});\n    }\n    this.users = [];\n  }\n}\n```\n\n## Row Level Security (RLS) Testing\n\n### Schema and Policies\n\n```sql\n-- supabase\u002Fmigrations\u002F20240101000000_create_profiles.sql\nCREATE TABLE profiles (\n  id UUID REFERENCES auth.users(id) ON DELETE CASCADE PRIMARY KEY,\n  username TEXT UNIQUE NOT NULL,\n  bio TEXT,\n  avatar_url TEXT,\n  is_public BOOLEAN DEFAULT true,\n  created_at TIMESTAMPTZ DEFAULT now(),\n  updated_at TIMESTAMPTZ DEFAULT now()\n);\n\nALTER TABLE profiles ENABLE ROW LEVEL SECURITY;\n\n-- Anyone can view public profiles\nCREATE POLICY \"Public profiles are viewable by everyone\"\n  ON profiles FOR SELECT\n  USING (is_public = true);\n\n-- Users can view their own profile (even if private)\nCREATE POLICY \"Users can view own profile\"\n  ON profiles FOR SELECT\n  USING (auth.uid() = id);\n\n-- Users can update only their own profile\nCREATE POLICY \"Users can update own profile\"\n  ON profiles FOR UPDATE\n  USING (auth.uid() = id)\n  WITH CHECK (auth.uid() = id);\n\n-- Users can insert their own profile\nCREATE POLICY \"Users can insert own profile\"\n  ON profiles FOR INSERT\n  WITH CHECK (auth.uid() = id);\n\n-- Only admins can delete profiles\nCREATE POLICY \"Admins can delete profiles\"\n  ON profiles FOR DELETE\n  USING (\n    EXISTS (\n      SELECT 1 FROM profiles\n      WHERE id = auth.uid()\n      AND (auth.jwt() -> 'user_metadata' ->> 'role') = 'admin'\n    )\n  );\n```\n\n```sql\n-- supabase\u002Fmigrations\u002F20240102000000_create_posts.sql\nCREATE TABLE posts (\n  id UUID DEFAULT gen_random_uuid() PRIMARY KEY,\n  author_id UUID REFERENCES profiles(id) ON DELETE CASCADE NOT NULL,\n  title TEXT NOT NULL,\n  content TEXT NOT NULL,\n  published BOOLEAN DEFAULT false,\n  created_at TIMESTAMPTZ DEFAULT now(),\n  updated_at TIMESTAMPTZ DEFAULT now()\n);\n\nALTER TABLE posts ENABLE ROW LEVEL SECURITY;\n\n-- Anyone can view published posts\nCREATE POLICY \"Published posts are viewable by everyone\"\n  ON posts FOR SELECT\n  USING (published = true);\n\n-- Authors can view their own drafts\nCREATE POLICY \"Authors can view own drafts\"\n  ON posts FOR SELECT\n  USING (auth.uid() = author_id);\n\n-- Authenticated users can create posts\nCREATE POLICY \"Authenticated users can create posts\"\n  ON posts FOR INSERT\n  WITH CHECK (auth.uid() = author_id);\n\n-- Authors can update their own posts\nCREATE POLICY \"Authors can update own posts\"\n  ON posts FOR UPDATE\n  USING (auth.uid() = author_id)\n  WITH CHECK (auth.uid() = author_id);\n\n-- Authors can delete their own posts\nCREATE POLICY \"Authors can delete own posts\"\n  ON posts FOR DELETE\n  USING (auth.uid() = author_id);\n```\n\n### RLS Policy Tests\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Frls\u002Fprofiles.test.ts\nimport { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest';\nimport {\n  createAnonClient,\n  createServiceClient,\n  resetDatabase,\n} from '..\u002F..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002F..\u002Fhelpers\u002Ftest-users';\n\ndescribe('Profiles RLS Policies', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(async () => {\n    serviceClient = createServiceClient();\n  });\n\n  afterAll(async () => {\n    await users.cleanup();\n  });\n\n  beforeEach(async () => {\n    await resetDatabase();\n  });\n\n  describe('SELECT policies', () => {\n    it('should allow anyone to view public profiles', async () => {\n      const { userId } = await users.createUser();\n\n      \u002F\u002F Create a public profile via service role\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: 'publicuser',\n        bio: 'Public bio',\n        is_public: true,\n      });\n\n      \u002F\u002F Anonymous client should see the profile\n      const anonClient = createAnonClient();\n      const { data, error } = await anonClient\n        .from('profiles')\n        .select('*')\n        .eq('id', userId)\n        .single();\n\n      expect(error).toBeNull();\n      expect(data).toBeDefined();\n      expect(data!.username).toBe('publicuser');\n    });\n\n    it('should hide private profiles from anonymous users', async () => {\n      const { userId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: 'privateuser',\n        bio: 'Private bio',\n        is_public: false,\n      });\n\n      const anonClient = createAnonClient();\n      const { data } = await anonClient\n        .from('profiles')\n        .select('*')\n        .eq('id', userId);\n\n      expect(data).toEqual([]);\n    });\n\n    it('should allow users to view their own private profile', async () => {\n      const { client, userId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: 'myprofile',\n        bio: 'My private bio',\n        is_public: false,\n      });\n\n      const { data, error } = await client\n        .from('profiles')\n        .select('*')\n        .eq('id', userId)\n        .single();\n\n      expect(error).toBeNull();\n      expect(data!.username).toBe('myprofile');\n    });\n\n    it('should hide private profiles from other authenticated users', async () => {\n      const { userId: ownerId } = await users.createUser();\n      const { client: otherClient } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: ownerId,\n        username: 'secretuser',\n        is_public: false,\n      });\n\n      const { data } = await otherClient\n        .from('profiles')\n        .select('*')\n        .eq('id', ownerId);\n\n      expect(data).toEqual([]);\n    });\n  });\n\n  describe('INSERT policies', () => {\n    it('should allow users to create their own profile', async () => {\n      const { client, userId } = await users.createUser();\n\n      const { error } = await client.from('profiles').insert({\n        id: userId,\n        username: `user-${Date.now()}`,\n        bio: 'My bio',\n      });\n\n      expect(error).toBeNull();\n    });\n\n    it('should prevent users from creating profiles for other users', async () => {\n      const { client } = await users.createUser();\n      const { userId: otherUserId } = await users.createUser();\n\n      const { error } = await client.from('profiles').insert({\n        id: otherUserId,\n        username: 'impersonator',\n      });\n\n      expect(error).not.toBeNull();\n      expect(error!.code).toBe('42501'); \u002F\u002F RLS violation\n    });\n\n    it('should prevent anonymous users from creating profiles', async () => {\n      const anonClient = createAnonClient();\n\n      const { error } = await anonClient.from('profiles').insert({\n        id: '550e8400-e29b-41d4-a716-446655440000',\n        username: 'anonymous',\n      });\n\n      expect(error).not.toBeNull();\n    });\n  });\n\n  describe('UPDATE policies', () => {\n    it('should allow users to update their own profile', async () => {\n      const { client, userId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: userId,\n        username: `user-${Date.now()}`,\n        bio: 'Original bio',\n      });\n\n      const { error } = await client\n        .from('profiles')\n        .update({ bio: 'Updated bio' })\n        .eq('id', userId);\n\n      expect(error).toBeNull();\n\n      const { data } = await client\n        .from('profiles')\n        .select('bio')\n        .eq('id', userId)\n        .single();\n\n      expect(data!.bio).toBe('Updated bio');\n    });\n\n    it('should prevent users from updating other profiles', async () => {\n      const { userId: ownerId } = await users.createUser();\n      const { client: attackerClient } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: ownerId,\n        username: `target-${Date.now()}`,\n        bio: 'Original',\n      });\n\n      const { data } = await attackerClient\n        .from('profiles')\n        .update({ bio: 'Hacked!' })\n        .eq('id', ownerId)\n        .select();\n\n      \u002F\u002F RLS silently filters -- no rows affected\n      expect(data).toEqual([]);\n\n      \u002F\u002F Verify original is unchanged\n      const { data: original } = await serviceClient\n        .from('profiles')\n        .select('bio')\n        .eq('id', ownerId)\n        .single();\n\n      expect(original!.bio).toBe('Original');\n    });\n  });\n\n  describe('DELETE policies', () => {\n    it('should allow admins to delete profiles', async () => {\n      const { client: adminClient } = await users.createAdmin();\n      const { userId: targetId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: targetId,\n        username: `delete-target-${Date.now()}`,\n      });\n\n      \u002F\u002F Admin needs their own profile for the policy check\n      const adminUserId = (await adminClient.auth.getUser()).data.user!.id;\n      await serviceClient.from('profiles').insert({\n        id: adminUserId,\n        username: `admin-${Date.now()}`,\n      });\n\n      const { error } = await adminClient\n        .from('profiles')\n        .delete()\n        .eq('id', targetId);\n\n      expect(error).toBeNull();\n    });\n\n    it('should prevent non-admin users from deleting profiles', async () => {\n      const { client: regularClient } = await users.createUser();\n      const { userId: targetId } = await users.createUser();\n\n      await serviceClient.from('profiles').insert({\n        id: targetId,\n        username: `no-delete-${Date.now()}`,\n      });\n\n      const { data } = await regularClient\n        .from('profiles')\n        .delete()\n        .eq('id', targetId)\n        .select();\n\n      \u002F\u002F Should not delete anything\n      expect(data).toEqual([]);\n    });\n  });\n});\n```\n\n### Posts RLS Tests\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Frls\u002Fposts.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport {\n  createAnonClient,\n  createServiceClient,\n} from '..\u002F..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002F..\u002Fhelpers\u002Ftest-users';\n\ndescribe('Posts RLS Policies', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(() => {\n    serviceClient = createServiceClient();\n  });\n\n  afterAll(async () => {\n    await users.cleanup();\n  });\n\n  it('should allow anyone to see published posts', async () => {\n    const { userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `author-${Date.now()}`,\n    });\n\n    await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Published Post',\n      content: 'This is public',\n      published: true,\n    });\n\n    const anonClient = createAnonClient();\n    const { data } = await anonClient\n      .from('posts')\n      .select('*')\n      .eq('published', true);\n\n    expect(data!.length).toBeGreaterThan(0);\n    expect(data!.some((p) => p.title === 'Published Post')).toBe(true);\n  });\n\n  it('should hide draft posts from anonymous users', async () => {\n    const { userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `draft-author-${Date.now()}`,\n    });\n\n    const { data: insertedPost } = await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Secret Draft',\n      content: 'Not published',\n      published: false,\n    }).select().single();\n\n    const anonClient = createAnonClient();\n    const { data } = await anonClient\n      .from('posts')\n      .select('*')\n      .eq('id', insertedPost!.id);\n\n    expect(data).toEqual([]);\n  });\n\n  it('should allow authors to see their own drafts', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `my-draft-author-${Date.now()}`,\n    });\n\n    await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'My Draft',\n      content: 'Work in progress',\n      published: false,\n    });\n\n    const { data } = await client\n      .from('posts')\n      .select('*')\n      .eq('author_id', userId)\n      .eq('published', false);\n\n    expect(data!.length).toBeGreaterThan(0);\n    expect(data![0].title).toBe('My Draft');\n  });\n\n  it('should prevent users from creating posts as another author', async () => {\n    const { client } = await users.createUser();\n    const { userId: otherUserId } = await users.createUser();\n\n    const { error } = await client.from('posts').insert({\n      author_id: otherUserId,\n      title: 'Impersonation Post',\n      content: 'Not my account',\n    });\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should prevent users from updating other authors posts', async () => {\n    const { userId: authorId } = await users.createUser();\n    const { client: attackerClient } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: authorId,\n      username: `update-target-${Date.now()}`,\n    });\n\n    const { data: post } = await serviceClient.from('posts').insert({\n      author_id: authorId,\n      title: 'Original Title',\n      content: 'Original content',\n      published: true,\n    }).select().single();\n\n    const { data } = await attackerClient\n      .from('posts')\n      .update({ title: 'Hacked Title' })\n      .eq('id', post!.id)\n      .select();\n\n    expect(data).toEqual([]);\n  });\n});\n```\n\n## Auth Flow Testing\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Fauth-flow.test.ts\nimport { describe, it, expect, afterAll } from 'vitest';\nimport { createAnonClient, createServiceClient } from '..\u002Fhelpers\u002Fsupabase-test-utils';\n\ndescribe('Supabase Auth Flows', () => {\n  const createdUserIds: string[] = [];\n\n  afterAll(async () => {\n    const serviceClient = createServiceClient();\n    for (const id of createdUserIds) {\n      await serviceClient.auth.admin.deleteUser(id).catch(() => {});\n    }\n  });\n\n  describe('Email\u002FPassword Sign Up', () => {\n    it('should sign up a new user with email and password', async () => {\n      const client = createAnonClient();\n      const email = `signup-${Date.now()}@test.com`;\n\n      const { data, error } = await client.auth.signUp({\n        email,\n        password: 'TestPassword123!',\n      });\n\n      expect(error).toBeNull();\n      expect(data.user).toBeDefined();\n      expect(data.user!.email).toBe(email);\n      createdUserIds.push(data.user!.id);\n    });\n\n    it('should reject signup with weak password', async () => {\n      const client = createAnonClient();\n\n      const { error } = await client.auth.signUp({\n        email: `weak-${Date.now()}@test.com`,\n        password: '123',\n      });\n\n      expect(error).not.toBeNull();\n    });\n\n    it('should reject duplicate email signup', async () => {\n      const client = createAnonClient();\n      const email = `dup-${Date.now()}@test.com`;\n\n      \u002F\u002F First signup\n      const { data } = await client.auth.signUp({\n        email,\n        password: 'TestPassword123!',\n      });\n      createdUserIds.push(data.user!.id);\n\n      \u002F\u002F Second signup with same email\n      const { data: dup, error } = await client.auth.signUp({\n        email,\n        password: 'AnotherPassword123!',\n      });\n\n      \u002F\u002F Supabase returns a fake user for security (no error), but no session\n      expect(dup.session).toBeNull();\n    });\n  });\n\n  describe('Email\u002FPassword Sign In', () => {\n    it('should sign in with correct credentials', async () => {\n      const serviceClient = createServiceClient();\n      const email = `signin-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      const { data, error } = await client.auth.signInWithPassword({\n        email,\n        password: 'TestPassword123!',\n      });\n\n      expect(error).toBeNull();\n      expect(data.session).toBeDefined();\n      expect(data.session!.access_token).toBeDefined();\n      expect(data.user!.email).toBe(email);\n    });\n\n    it('should reject incorrect password', async () => {\n      const serviceClient = createServiceClient();\n      const email = `wrongpw-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'CorrectPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      const { error } = await client.auth.signInWithPassword({\n        email,\n        password: 'WrongPassword123!',\n      });\n\n      expect(error).not.toBeNull();\n      expect(error!.message).toContain('Invalid login credentials');\n    });\n\n    it('should reject non-existent email', async () => {\n      const client = createAnonClient();\n\n      const { error } = await client.auth.signInWithPassword({\n        email: 'doesnotexist@test.com',\n        password: 'TestPassword123!',\n      });\n\n      expect(error).not.toBeNull();\n    });\n  });\n\n  describe('Session Management', () => {\n    it('should return a valid session after sign in', async () => {\n      const serviceClient = createServiceClient();\n      const email = `session-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      const { data: sessionData } = await client.auth.getSession();\n      expect(sessionData.session).not.toBeNull();\n      expect(sessionData.session!.expires_at).toBeDefined();\n    });\n\n    it('should sign out and invalidate session', async () => {\n      const serviceClient = createServiceClient();\n      const email = `signout-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      const { error } = await client.auth.signOut();\n      expect(error).toBeNull();\n\n      const { data } = await client.auth.getSession();\n      expect(data.session).toBeNull();\n    });\n  });\n\n  describe('User Metadata', () => {\n    it('should store and retrieve user metadata', async () => {\n      const serviceClient = createServiceClient();\n      const email = `meta-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n        user_metadata: { role: 'editor', displayName: 'Test Editor' },\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      const { data } = await client.auth.getUser();\n      expect(data.user!.user_metadata.role).toBe('editor');\n      expect(data.user!.user_metadata.displayName).toBe('Test Editor');\n    });\n\n    it('should update user metadata', async () => {\n      const serviceClient = createServiceClient();\n      const email = `update-meta-${Date.now()}@test.com`;\n\n      const { data: created } = await serviceClient.auth.admin.createUser({\n        email,\n        password: 'TestPassword123!',\n        email_confirm: true,\n        user_metadata: { displayName: 'Original' },\n      });\n      createdUserIds.push(created.user.id);\n\n      const client = createAnonClient();\n      await client.auth.signInWithPassword({ email, password: 'TestPassword123!' });\n\n      await client.auth.updateUser({\n        data: { displayName: 'Updated' },\n      });\n\n      const { data } = await client.auth.getUser();\n      expect(data.user!.user_metadata.displayName).toBe('Updated');\n    });\n  });\n});\n```\n\n## Realtime Subscription Testing\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Frealtime.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createServiceClient } from '..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002Fhelpers\u002Ftest-users';\nimport type { RealtimeChannel } from '@supabase\u002Fsupabase-js';\n\ndescribe('Supabase Realtime Subscriptions', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n  const channels: RealtimeChannel[] = [];\n\n  beforeAll(() => {\n    serviceClient = createServiceClient();\n  });\n\n  afterAll(async () => {\n    \u002F\u002F Unsubscribe all channels\n    for (const channel of channels) {\n      await channel.unsubscribe();\n    }\n    await users.cleanup();\n  });\n\n  it('should receive INSERT events on subscribed table', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `realtime-${Date.now()}`,\n    });\n\n    const receivedEvents: any[] = [];\n\n    const channel = client\n      .channel('posts-inserts')\n      .on(\n        'postgres_changes',\n        { event: 'INSERT', schema: 'public', table: 'posts' },\n        (payload) => receivedEvents.push(payload)\n      )\n      .subscribe();\n\n    channels.push(channel);\n\n    \u002F\u002F Wait for subscription to be established\n    await new Promise((resolve) => setTimeout(resolve, 1000));\n\n    \u002F\u002F Insert a post via service client\n    await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Realtime Test Post',\n      content: 'Testing realtime',\n      published: true,\n    });\n\n    \u002F\u002F Wait for the event to arrive\n    await new Promise((resolve) => setTimeout(resolve, 2000));\n\n    expect(receivedEvents.length).toBeGreaterThan(0);\n    expect(receivedEvents[0].new.title).toBe('Realtime Test Post');\n    expect(receivedEvents[0].eventType).toBe('INSERT');\n  });\n\n  it('should receive UPDATE events', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `rt-update-${Date.now()}`,\n    });\n\n    const { data: post } = await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'Before Update',\n      content: 'Original',\n      published: true,\n    }).select().single();\n\n    const updateEvents: any[] = [];\n\n    const channel = client\n      .channel('posts-updates')\n      .on(\n        'postgres_changes',\n        { event: 'UPDATE', schema: 'public', table: 'posts', filter: `id=eq.${post!.id}` },\n        (payload) => updateEvents.push(payload)\n      )\n      .subscribe();\n\n    channels.push(channel);\n\n    await new Promise((resolve) => setTimeout(resolve, 1000));\n\n    await serviceClient\n      .from('posts')\n      .update({ title: 'After Update' })\n      .eq('id', post!.id);\n\n    await new Promise((resolve) => setTimeout(resolve, 2000));\n\n    expect(updateEvents.length).toBeGreaterThan(0);\n    expect(updateEvents[0].new.title).toBe('After Update');\n    expect(updateEvents[0].old.title).toBe('Before Update');\n  });\n\n  it('should receive DELETE events', async () => {\n    const { client, userId } = await users.createUser();\n\n    await serviceClient.from('profiles').insert({\n      id: userId,\n      username: `rt-delete-${Date.now()}`,\n    });\n\n    const { data: post } = await serviceClient.from('posts').insert({\n      author_id: userId,\n      title: 'To Be Deleted',\n      content: 'Bye',\n      published: true,\n    }).select().single();\n\n    const deleteEvents: any[] = [];\n\n    const channel = client\n      .channel('posts-deletes')\n      .on(\n        'postgres_changes',\n        { event: 'DELETE', schema: 'public', table: 'posts' },\n        (payload) => deleteEvents.push(payload)\n      )\n      .subscribe();\n\n    channels.push(channel);\n\n    await new Promise((resolve) => setTimeout(resolve, 1000));\n\n    await serviceClient.from('posts').delete().eq('id', post!.id);\n\n    await new Promise((resolve) => setTimeout(resolve, 2000));\n\n    expect(deleteEvents.length).toBeGreaterThan(0);\n    expect(deleteEvents[0].old.id).toBe(post!.id);\n  });\n\n  it('should handle channel disconnection gracefully', async () => {\n    const { client } = await users.createUser();\n\n    const channel = client\n      .channel('disconnect-test')\n      .on('postgres_changes', { event: '*', schema: 'public', table: 'posts' }, () => {})\n      .subscribe();\n\n    channels.push(channel);\n\n    await new Promise((resolve) => setTimeout(resolve, 500));\n\n    \u002F\u002F Unsubscribe\n    const status = await channel.unsubscribe();\n    expect(status).toBe('ok');\n  });\n});\n```\n\n## Storage Bucket Testing\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Fstorage.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createServiceClient } from '..\u002Fhelpers\u002Fsupabase-test-utils';\nimport { TestUserManager } from '..\u002Fhelpers\u002Ftest-users';\n\ndescribe('Supabase Storage', () => {\n  const users = new TestUserManager();\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(async () => {\n    serviceClient = createServiceClient();\n\n    \u002F\u002F Ensure test bucket exists\n    await serviceClient.storage.createBucket('avatars', {\n      public: false,\n      fileSizeLimit: 1024 * 1024, \u002F\u002F 1MB\n      allowedMimeTypes: ['image\u002Fpng', 'image\u002Fjpeg', 'image\u002Fwebp'],\n    }).catch(() => {}); \u002F\u002F Ignore if already exists\n  });\n\n  afterAll(async () => {\n    await users.cleanup();\n  });\n\n  it('should allow authenticated users to upload to their folder', async () => {\n    const { client, userId } = await users.createUser();\n\n    const file = new Blob(['fake image data'], { type: 'image\u002Fpng' });\n\n    const { data, error } = await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Favatar.png`, file, {\n        contentType: 'image\u002Fpng',\n      });\n\n    expect(error).toBeNull();\n    expect(data!.path).toBe(`${userId}\u002Favatar.png`);\n  });\n\n  it('should prevent users from uploading to other user folders', async () => {\n    const { client } = await users.createUser();\n    const { userId: otherUserId } = await users.createUser();\n\n    const file = new Blob(['fake data'], { type: 'image\u002Fpng' });\n\n    const { error } = await client.storage\n      .from('avatars')\n      .upload(`${otherUserId}\u002Fmalicious.png`, file, {\n        contentType: 'image\u002Fpng',\n      });\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should enforce file size limits', async () => {\n    const { client, userId } = await users.createUser();\n\n    \u002F\u002F Create a file larger than 1MB limit\n    const largeFile = new Blob([new ArrayBuffer(2 * 1024 * 1024)], { type: 'image\u002Fpng' });\n\n    const { error } = await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Ftoo-large.png`, largeFile);\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should enforce allowed MIME types', async () => {\n    const { client, userId } = await users.createUser();\n\n    const file = new Blob(['not an image'], { type: 'application\u002Fpdf' });\n\n    const { error } = await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Fdoc.pdf`, file, {\n        contentType: 'application\u002Fpdf',\n      });\n\n    expect(error).not.toBeNull();\n  });\n\n  it('should generate signed URLs for private files', async () => {\n    const { client, userId } = await users.createUser();\n\n    const file = new Blob(['test data'], { type: 'image\u002Fpng' });\n    await client.storage\n      .from('avatars')\n      .upload(`${userId}\u002Fsigned-test.png`, file, { contentType: 'image\u002Fpng' });\n\n    const { data, error } = await client.storage\n      .from('avatars')\n      .createSignedUrl(`${userId}\u002Fsigned-test.png`, 60);\n\n    expect(error).toBeNull();\n    expect(data!.signedUrl).toContain('token=');\n  });\n});\n```\n\n## Edge Function Testing\n\n```typescript\n\u002F\u002F supabase\u002Ffunctions\u002Fhello-world\u002Findex.ts\nimport { serve } from 'https:\u002F\u002Fdeno.land\u002Fstd@0.177.0\u002Fhttp\u002Fserver.ts';\nimport { createClient } from 'https:\u002F\u002Fesm.sh\u002F@supabase\u002Fsupabase-js@2';\n\nserve(async (req) => {\n  try {\n    const { name } = await req.json();\n\n    if (!name) {\n      return new Response(\n        JSON.stringify({ error: 'Name is required' }),\n        { status: 400, headers: { 'Content-Type': 'application\u002Fjson' } }\n      );\n    }\n\n    \u002F\u002F Verify auth\n    const authHeader = req.headers.get('Authorization');\n    if (!authHeader) {\n      return new Response(\n        JSON.stringify({ error: 'Unauthorized' }),\n        { status: 401, headers: { 'Content-Type': 'application\u002Fjson' } }\n      );\n    }\n\n    const supabase = createClient(\n      Deno.env.get('SUPABASE_URL')!,\n      Deno.env.get('SUPABASE_ANON_KEY')!,\n      { global: { headers: { Authorization: authHeader } } }\n    );\n\n    const { data: { user } } = await supabase.auth.getUser();\n\n    return new Response(\n      JSON.stringify({ message: `Hello ${name}!`, userId: user?.id }),\n      { status: 200, headers: { 'Content-Type': 'application\u002Fjson' } }\n    );\n  } catch (error) {\n    return new Response(\n      JSON.stringify({ error: 'Internal error' }),\n      { status: 500, headers: { 'Content-Type': 'application\u002Fjson' } }\n    );\n  }\n});\n```\n\n```typescript\n\u002F\u002F __tests__\u002Fintegration\u002Fedge-functions.test.ts\nimport { describe, it, expect, beforeAll, afterAll } from 'vitest';\nimport { createTestUser, cleanupTestUser } from '..\u002Fhelpers\u002Fsupabase-test-utils';\n\nconst FUNCTIONS_URL = 'http:\u002F\u002F127.0.0.1:54321\u002Ffunctions\u002Fv1';\n\ndescribe('Edge Function: hello-world', () => {\n  let accessToken: string;\n  let userId: string;\n\n  beforeAll(async () => {\n    const user = await createTestUser();\n    userId = user.userId;\n\n    const { data } = await user.client.auth.getSession();\n    accessToken = data.session!.access_token;\n  });\n\n  afterAll(async () => {\n    await cleanupTestUser(userId);\n  });\n\n  it('should return greeting with user info', async () => {\n    const response = await fetch(`${FUNCTIONS_URL}\u002Fhello-world`, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application\u002Fjson',\n        Authorization: `Bearer ${accessToken}`,\n      },\n      body: JSON.stringify({ name: 'World' }),\n    });\n\n    expect(response.status).toBe(200);\n    const data = await response.json();\n    expect(data.message).toBe('Hello World!');\n    expect(data.userId).toBe(userId);\n  });\n\n  it('should return 400 when name is missing', async () => {\n    const response = await fetch(`${FUNCTIONS_URL}\u002Fhello-world`, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application\u002Fjson',\n        Authorization: `Bearer ${accessToken}`,\n      },\n      body: JSON.stringify({}),\n    });\n\n    expect(response.status).toBe(400);\n    const data = await response.json();\n    expect(data.error).toBe('Name is required');\n  });\n\n  it('should return 401 without auth header', async () => {\n    const response = await fetch(`${FUNCTIONS_URL}\u002Fhello-world`, {\n      method: 'POST',\n      headers: { 'Content-Type': 'application\u002Fjson' },\n      body: JSON.stringify({ name: 'World' }),\n    });\n\n    expect(response.status).toBe(401);\n  });\n});\n```\n\n## Database Migration Testing\n\n```typescript\n\u002F\u002F supabase\u002Ftests\u002Fmigrations\u002Fmigration.test.ts\nimport { describe, it, expect, beforeAll } from 'vitest';\nimport { createServiceClient } from '..\u002F..\u002F__tests__\u002Fhelpers\u002Fsupabase-test-utils';\n\ndescribe('Database Migration Verification', () => {\n  let serviceClient: ReturnType\u003Ctypeof createServiceClient>;\n\n  beforeAll(() => {\n    serviceClient = createServiceClient();\n  });\n\n  it('should have profiles table with correct columns', async () => {\n    const { data, error } = await serviceClient.rpc('get_table_columns', {\n      p_table: 'profiles',\n    });\n\n    \u002F\u002F Alternatively, query information_schema directly\n    const { data: columns } = await serviceClient\n      .from('information_schema.columns' as any)\n      .select('column_name, data_type, is_nullable')\n      .eq('table_name', 'profiles')\n      .eq('table_schema', 'public');\n\n    const columnNames = columns!.map((c: any) => c.column_name);\n\n    expect(columnNames).toContain('id');\n    expect(columnNames).toContain('username');\n    expect(columnNames).toContain('bio');\n    expect(columnNames).toContain('avatar_url');\n    expect(columnNames).toContain('is_public');\n    expect(columnNames).toContain('created_at');\n  });\n\n  it('should have RLS enabled on all tables', async () => {\n    const { data: tables } = await serviceClient.rpc('check_rls_enabled');\n\n    \u002F\u002F All public tables should have RLS enabled\n    const publicTables = ['profiles', 'posts', 'comments'];\n    for (const table of publicTables) {\n      const tableInfo = tables?.find((t: any) => t.tablename === table);\n      expect(tableInfo?.rowsecurity, `RLS not enabled on ${table}`).toBe(true);\n    }\n  });\n\n  it('should have correct foreign key relationships', async () => {\n    \u002F\u002F Verify posts.author_id references profiles.id\n    const { data: fks } = await serviceClient\n      .from('information_schema.referential_constraints' as any)\n      .select('constraint_name')\n      .eq('constraint_schema', 'public');\n\n    expect(fks!.length).toBeGreaterThan(0);\n  });\n});\n```\n\n## Best Practices\n\n1. **Always use `supabase start` for local testing** -- Never test against production or staging Supabase instances. Local testing is fast, isolated, and free.\n2. **Test every RLS policy with at least 3 roles** -- For each policy, test as the resource owner, a different authenticated user, and an anonymous user.\n3. **Use the service role client for test setup only** -- Create test data with the service role client, but run actual tests with anon or authenticated clients to verify RLS.\n4. **Clean up test users after each suite** -- Use a TestUserManager that tracks created users and deletes them in afterAll to prevent test database bloat.\n5. **Disable email confirmation for test environments** -- Set `enable_confirmations = false` in the local config to avoid needing to handle email verification in tests.\n6. **Test RLS with both SELECT and the actual operation** -- A user may be able to SELECT a row but not UPDATE or DELETE it. Test each operation independently.\n7. **Verify RLS failures are silent, not errors** -- Supabase RLS violations on UPDATE\u002FDELETE return empty results, not errors. Assert on the returned data being empty.\n8. **Test realtime with proper timeouts** -- Realtime events have latency. Use adequate waits (1-2 seconds) between subscribing and expecting events.\n9. **Use unique identifiers in test data** -- Include timestamps or random strings in test usernames and emails to prevent collisions between parallel test runs.\n10. **Test storage policies separately from application logic** -- Storage bucket policies are independent of table RLS. Write dedicated storage tests.\n\n## Anti-Patterns to Avoid\n\n1. **Testing against production Supabase** -- Production testing creates real data, costs money, and risks exposing test users. Always use local instances.\n2. **Using the service role client in application tests** -- The service role bypasses RLS entirely. If your tests use it for data access, they cannot verify security policies.\n3. **Not testing RLS at all** -- Many teams skip RLS testing because it requires user management. This is the most critical security boundary in a Supabase app.\n4. **Sharing test users between test files** -- Parallel test execution with shared users causes race conditions. Each test file should create its own users.\n5. **Testing only SELECT policies** -- INSERT, UPDATE, and DELETE policies have different USING and WITH CHECK clauses. Test each operation type.\n6. **Ignoring the difference between USING and WITH CHECK** -- USING filters rows you can see, WITH CHECK validates the new row on INSERT\u002FUPDATE. Both need testing.\n7. **Hardcoding Supabase keys in test files** -- Use environment variables or read from the local Supabase config. Hardcoded keys get committed to version control.\n8. **Not testing auth edge cases** -- Token expiry, session refresh, and concurrent sessions are common sources of production bugs. Test these flows.\n9. **Skipping migration rollback tests** -- Only testing the `up` migration is not enough. Verify that `down` migrations cleanly reverse schema changes.\n10. **Testing realtime without actually subscribing** -- Mocking the realtime client misses connection issues, reconnection logic, and message ordering problems.\n\n## Running Tests\n\n- Start local Supabase: `supabase start`\n- Run all tests: `pnpm vitest run`\n- Run RLS tests: `pnpm vitest run __tests__\u002Fintegration\u002Frls`\n- Run auth tests: `pnpm vitest run __tests__\u002Fintegration\u002Fauth-flow.test.ts`\n- Run realtime tests: `pnpm vitest run __tests__\u002Fintegration\u002Frealtime.test.ts`\n- Run edge function tests: `supabase functions serve && pnpm vitest run __tests__\u002Fintegration\u002Fedge-functions.test.ts`\n- Reset local database: `supabase db reset`\n- View local Supabase dashboard: `open http:\u002F\u002F127.0.0.1:54323`\n- Stop local Supabase: `supabase stop`\n",{"name":5,"tags":24,"agents":35,"author":48,"domains":49,"license":15,"version":53,"languages":54,"frameworks":57,"description":7,"testingTypes":61},[25,26,27,28,29,30,31,32,33,34],"supabase","rls","auth","realtime","edge-functions","postgres","storage","migrations","row-level-security","testing",[36,37,38,39,40,41,42,43,44,45,46,47],"claude-code","cursor","github-copilot","windsurf","codex","aider","continue","cline","zed","bolt","gemini-cli","amp","thetestingacademy",[50,51,52],"web","api","backend","1.0.0",[55,56],"typescript","javascript",[58,59,60],"vitest","jest","playwright",[62,63,64],"unit","integration","e2e","main","eac438ea9216a7cb8a570cab803eb01eeafc6793","skills\u002Fqa\u002Fsupabase-testing","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m","https:\u002F\u002Fid-preview--d5bef06d-6c9e-4563-a3d4-a855b9d61610.lovable.app\u002F","Eu sou Antonio B. B. Ndombe \r\nEu sou um Pesquisador e desenvolvedor de sistema autonomia cognitivos, fundador de sistemas ODCs ( organismos digital conscientes)","2026-11-04 06:53:39",{"source":8,"skillName":5,"commands":74,"prompt":84,"zipAvailable":85},[75,78,81],{"tool":76,"command":77},"npx","npx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Supabase Testing\"",{"tool":79,"command":80},"bunx","bunx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Supabase Testing\"",{"tool":82,"command":83},"pnpm","pnpm dlx skills add GrupoANDevelopment-m\u002Falberto-ai --skill \"Supabase Testing\"","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fskills\u002Fqa\u002Fsupabase-testing\u002FSKILL.md",true,[],[88,96,103,110,117,124],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":92,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M7DASC6FSCJP49JZBSK0NY1Z","nemoclaw-user-reference","Describes the NemoClaw integration layer and blueprint architecture and how they orchestrate compatible agent sandboxes. Use when looking up architecture, agent integration, plugin structure, or blueprint design. Trigger keywords - nemoclaw architecture, nemoclaw agent architecture, nemoclaw plugin blueprint structure, nemoclaw vs openshell, which cli, nemoclaw cli, openshell cli, sandbox commands, nemoclaw cli commands, nemoclaw command reference, nemoclaw network policy, sandbox egress control operator approval, nemoclaw troubleshooting, nemoclaw debug sandbox issues.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-reference\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":92,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M7DAS5S79VK33XFGVAM2TFWF","nemoclaw-user-overview","Explains how OpenClaw, OpenShell, and NemoClaw form the ecosystem, NemoClaw's position in the stack, what NemoClaw adds beyond the community sandbox, and when to prefer NemoClaw versus integrating OpenShell and OpenClaw directly. Use when users ask about the relationship between OpenClaw, OpenShell, and NemoClaw, or when to use NemoClaw versus OpenShell. Trigger keywords - nemoclaw ecosystem, openclaw openshell, nemoclaw vs openshell, sandboxed openclaw, how nemoclaw works, nemoclaw sandbox lifecycle blueprint, nemoclaw overview, openclaw always-on assistants, nvidia openshell, nvidia nemotron, nemoclaw release notes, nemoclaw changelog.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-overview\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":92,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7DAS0PQEMET5MNGZ1ABSZVS","nemoclaw-user-monitor-sandbox","Inspects sandbox health, traces agent behavior, and diagnoses problems. Use when monitoring a running sandbox, debugging agent issues, or checking sandbox logs. Trigger keywords - monitor nemoclaw sandbox, debug nemoclaw agent issues.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-monitor-sandbox\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":92,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":19},"01M7DARQYGF7E9A69VH6S3CGN9","nemoclaw-user-manage-sandboxes","Explains operational tasks after the quickstart: listing sandboxes, status and health checks, logs, diagnostics, port forwards, multiple sandboxes, credential reset, rebuilds, network presets, upgrades, and uninstall. Trigger keywords - manage nemoclaw sandboxes, nemoclaw status, nemoclaw list, nemoclaw dashboard port, nemoclaw rebuild, nemoclaw upgrade sandboxes, nemoclaw uninstall, sandbox mutability, sandbox runtime configuration, sandbox rebuild, nemoclaw backup, nemoclaw restore, workspace backup, openshell sandbox download upload, nemoclaw messaging channels, nemoclaw telegram, nemoclaw discord, nemoclaw slack, nemoclaw wechat, nemoclaw whatsapp, openshell channel messaging, nemoclaw workspace files, soul.md, user.md, identity.md, agents.md, sandbox persistence.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-sandboxes\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":92,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":19},"01M7DARH8BRTG51TRCAB7YWDJ4","nemoclaw-user-manage-policy","Adds, removes, or modifies allowed endpoints in the sandbox policy. Use when customizing network policy, changing egress rules, or configuring sandbox endpoint access. Trigger keywords - customize nemoclaw network policy, sandbox egress policy configuration, nemoclaw integration policy examples, post-install policy setup, openshell approval workflow, policy preset, nemoclaw approve network requests, sandbox egress approval tui.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-manage-policy\u002FSKILL.md",[],[],{"skillNo":125,"name":126,"nameZh":6,"description":127,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":92,"licenseFileUrl":6,"sourceHtmlUrl":128,"categories":129,"keywords":130,"publishedAt":19},"01M7DARAT62M2VR37590VCZ5NS","nemoclaw-user-get-started","Installs NemoClaw, launches a sandbox, and runs the first agent prompt. Use when onboarding, installing, or launching a NemoClaw sandbox for the first time. Trigger keywords - nemoclaw quickstart, install nemoclaw openclaw sandbox, nemohermes quickstart, hermes agent nemoclaw, run hermes openshell sandbox, nemoclaw prerequisites, nemoclaw supported platforms, nemoclaw hardware software, nemoclaw windows wsl2 setup, nemoclaw install windows docker desktop.","https:\u002F\u002Fgithub.com\u002FGrupoANDevelopment-m\u002Falberto-ai\u002Fblob\u002Fmain\u002Fupstream\u002Fnemoclaw\u002Fskills\u002Fnemoclaw-user-get-started\u002FSKILL.md",[],[]]