agentleFS
SupabaseKnown publishersupabase/supabase-flutter/AGENTS.md

supabase-flutter

AGENTS.md1k starsChanged 2 months agoMITView on GitHub

This file provides guidance to the agents when working with code in this repository. This is a monorepo for the Supabase Flutter SDK, managed by Melos. It contains multiple independently versioned packages that provide Flutter and Dart clients for Supabase services. The repository follows a layered dependency structure: Key architectural patterns: - SupabaseClient is a facade that initializes and coordinates all sub-clients - AuthHttpClient wraps HTTP requests to inject JWT tokens automatically - Builder/fluent interface pattern for query construction (from().select().eq())…

Trending

Quiet since October.about the whole repository

Jan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 1 mentionOct 2026: 15 mentionsNov 2026: 0 mentionsDec 2026: 0 mentions
Jan 2026Jul 2026Dec 2026
Mentions a month of the supabase/supabase-flutter repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about supabase/supabase-flutter

The biggest 5 of 27 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 27

Talked about on GitHub (27 times).

On GitHub · 27

22 more on GitHub
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

We split this AGENTS.md into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Put a client into a signed-in state with signInTestUser, and build server payloads with testUserJson, testSessionResponseJson and …

    line 115
  2. Distinctive:

    All clients accept options classes for customization:

    line 205
  3. Very specific:

    Run melos analyze and melos format before committing

    line 238
  4. Distinctive:

    Ensure tests pass for modified packages

    line 239
  5. Distinctive:

    Update package changelogs if making notable changes

    line 240
  6. Very specific:

    Use dart format for consistent formatting

    line 244
  7. Very specific:

    Every exported public symbol must be declared in sdk-compliance.yaml at the repo root, or the "SDK Compliance" CI check fails.

    line 248

≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md 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
AGENTS.md

AGENTS.md

This file provides guidance to the agents when working with code in this repository.

Overview

This is a monorepo for the Supabase Flutter SDK, managed by Melos. It contains multiple independently versioned packages that provide Flutter and Dart clients for Supabase services.

Package Architecture

The repository follows a layered dependency structure:

  • supabase_flutter: Flutter-specific wrapper with platform integrations (deep links, local storage, app lifecycle)
  • supabase: Core Dart client that orchestrates all service clients
  • supabase_auth: Authentication client (sessions, JWT, OAuth)
  • postgrest: Database query client with ORM-style API
  • supabase_realtime: WebSocket client for real-time subscriptions
  • supabase_storage: File storage client with retry logic
  • iceberg: Apache Iceberg REST Catalog client used by storage analytics buckets
  • supabase_functions: Edge functions invocation client
  • yet_another_json_isolate: JSON parsing in separate isolate for performance

Key architectural patterns:

  • SupabaseClient is a facade that initializes and coordinates all sub-clients
  • AuthHttpClient wraps HTTP requests to inject JWT tokens automatically
  • Builder/fluent interface pattern for query construction (from().select().eq())
  • Stream-based reactive pattern using RxDart BehaviorSubject
  • Platform-specific code via conditional imports (web vs native)

Development Setup

# Install Melos globally (if not already installed)
dart pub global activate melos

# Bootstrap dependencies for all packages
melos bootstrap
# or shorthand:
melos bs

Common Commands

Linting and Formatting

# Run the analyzer across the whole workspace
melos analyze

# Format code (80 char line length, configured in the root pubspec.yaml)
melos format

Testing

Most packages have unit tests. The postgrest, supabase_auth, supabase_realtime, and supabase_storage packages run against a local Supabase stack started with the Supabase CLI. This requires Docker and the Supabase CLI installed.

For packages requiring a backend (postgrest, supabase_auth, supabase_realtime, supabase_storage):

# 1. Start the local Supabase stack from the repository root
supabase start

# 2. Run tests (from the package directory)
cd packages/<package>
dart test -j 1

# 3. Stop the stack when done (from the repository root)
supabase stop

The single supabase/ config at the repository root serves every package: its migrations and seed.sql create the schemas, functions, and test data all four packages rely on. The stack binds ports 14420 to 14429 (gateway on http://127.0.0.1:14421, database on 127.0.0.1:14422), off the CLI defaults so it can run alongside another local Supabase project and below Linux's default ephemeral port range so an outgoing connection cannot claim a port the stack still needs to bind.

The -j 1 flag runs tests sequentially (not concurrently), which is required since tests share the same backend.

For packages without a backend requirement:

# Run tests from package directory
cd packages/<package>
dart test

Run every package's tests at once:

# Runs `dart test`/`flutter test` in each package that has a test/ directory.
# Start the local Supabase stack first (see above) so the backend packages pass.
melos test

Run tests with coverage (from a package directory):

cd packages/<package>
dart test --coverage=coverage

Running a Single Test File

# From package directory
dart test test/specific_test.dart

# For a specific test case
dart test test/specific_test.dart -n "test name pattern"

Writing Tests

Build tests on the supabase_test package instead of writing mocks by hand:

  • Answer HTTP calls with MockSupabaseHttpClient and its stub, stubHandler, stubError and stubTable/stubRpc/stubStorage* helpers. Do not subclass BaseClient in a test. Match methods with HttpMethod.post.value and friends rather than raw strings.
  • Assert on what was sent with requests and requestsTo(path, method:).
  • Put a client into a signed-in state with signInTestUser, and build server payloads with testUserJson, testSessionResponseJson and unsignedTestJwt. Do not hand-assemble JWTs or session JSON.
  • Construct clients with testSupabaseClient where a whole SupabaseClient is needed.

Fakes for things supabase_test does not cover, such as a platform plugin interface, are written in the test file itself.

Package Management

# Upgrade dependencies across the whole workspace (run at the repository root)
dart pub upgrade

# Check for outdated dependencies
dart pub outdated

Version Management

# Update version.dart files for all packages
melos run update-version

# Version packages and generate changelogs (handled by melos)
melos version

Key Implementation Details

Authentication Flow

  • AuthClient manages sessions, tokens, and JWT validation
  • Emits auth state changes via Stream<AuthState>
  • supabase_flutter adds session persistence via SharedPreferencesAsync (mobile) or browser localStorage (web)
  • Deep link handling for OAuth callbacks (detects ?code= for PKCE or #access_token= for implicit flow)
  • Auth tokens are automatically injected into all HTTP requests via AuthHttpClient
  • Realtime client receives token updates when auth state changes

Query Building

PostgREST queries use a chain of builder classes:

PostgrestQueryBuilder → PostgrestFilterBuilder → PostgrestTransformBuilder → PostgrestBuilder<T>

Example: supabase.from('users').select('id, name').eq('id', 1).limit(10)

PostgrestBuilder<T> is the executable base: T is what awaiting the request resolves to. Steps that change the result (select(), single(), count(), withConverter()) each supply a decoder for the response, and the decoders compose in call order, so the converter always receives whatever the chain resolved to right before it.

The typed builders returned by client.table(...) (PostgrestTypedQueryBuilder → PostgrestTypedFilterBuilder → PostgrestTypedTransformBuilder → PostgrestTypedBuilder<T>) do not wrap untyped builders. Each method returns a copy holding an immutable PostgrestTableRequest that describes the query as structured values (operation, columns, filter, orderings, payload, and PostgrestRequestOptions for headers, retry, timeout and abort signal). Awaiting the builder hands the request to a PostgrestTableExecutor and converts the PostgrestTableResult into the table's Row type. The default PostgrestHttpTableExecutor renders the request through the untyped builders at execution time, so both APIs send the same wire request; another executor (a SupabaseClientPlugin can wrap it) may cache, queue or answer from a local store instead.

Realtime Architecture

  • SupabaseStreamBuilder combines initial PostgREST data fetch with realtime updates
  • Uses RxDart BehaviorSubject for reactive streams
  • WebSocket maintains persistent connection with 30s heartbeat
  • Auto-reconnect with exponential backoff on disconnect

Error Handling

Each package has its own exception hierarchy:

  • supabase_auth: AuthException (base), with specialized subclasses like AuthApiException, AuthRetryableFetchException
  • postgrest: HTTP-based error responses
  • realtime: RealtimeSubscribeException with status tracking
  • storage: Retry logic with exponential backoff, opt-in through SupabaseRetryOptions

Platform Differences

The codebase uses conditional imports for platform-specific implementations:

import './local_storage_stub.dart'
    if (dart.library.js_interop) './local_storage_web.dart'

This enables:

  • Native mobile (iOS/Android): SharedPreferencesAsync for persistence
  • Web: Browser localStorage
  • Single codebase for all platforms

Client Configuration

All clients accept options classes for customization:

  • PostgrestClientOptions: Custom schema access
  • AuthClientOptions: Auto-refresh tokens, PKCE vs implicit flow
  • StorageClientOptions: Retry configuration for uploads
  • FunctionsClientOptions: Edge function region selection
  • RealtimeClientOptions: WebSocket timeout configuration

URL Structure

The SupabaseClient transforms a base URL into service-specific endpoints:

supabaseUrl: "https://project.supabase.co"
├─ REST: "https://project.supabase.co/rest/v1"
├─ Realtime: "ws://project.supabase.co/realtime/v1"
├─ Auth: "https://project.supabase.co/auth/v1"
├─ Storage: "https://project.supabase.co/storage/v1" (or dedicated host)
└─ Functions: "https://project.supabase.co/functions/v1"

Testing Against Local Supabase

For integration testing, you may want to point to a local Supabase instance:

await Supabase.initialize(
  url: 'http://localhost:54321',
  publishableKey: 'your-local-supabase-key',
);

Contributing Guidelines

  • Fork the repo and create feature branches
  • Run melos analyze and melos format before committing
  • Ensure tests pass for modified packages
  • Update package changelogs if making notable changes
  • Any change that breaks the public API adds its own section to MIGRATION.md in the same pull request, under the major version it will ship in
  • Line length limit is 80 characters
  • Use dart format for consistent formatting

Adding a new public API

Every exported public symbol must be declared in sdk-compliance.yaml at the repo root, or the "SDK Compliance" CI check fails. If the capability already exists in the SDK capability matrix (capabilities/<area>.yaml there), just register your symbols. If it doesn't exist yet, open a PR on that repo first to declare it; once it's merged and released, bump the pinned SHA in .github/workflows/validate-capabilities.yml to the new capability-matrix/vX.Y.Z tag, then register the symbols here, entry points under symbols, everything else (params, response types, etc.) under supporting_symbols:

auth.mfa_recovery_codes.generate:
  status: implemented
  symbols:
    - AuthClient.generateMfaRecoveryCodes
  supporting_symbols:
    - MFARecoveryCodesGenerateResponse

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.