/flutter-clean-riverpod-skills:flutter-riverpod3from flutter-clean-riverpod-skills
Guides hand-written Riverpod 3 provider patterns in Flutter: choosing provider types, wiring DI, writing Notifier/AsyncNotifier, and handling state immutability, disposal, and retry. Rejects code generation, StateNotifier, Bloc, GetIt.
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.
Riverpod is the only tool for dependency injection, state management and async orchestration. Providers are declared explicitly by hand.
| Rule | Why |
|---|---|
No riverpod_generator, riverpod_annotation, @riverpod | One less build_runner target, the dependency graph is readable in plain Dart, and nothing to migrate when the generator's output changes. (build_runner may still run for json_serializable etc.) |
No StateNotifier / StateNotifierProvider | Legacy API. Notifier / AsyncNotifier replace it. |
No Bloc, Cubit, provider package, GetIt, Injectable | A second state or DI system doubles what a reader must learn and splits the graph. |
Every dependency is exposed through a Provider | One graph, one override mechanism for tests. |
| Never instantiate dependencies inside widgets | A widget that does Dio() or Repo() cannot be tested or swapped. |
| Need | Use |
|---|---|
| Immutable dependency (repository, service, client) | Provider<Contract> |
| Async read-only data | FutureProvider |
| Continuous stream (auth state, connectivity) | StreamProvider |
| Mutable synchronous state (filters, selected tab, a form) | NotifierProvider |
| Mutable asynchronous state (a screen's store, a session) | AsyncNotifierProvider |
| One user action in flight | SubmissionNotifier + autoDispose (see flutter-result-errors) |
One responsibility per provider. Name them xProvider / XNotifier.
final todayProvider = FutureProvider<Today>((ref) async {
final result = await ref.watch(todayRepositoryProvider).getToday();
return result.getOrThrow(); // the sanctioned throw: becomes AsyncError
});
watch, read, listen| Where | Use | Never |
|---|---|---|
Provider body, Notifier.build, widget build | ref.watch | ref.read for data that can change: the consumer will not update |
Callbacks, notifier methods, onPressed | ref.read | ref.watch: it throws or leaks |
| Side effects (navigation, snackbar, analytics) | ref.listen in a listener widget (see flutter-ui-side-effects) | Doing them inside build |
Equatable. Riverpod only notifies when
the new state is not == to the old one, and select compares by value, so
value equality is what makes both work as intended.state = AsyncData(current.copyWith(...)); never mutate a list
in place (the reference does not change, so nothing fires).AsyncResult so the caller can report the failure;
the store itself changes only on success, so a failed attempt never wipes
app-wide state. Template: assets/async_store_notifier.dart.autoDispose for screen-scoped state and for per-attempt submissions, so
a stale error resets when the screen is left.autoDispose a long-lived singleton that is read from callbacks
(a text-to-speech engine, a socket): it can be torn down mid-use and crash on
the next event. Release native resources with ref.onDispose.ref.onDispose for every timer, debouncer and stream subscription a
provider creates.if (!ref.mounted) return; after every await in a notifier that can be
disposed while a request is in flight; assigning state afterwards throws.
Still hand the result back to the caller.ref.invalidate(provider) is the retry button: wire onRetry to it.A provider that throws during build is retried automatically with
exponential backoff. With Result-based errors that is usually wrong:
an AuthFailure or ValidationFailure fails identically every time, and
calling a store or payment SDK ten more times is harmful.
NetworkFailure and 5xx, a couple of times: assets/retry_policy.dart.retry: (_, _) => null when the work is not safe
to repeat.flutter-testing).Verify the retry parameter against your Riverpod version.
ProviderContainer yourself and use UncontrolledProviderScope
when something must read providers before the first frame, or when a widget
above the router needs the router instance. See assets/bootstrap_example.dart.context.router; read the router
from a provider instead.Measure first. These techniques add complexity; use them when a rebuild is observably expensive (a long list, a chart, dropped frames), not on suspicion.
watch down. A small ConsumerWidget around the subtree that
needs the state beats a select at the page root. Listener widgets exist
for the same reason: they listen without watching.autoDispose provider, not in the session, or every
screen watching the session rebuilds on every tap.select the narrowest thing.
final name = ref.watch(authProvider.select((s) => s.value?.user?.name ?? ''));
final submitting = ref.watch(submissionProvider.select((s) => s.isLoading));
Use selectAsync to derive from another provider's data without awaiting
the whole AsyncValue.const the leaves.select rules: the selected value must be immutable and compared by value;
do not select a property that changes as often as its parent.
ref.read inside build for reactive datafailure.message for UI copy (see flutter-result-errors)Result insteadProviderContainer inside a widgetStateNotifier, Bloc, GetIt, provider packagewatch in builds, read in callbacks, listen for side effectsEquatableautoDispose where scoped; never on long-lived singletonsref.mounted checked after awaits; ref.onDispose for timers and subscriptionsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
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-sdk-contractsUse when adding, replacing or touching any third-party SDK or platform plugin in a Flutter app (Firebase, Sentry, PostHog, Dio, secure storage, shared_preferences, notifications, share, clipboard, permissions, purchases), or when feature code imports an SDK directly. Defines application-owned contracts (ports), adapters, no-op/composite/recording implementations and their Riverpod wiring./flutter-testingUse when writing or reviewing tests for a Flutter app that uses Riverpod, Result-based repositories and SDKs behind contracts - unit tests for data sources, repositories and notifiers, widget tests with provider overrides, listener tests with recording fakes, golden tests, or deciding between a mock and a fake./flutter-ui-side-effectsUse when a Flutter widget needs navigation, snackbars, dialogs, analytics or any one-shot reaction to a state change, when button callbacks contain context.router / ScaffoldMessenger / analytics calls, when error copy must be shown for a failed action, or when adding a <Feature>Listeners widget. Covers ref.listen listener widgets, per-attempt submission state and mapping failures to user-facing text.Other plugins' skills for the same job