/apple-dev:supabase-swiftfrom apple-dev
Working with Supabase in Apple-platform apps: schema changes and migrations through the Supabase MCP tools, row level security and API key rules, and supabase-swift auth and query patterns for Apple platform apps.
Ships in apple-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
create_project, list_tables, apply_migration, execute_sql, deploy_edge_function, get_advisors, query_logs, search_docs…). If it isn't connected, ask the user to connect it rather than working around it. Use the Supabase CLI only if the project already uses it (a supabase/ folder with config.toml); don't introduce a local Docker stack.search_docs tool rather than relying on memory.create_project) after telling them. Confirm the organization if they belong to more than one.list_tables shows row counts). If it has tables with data, confirm in plain language before any schema work, and offer to build in a new development project instead. Branching exists but only on paid plans, so a second project is the universal option.SupabaseClient). Read it from there; don't guess from the project list.apply_migration with a descriptive name. Use execute_sql for reads, data fixes, and exploratory queries — not for schema changes that should be part of the app's history.CREATE TABLE migration must include, in the same migration:
ALTER TABLE ... ENABLE ROW LEVEL SECURITY plus its policies, andGRANT SELECT, INSERT, UPDATE, DELETE ON <table> TO authenticated; (and TO anon only when genuinely public), the app gets "permission denied" no matter what RLS says. Grants control whether the table is reachable; RLS controls which rows. Both are required.DROP, DELETE/UPDATE without a tight WHERE, TRUNCATE, column type changes, disabling RLS) on anything containing data: explain what will happen in plain language and get the user's explicit OK in chat first. Never batch a destructive change silently into a larger migration.user_id). In a migration that creates the table, plain CREATE INDEX is correct. On an existing table with live data, CREATE INDEX CONCURRENTLY — but it cannot run inside a migration (transactional), so run it via execute_sql, then verify with select relname from pg_class join pg_index on indexrelid = pg_class.oid where not indisvalid; and drop-and-retry any invalid index.bigint generated always as identity by default; uuid default gen_random_uuid() when clients generate IDs offline. Do not use pg_uuidv7 — the extension is unavailable on hosted Supabase.get_advisors (type "security") and fix or surface what it reports. Treat a table flagged without RLS as a must-fix, not a suggestion.create policy ... on t to authenticated using ((select auth.uid()) = user_id); — always the (select ...) wrapper (caches per statement instead of per row), always to authenticated/to anon rather than auth.role(). UPDATE policies need both USING and WITH CHECK (without WITH CHECK a user can reassign rows to someone else). A table readable by anon still needs an ownership predicate unless it is genuinely public content.auth.uid() / auth.jwt() in policies. Never current_setting('app.*') session variables (unusable from a mobile client — such policies silently match nothing) and never request.headers (client-controlled, and not delivered over Realtime).authenticated role. Policies that must exclude them check (select (auth.jwt()->>'is_anonymous')::boolean) is false.SELECT policies gate UPDATE too: without a SELECT policy, updates silently match zero rows — no error, no change.app_metadata, never user_metadata — users can edit their own user_metadata, and it appears in auth.jwt(), so any policy or check that trusts it is bypassable.with (security_invoker = true), or keep them in an unexposed schema.SECURITY DEFINER is acceptable only as a deliberate RLS helper function, kept out of exposed schemas, with set search_path = ''. Never add it to make a permission error go away — fix the grant or policy instead.sb_publishable_..., fetched with get_publishable_keys) — it is public by design; RLS is the security boundary. Never write a secret key (sb_secret_..., service_role, or any credential) into project files, even temporarily: generated projects get pushed to public git hosting and history is permanent.One shared SupabaseClient for the whole app (multiple instances race token refresh and force-log the user out). Defaults are already right: Keychain session storage, PKCE, auto-refresh — no configuration needed beyond URL and publishable key.
Auth: never pick the method silently. Every option below needs the user to do something outside the tools you have, and the options have different prerequisites. Ask which they want before building, and say what it will cost them in setup. Do not present a choice you made for them as already decided. The choice also decides how App Review gets in (see App Review access below) — raise that at the same time, not at submission.
Sign in with Apple (native) — the default when the user has a paid Apple Developer account. No Services ID, client secret, .p8 key, or secret rotation: native-only needs the bundle ID and nothing else. Three prerequisites, all of which must hold:
"entitlements": { "path": "App/App.entitlements", "properties": { "com.apple.developer.applesignin": ["Default"] } }. Without it every authorization fails with AuthorizationError 1000 and no useful message.app.bitrig.<anything>.<uuid>), follow the xcodegen-project skill's Bundle Identifier rules first (reuse the App Store Connect bundle ID if there is one, otherwise ask the user for a reverse-DNS ID they own), then update everything derived from it. Never invent a bundle ID yourself. Otherwise the registration and the Supabase Client IDs list both go stale when the real bundle ID lands.Then enable the provider on the Supabase side: Authentication → Sign In / Providers → Apple, turn it on, and add the bundle ID to Client IDs (native-only sign-in needs no secret key). Give the user the direct dashboard link (https://supabase.com/dashboard/project/<ref>/auth/providers) and the exact value to paste. If the bundle ID changes later, the Client IDs entry must change too — sign-in with an unregistered bundle ID fails with "Unacceptable audience in id_token". Have them run the app on a device once — device builds use automatic signing, which registers the capability with the portal. Simulator sign-in additionally needs an Apple Account signed into the simulator.
In code: SignInWithAppleButton → pass the credential's identity token to auth.signInWithIdToken(credentials: .init(provider: .apple, idToken: ...)). Send Apple the SHA-256 of a nonce and Supabase the raw nonce. Apple returns the user's name/email only on the very first authorization — save them to the profile immediately.
Anonymous sign-in — the fallback when there is no paid team, and the right choice on its own for try-before-signup. One dashboard toggle, no entitlement, no email infrastructure. Convert later via updateUser/linkIdentity, and remember the is_anonymous policy rule above.
Email one-time codes — only when the user specifically wants email, and only after checking the two gates below. signInWithOTP(email:) + verifyOTP(email:token:type: .email), no deep links or redirect URLs to configure, but the project's Magic Link template must contain {{ .Token }} and the default template does not.
Avoid web-redirect OAuth flows unless the user asks — they need URL schemes and redirect allowlist entries.
Drive app state from auth.authStateChanges (an AppView that switches between auth and content views), matching Supabase's official Swift tutorial and the supabase-swift Examples/ app.
Data API calls run under short statement timeouts (roughly 3s anonymous / 8s authenticated), so generated queries need the indexes above plus pagination (.range(...)) — never unbounded table scans in UI paths.
When sign-in gates content, App Review needs a way in — raise it when building auth, and offer to create the account rather than asking the user for one.
select email_confirmed_at from auth.users) if the project requires confirmation, and seed it so the reviewer doesn't land in an empty state. Sign in as it once before putting the credentials in review.json.checkout-v2) and leave the old one serving until old builds drain.A key for OpenAI, Stripe, Resend, or any other service cannot ship in the app — an iOS binary is readable, and a key in it is a key anyone can spend. The shape is always the same: the app calls an Edge Function with verify_jwt: true, the function reads the key from the project's secrets with Deno.env.get, and calls the third party. This makes auth a prerequisite for the feature, not an optional extra — settle it with the user before building the function.
Have the user store the key themselves so it never lands in the conversation, the transcript, or a file: give them the link where they create or look up the value (https://platform.openai.com/api-keys, https://dashboard.stripe.com/apikeys) and the link to the project's Edge Function secrets page (https://supabase.com/dashboard/project/<ref>/functions/secrets), with the exact secret name to use. If they use the Supabase CLI, supabase secrets set NAME=… run in their own terminal also works. Never ask for a key in chat and never write one into source or deno.json.
Rotating a key works the same way — the user overwrites the secret on the same page. Values can't be read back (the API returns names only), so a wrong key shows up as a 401 from the third party, not as anything visible in the project; when a function fails that way, offer to replace the secret rather than hunting through the code.
Then, in the function: keep the third party's response shape out of the app's contract, return only what the app needs, and check Deno.env.get("OPENAI_API_KEY") for null at the top so a missing secret is a clear 500 rather than a confusing upstream error. Streaming responses reach the app over SSE; functions.invoke buffers, so a token-by-token UI needs URLSession.bytes against the function URL with the session's access token in the Authorization header.
Rate limiting is the app's job. A key sitting behind a JWT-verified function is still spendable by any signed-in user, anonymous ones included — count calls per auth.uid() in a table and reject over the limit, especially when the app uses anonymous sign-in.
Supabase Cron is the pg_cron extension — there is no separate service and no MCP tool for it, so schedule and inspect jobs with apply_migration and execute_sql like any other SQL. Enable it, plus pg_net if jobs need to reach anything outside the database, in a migration:
create extension if not exists pg_cron with schema pg_catalog;
create extension if not exists pg_net;
pg_net installs into public and does not support ALTER EXTENSION SET SCHEMA, so the extension_in_public security advisor warning for it can't be fixed in place — note it to the user and move on.
cron.schedule(name, schedule, sql) upserts by name, so re-running a migration replaces the job instead of duplicating it. cron.alter_job edits and cron.unschedule(name) removes; a job cannot be changed any other way.postgres and bypass RLS. The job body is the security boundary — scope every statement with its own where, and never let a job write rows on behalf of a user without an explicit user id in the query.net.http_post, wrapped in a job. Keep the key in Vault (select vault.create_secret('sb_publishable_...', 'publishable_key')) and read it back through vault.decrypted_secrets in the job body — anything inlined is stored in plain text in cron.job, which is readable by every job author.cron.job_run_details (where status <> 'succeeded' ordered by start_time desc) before changing anything. Statement timeouts and permission errors both land there. query_logs on postgres_logs has the rest.net.http_post → an Edge Function that sends to APNs; see Push notifications below.Supabase apps send through APNs directly: an Edge Function signs and POSTs the notifications, using an APNs auth key held in the project's secrets. The notifications skill covers the app side (entitlement, registration, environment detection, testing); the Supabase side is:
For WidgetKit push updates (widgets and watch complications), the same key and the same Edge Function shape apply, with two differences: the token column holds the widget token rather than the device token (keep the two kinds apart with a kind column), and the send appends the widget suffix to the topic — apns-topic ".push-type.widgets" with the apns-push-type header set to widgets. For an iPhone widget that host is APNS_TOPIC itself, so build the topic as "${APNS_TOPIC}.push-type.widgets" rather than storing a second secret. A watch complication is hosted by the watch app, whose bundle ID APNS_TOPIC doesn't cover, so store that token's topic on its row and send to the stored value. One auth key signs every topic in the team. Trigger widget sends from wherever the data changes: when other users' writes should refresh everyone's widgets, the mutating app calls an Edge Function after every write to widget-visible data (or a database webhook on the table does) — not just the writes that also send alert pushes.
A push-refreshed widget is a Supabase client of its own: the push only triggers a timeline reload, so the extension's provider fetches the fresh rows itself in getTimeline, and that needs the app's session. Share it by configuring the same auth storage in both processes — KeychainLocalStorage with an explicit shared service name and the App Group id as the accessGroup (on iOS the App Groups entitlement doubles as a keychain access group, so no extra entitlement) — and add the Supabase package to the extension target's dependencies. Keep the one-client-per-process rule; two processes sharing one stored session is fine. Switching an existing app's session storage signs everyone out once — tell the user. Upload the widget token from the WidgetPushHandler, re-upload WidgetCenter.shared.currentPushInfo whenever the account loads in the app, and delete the row on sign-out while the session still exists, alongside the device token.
Live Activities use the same key and Edge Function shape again, with apns-push-type liveactivity and apns-topic "${APNS_TOPIC}.push-type.liveactivity" — the host app's bundle ID, so APNS_TOPIC covers it directly. The token storage differs from the other two: an update token belongs to one activity rather than to the install, so give it a row keyed by activity id alongside the user id and delete that row when the activity ends, while the per-install push-to-start token is stored like a device token. The function body is where the content-state JSON is built, so build it from the same field names and types as the Swift ContentState and let JSON.stringify emit them unchanged — the system decodes with default strategies, so a snake_cased or reformatted field makes the send succeed and the activity never update. Delete tokens on 410 Unregistered as with the others.
A stored device token contributes Identifiers → Device ID to the privacy label below.
Supabase means the app is never a "collects nothing" answer on App Store Connect's App Privacy questionnaire, and that label must be published before the first submission. Work the answers out from the project rather than asking the user what leaves the device.
auth.uid() every row is keyed by). Any email-based flow adds Contact Info → Email Address — passwords and one-time codes alike, and Sign in with Apple when the app requests the email scope, private relay addresses included. Requesting the name scope adds Contact Info → Name. Anonymous sign-in alone contributes only the user ID.list_tables is the checklist.Hand this to the user as a filled-in list keyed to Apple's categories, not as a question. The app-store-connect skill covers where it gets published.
Run get_advisors (security, then performance) and resolve or explicitly surface every finding to the user — especially any exposed table without RLS. Confirm auth works against the real project on a device or simulator before submitting the app, and settle App Review access and the App Privacy label above before submitting.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub chrislaupama/apple-dev-kit --plugin apple-dev25 skills in this plugin
/app-intentsUse when adding or modifying App Intents, App Shortcuts, Siri actions, Spotlight actions, Action Button actions, or parameters exposed through those systems./apple-app-extensionsUse when adding or modifying a Widget, Control Center control, Live Activity, WidgetKit extension, complication, or App Group shared between an app and its extensions./apple-higConsult Apple's Human Interface Guidelines when creating a new app's user-facing interface, designing a new screen or UI component, substantially redesigning UI layout, controls, navigation, or interactions, or answering an explicit HIG guidance or review request. Not triggered by code architecture, API or data-model design, or implementation changes that preserve the UI.Other plugins' skills for the same job