agentleFS
ariaraminariaramin/flutter-skills/skills/flutter-supabase-engineering/SKILL.md

flutter-supabase-engineering

Skill8 starsChanged 48 days agoMITView on GitHub

Design, implement, review, secure, test, debug, migrate, and optimize production Supabase integrations in Flutter and Dart applications. Use when a task involves supabase_flutter, Supabase Auth or session restoration, OAuth/PKCE or deep links, PostgREST queries and mutations, PostgreSQL Row Level Security, RPC/database functions, pagination or query performance, Realtime/Postgres Changes/Broadcast/Presence, Storage buckets/uploads/downloads/signed URLs, Edge Functions, caching or offline behavior, retries/idempotency, local Supabase testing, mock_supabase_http_client, or Supabase architecture and production readiness. Do not use for generic PostgreSQL work with no Supabase client or policy concerns, backend-only Supabase integrations, or non-Supabase authentication.

The file

Show its rules and text

We split this skill into the rules it gives an agent

30 rules. About 0 are common, 27 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈27

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat Flutter as an untrusted client.

    line 8
  2. Very specific:

    Do not create a new client, query, Future, stream, Auth listener, or Realtime channel from build().

    line 40
  3. Distinctive:

    Treat the project URL and client publishable/anonymous key as client configuration, not authorization.

    line 42
  4. Distinctive:

    Never ship a service-role key, secret key, database password, JWT signing secret, third-party secret, or privileged credential in Flutter.

    line 44
  5. Distinctive:

    Keep authorization claims in trusted server-controlled data, not editable user metadata.

    line 48
  6. Distinctive:

    Keep ordinary user-owned CRUD behind direct PostgREST plus RLS when that is the simplest secure boundary.

    line 50
  7. Distinctive:

    Use database functions/RPC for atomic multi-row or transactional SQL work.

    line 52
  8. Distinctive:

    Use Edge Functions for server-only secrets, external integrations, or custom privileged orchestration—not as a generic proxy for every …

    line 53
  9. Very specific:

    Use .single() only when exactly one row is required.

    line 57
  10. Distinctive:

    Keep Realtime subscriptions narrow, persist stream instances, remove unused channels, and never treat Realtime as durable history.

    line 61
  11. Distinctive:

    Use private buckets for private data and enforce access with Storage RLS.

    line 64
  12. Distinctive:

    Do not stack retries across client, repository, and state layers.

    line 68
  13. Distinctive:

    Do not assume Supabase is offline-first.

    line 69
  14. Distinctive:

    Never rely on mocks to prove RLS, grants, constraints, triggers, Auth, Realtime, or real PostgreSQL behavior.

    line 73
  15. Distinctive:

    Use this decision order:

    line 78
  16. Distinctive:

    Use direct PostgREST plus RLS for ordinary user-owned CRUD.

    line 80
  17. Distinctive:

    Use RPC for atomic database work or reusable server-side SQL logic.

    line 81
  18. Distinctive:

    Use an Edge Function when server-only credentials, external APIs, or custom privileged orchestration are required.

    line 82
  19. Distinctive:

    Use Postgres Changes for moderate live database views.

    line 84
  20. Distinctive:

    Use Broadcast for high-scale fan-out or application-defined messages.

    line 85
  21. Distinctive:

    Use Presence for ephemeral online state.

    line 86
  22. Distinctive:

    Use private Storage plus signed URLs for temporary external access.

    line 87
  23. Distinctive:

    Add offline-first architecture only for an explicit offline editing requirement.

    line 88
  24. Distinctive:

    Prefer the first boundary that fully satisfies security and correctness.

    line 91
  25. Very specific:

    Read only the relevant sections of references/production-guide.md.

    line 95
  26. Distinctive:

    Use these search headings:

    line 102
  27. Distinctive:

    Do not add an interface, wrapper, Edge Function, or cache solely for future flexibility.

    line 131
  28. Distinctive:

    Keep transport and Supabase error types inside the data boundary.

    line 133
  29. Distinctive:

    Run the narrowest relevant Dart/Flutter checks, then validate authoritative behavior against a local or isolated Supabase stack.

    line 138
  30. Distinctive:

    Never test destructive behavior against production.

    line 153

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Flutter Supabase Engineering

Treat Flutter as an untrusted client. Keep the database, Row Level Security, constraints, and server-side policy authoritative.

Start with evidence

Before changing code:

  1. Inspect pubspec.yaml, pubspec.lock, Flutter/Dart constraints, and target platforms.
  2. Identify the locked supabase_flutter, supabase, postgrest, realtime_client, storage_client, functions_client, and test-package versions.
  3. Find every Supabase initialization and client construction; identify the single intended client owner and lifetime.
  4. Inspect Auth bootstrap, persistence, deep-link handling, listeners, sign-out, and session-dependent startup behavior.
  5. Inspect database migrations, grants, RLS policies, indexes, functions, constraints, and generated/typed models relevant to the task.
  6. Inventory query count, selected columns, pagination, N+1 patterns, mutation idempotency, Realtime channels, Storage transfer paths, Edge Functions, retry layers, caching, and offline requirements.
  7. Separate current repository behavior from version-sensitive guidance.

The bundled guide was validated on 2026-08-11 against supabase_flutter 2.17.1, supabase 2.16.0, storage_client 2.6.0, functions_client 2.7.1, and mock_supabase_http_client 0.0.3+2. Use the installed packages and their changelogs as the source of truth when versions differ.

Preserve these invariants

  • Initialize supabase_flutter once before runApp and reuse its client.
  • Do not create a new client, query, Future, stream, Auth listener, or Realtime channel from build().
  • Treat the project URL and client publishable/anonymous key as client configuration, not authorization.
  • Never ship a service-role key, secret key, database password, JWT signing secret, third-party secret, or privileged credential in Flutter.
  • Enable and test RLS for client-accessible data; do not treat hidden UI or a client-supplied user/tenant ID as authorization.
  • Keep authorization claims in trusted server-controlled data, not editable user metadata.
  • Keep ordinary user-owned CRUD behind direct PostgREST plus RLS when that is the simplest secure boundary.
  • Use database functions/RPC for atomic multi-row or transactional SQL work.
  • Use Edge Functions for server-only secrets, external integrations, or custom privileged orchestration—not as a generic proxy for every query.
  • Select only needed columns, filter on the server, paginate large results, avoid N+1 requests, and index real query and RLS predicates.
  • Use .single() only when exactly one row is required; use .maybeSingle() when absence is valid.
  • Make retried mutations idempotent at the database or protocol boundary; do not infer safety from a client boolean.
  • Keep Realtime subscriptions narrow, persist stream instances, remove unused channels, and never treat Realtime as durable history.
  • Reconcile initial query data and Realtime changes deliberately.
  • Use private buckets for private data and enforce access with Storage RLS; object paths are organization, not authorization.
  • Choose standard versus resumable upload based on object size and network reliability; avoid whole-file memory loads for large objects.
  • Do not stack retries across client, repository, and state layers.
  • Do not assume Supabase is offline-first; add an explicit local source of truth, sync, conflict, and deletion model only when the product requires it.
  • Apply schema and policy migrations through the database workflow, never from the Flutter app.
  • Never rely on mocks to prove RLS, grants, constraints, triggers, Auth, Realtime, or real PostgreSQL behavior.

Choose the smallest secure boundary

Use this decision order:

  1. Use direct PostgREST plus RLS for ordinary user-owned CRUD.
  2. Use RPC for atomic database work or reusable server-side SQL logic.
  3. Use an Edge Function when server-only credentials, external APIs, or custom privileged orchestration are required.
  4. Use Postgres Changes for moderate live database views.
  5. Use Broadcast for high-scale fan-out or application-defined messages.
  6. Use Presence for ephemeral online state.
  7. Use private Storage plus signed URLs for temporary external access.
  8. Add offline-first architecture only for an explicit offline editing requirement.

Prefer the first boundary that fully satisfies security and correctness.

Route to the production guide

Read only the relevant sections of references/production-guide.md. Locate sections before reading them with:

rg -n '^#{1,3} (SECTION|RELATED SECTION)$' references/production-guide.md

Use these search headings:

TaskSearch headings
Select packages, configure secrets, initialize, or manage client lifetime`Package SelectionPlatform Capability MatrixConfiguration and SecretsInitializationSession Restoration Is AsynchronousClient LifetimeDo Not Recreate Clients`
Implement Auth, sessions, sign-out, OAuth, PKCE, deep links, or recovery`AuthenticationAuth Session LifecycleAccess and Refresh TokensgetSessiononAuthStateChangeSign-OutAuth PersistenceOAuth and PKCEOAuth Deep-Link FlowPassword RecoveryNative Provider Sign-In`
Design authorization, RLS, grants, tenant isolation, or policy performance`Authorization and RLSRLS BaselineGrants and RLSauth.uidIndex RLS ColumnsRLS Policy PerformanceMulti-Tenant RLSUser Metadata and Authorizationsecurity definer`
Implement queries, typed models, pagination, or query optimization`Database QueriesSelect Required ColumnsCurrent Filter APIsTyped ModelsRepository Examplesingle.*maybeSinglePaginationKeyset PaginationAvoid N+1Query Performance WorkflowDatabase Index Awareness`
Implement mutations, constraints, idempotency, RPC, or transactions`MutationsInsertUpdateUpsertDeleteDatabase ConstraintsIdempotencyRPC and Database FunctionsTransactionsDatabase Function Security`
Choose direct queries, RPC, or Edge Functions`Edge Functions vs RPC vs Direct QueriesDecision Framework`
Add or optimize Realtime, Broadcast, Presence, or streams`Realtime ArchitecturePostgres ChangesRealtime Multiple FiltersRealtime ScalingRealtime Performance RulesRemove ChannelsFlutter Lifecycle and RealtimeRealtime Is Not Durable HistorystreamRealtime + Local State ReconciliationBroadcastPresence`
Implement Storage, uploads, downloads, buckets, signed URLs, or CDN behavior`StoragePublic vs Private BucketsStorage RLSStorage OwnershipStorage UploadWeb UploadsStandard vs Resumable UploadsLarge Upload MemoryStorage RetrySigned URLsPublic URLsCDN and cacheControlDownloads`
Invoke, cancel, retry, locate, or debug Edge Functions`Edge FunctionsCurrent Function CancellationFunction Error TypesFunction Retry StrategyFunction RegionWeb Edge FunctionsFunction Performance`
Add caching, offline support, retry, or error mapping`Offline BehaviorCaching StrategyRetry StrategyPostgREST Automatic RetryError HandlingError Mapping`
Review architecture, Flutter performance, concurrency, security, or reliability`ArchitectureRepository PatternDependency InjectionState ManagementFlutter Widget PerformanceConcurrency and Race ConditionsSecurity RulesPerformance RulesReliability Rules`
Test, debug, migrate, review, or prepare production`Testingmock_supabase_http_clientMock LimitationsLocal SupabaseRLS Security TestsDatabase Migration RulesEdge Function TestingObservability and DebuggingDebugging GuideAnti-PatternsImplementation ChecklistCode Review ChecklistProduction Readiness ChecklistVersion-Sensitive Areas`

For a full security or production-readiness audit, read the entire guide after completing the repository inventory.

Implement at the authoritative boundary

  • Fix authorization in RLS, grants, trusted claims, or server-side code rather than duplicating checks in every Flutter caller.
  • Fix query shape and indexes before applying Dart micro-optimizations.
  • Fix atomicity with a database constraint, transaction, or function rather than client sequencing.
  • Reuse the existing repository, client, Auth bootstrap, cache, and subscription ownership patterns when they are sound.
  • Do not add an interface, wrapper, Edge Function, or cache solely for future flexibility.
  • Keep transport and Supabase error types inside the data boundary; map them to stable application failures where the existing architecture expects it.

Validate the result

Run the narrowest relevant Dart/Flutter checks, then validate authoritative behavior against a local or isolated Supabase stack. Cover changed paths from this matrix:

  • authenticated, anonymous, expired, refreshed, and signed-out sessions;
  • allowed and denied RLS cases for each relevant role and tenant;
  • database constraints, triggers, functions, transactions, and indexes;
  • empty, single-row, multi-row, pagination, and concurrent mutation cases;
  • Realtime subscribe, reconnect, reconcile, and channel disposal behavior;
  • private/public Storage access and representative transfer sizes;
  • Edge Function success, typed failures, timeout, cancellation, and idempotent retry behavior;
  • offline/cache transitions when changed;
  • release-like deep-link and OAuth behavior on each affected platform.

Never test destructive behavior against production. Report any authorization, migration, platform, or local-stack path that was not executed.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.