/flutter-clean-riverpod-skills:flutter-sdk-contractsfrom flutter-clean-riverpod-skills
Wraps third-party SDKs behind application-owned contracts in Flutter apps. Defines ports, adapters, no-op implementations, and Riverpod wiring for replaceable, testable dependencies.
Ships in flutter-clean-riverpod-skills. 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.
Read when SKILL.md points to them.
Every dependency that crosses the application boundary is wrapped behind a contract the application owns. Feature code depends on contracts, never on SDKs.
MissingPluginException, no SDK initialisation in widget tests.track(event)),
not the SDK's whole surface, so features cannot misuse it.For a capability Foo (analytics, error tracking, clipboard, storage…):
abstract interface class FooService in core/foo/.
Only app-owned types in its signatures. Document why on the methods
whose behaviour is surprising.sealed class AnalyticsEvent instead of track(String, Map).FirebaseFooService implements FooService. The only file
that imports the SDK. It translates SDK errors into AppFailure
(see flutter-result-errors) or swallows them if the contract says
"never throws".NoOpFooService for tests and disabled builds.final fooServiceProvider = Provider<FooService>((ref) {
final config = ref.watch(fooConfigProvider);
return config.isEnabled ? SdkFooService(config) : const NoOpFooService();
});
test/helpers/ (see
assets/recording_analytics_service.dart). Prefer recording fakes to
mocks: assertions read as "this event was tracked".Naming: <Capability>Service. Adapter: <Vendor><Capability>Service.
AsyncResult<Unit> (or a typed value). Fire-and-forget
reporting → Future<void> that never throws: reporting a failure must
not fail the operation that caused it (ErrorTrackingService).AnalyticsAndCrash god
interface.final networkConfigProvider = Provider<NetworkConfig>(
(ref) => throw UnimplementedError('override in bootstrap'),
);
AnalyticsConfig.disabled())
so widget and provider tests never initialise a platform SDK. Bootstrap
overrides it for real runs.Firebase…instance, Sentry.captureException
or Dio(). Only adapters and provider files do.When the same event must reach several vendors, compose behind the same
contract (assets/composite_analytics_service.dart). Rules: call every
destination even after one fails, and return the first failure so
partial delivery stays visible. The provider picks 0 / 1 / many with a
switch on the list length; features never learn the count.
assets/api_client.dart, dio_api_client.dart and the ApiException
hierarchy (from flutter-result-errors) are the reference implementation:
ApiClient speaks decoded JSON maps and throws only ApiExceptions.DioApiClient is the only file allowed to know Dio's API; it maps
DioException types to ApiConnectionException / ApiResponseException /
ApiUnknownException.ApiClient and run through guard(...).Interceptor order matters when you build the Dio in a provider:
Authorization header is attached and tokens never hit
the console. Enable it in debug builds only.Run from the project root; each should print nothing:
# SDKs must not be imported by feature code
grep -rnE "package:(dio|firebase_[a-z_]+|sentry[a-z_]*|posthog_flutter|purchases_flutter|shared_preferences|flutter_secure_storage)/" lib/features
# Static singletons must not be reached from features
grep -rnE "(Firebase[A-Za-z]*\.instance|Sentry\.capture|SharedPreferences\.getInstance|Dio\()" lib/features
Adapters under lib/core/ and the provider files that construct them are
the only legitimate importers. Tune the package list to your pubspec.
NoOp and a recording fake existProvider<FooService>), not the adapterassets/analytics_event.dart (opens in a new tab)assets/analytics_providers.dart (opens in a new tab)assets/analytics_service.dart (opens in a new tab)assets/api_client.dart (opens in a new tab)assets/composite_analytics_service.dart (opens in a new tab)assets/dio_api_client.dart (opens in a new tab)assets/error_tracking_service.dart (opens in a new tab)assets/recording_analytics_service.dart (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub ethiel97/flutter-clean-riverpod-skills --plugin flutter-clean-riverpod-skills6 skills in this plugin
/flutter-feature-scaffoldUse when adding a new feature or module to a Flutter app that follows feature-first Clean Architecture (data / domain / presentation) with Riverpod 3 and no code generation for providers, when deciding which layer or folder a file belongs in, or when reviewing dependency direction between layers. Provides the folder layout, per-layer rules, barrel conventions, build order and a scaffold script./flutter-result-errorsUse when writing or reviewing Flutter data-layer, repository or provider code that can fail, when adding Result/AsyncResult types or failure types, when mapping exceptions to user-facing errors, or when an exception is crossing a layer boundary. Sets up a sealed AppFailure taxonomy, Result typedefs over result_dart, one catch boundary (RemoteDataSourceGuard) and the way presentation folds failures./flutter-riverpod3Other plugins' skills for the same job