/flutter-clean-riverpod-skills:flutter-feature-scaffoldfrom flutter-clean-riverpod-skills
Scaffolds new features in Flutter apps following feature-first Clean Architecture with Riverpod 3. Covers folder layout, per-layer rules, barrel conventions, dependency direction, and build order.
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; scripts run unread.
lib/
├── app/ bootstrap, root widget, environment
├── core/ cross-cutting contracts + adapters (network, analytics,
│ error_tracking, storage, errors, config, logging…)
├── shared/ reusable UI & utils with no business meaning
│ (routing, theme, widgets, extensions)
├── features/ one folder per business capability
└── l10n/
features/<feature>/
├── <feature>.dart barrel: exports domain, di, presentation (NOT data)
├── data/ no Riverpod, no Flutter widgets
│ ├── datasources/ <x>_remote_data_source.dart, <x>_endpoints.dart
│ ├── models/ JSON-aware classes (fromJson / toEntity)
│ └── repositories/ <x>_repository_impl.dart
├── di/
│ └── <feature>_providers.dart dataSource + repository providers
├── domain/
│ ├── entities/ immutable value classes (Equatable)
│ ├── repositories/ abstract interface class contracts
│ ├── services/ pure domain logic spanning entities
│ └── usecases/ only when logic is shared or non-trivial
└── presentation/
├── pages/
├── widgets/ includes <Feature>Listeners (side effects)
├── providers/ Notifier / AsyncNotifier / FutureProvider
└── state/ state classes when a notifier needs more than a value
Every folder has a barrel named after it (entities.dart,
datasources.dart, …) that exports its files. Import barrels, not files,
across folders.
presentation ──▶ di ──▶ data
│ │ │
└──────▶ domain ◀───┘
equatable.ApiClient. It does not import Riverpod: wiring is
not its job, so it stays testable in plain Dart.di/ is the composition point: the only place that sees data/ and
domain/ together. It builds the data source and repository and exposes
the repository as its contract type (Provider<FavoriteRepository>).domain/ and di/, never data/. It does not
call an ApiClient, parse JSON or touch SDKs.di/) only.
If two features need the same model, promote it to core/ instead of
reaching into another feature's data/ or presentation/.Why di/ and not "a provider next to the impl": a provider in data/ forces
presentation to import data/ just to ref.watch it, and the rule
"presentation never imports data" gains an exception that people stretch
(first the provider, then "just this one model"). A dedicated file keeps the
rule absolute, so a script can check it. It also keeps data/ free of
Riverpod.
Call chain: Widget → (Async)Notifier → Repository contract → RepositoryImpl → RemoteDataSource → ApiClient. Never skip a layer.
Entities — immutable, extends Equatable, const constructor, no JSON.
Drop wire-only fields (userId the client already knows) in toEntity.
Equatable also makes ref.watch(p.select(...)) work by value.
Repository contract — abstract interface class, methods return
AsyncResult<Entity> / AsyncResult<Unit> (see flutter-result-errors).
Signatures use entities and value objects, never models or SDK types.
Models — live only in data/models/. Factory fromJson (via
json_serializable), toEntity(), and fromEntity when the model is sent
back. Entities never import models. Models never leave the repository.
Endpoints — one abstract final class <X>Endpoints of path constants and
path-building static methods, so URLs are not string literals in data sources.
Remote data source — abstract interface class + Impl that
with RemoteDataSourceGuard, takes an ApiClient, returns AsyncResult<Model>.
No provider in this file.
Repository impl — takes the data source, converts models → entities with
result.map(...), passes failures through. No provider in this file.
di/<feature>_providers.dart — the providers for the two above:
final favoriteRemoteDataSourceProvider = Provider<FavoriteRemoteDataSource>(
(ref) => FavoriteRemoteDataSourceImpl(ref.watch(apiClientProvider)),
);
/// Exposes the CONTRACT, never the implementation. Tests override this.
final favoriteRepositoryProvider = Provider<FavoriteRepository>(
(ref) => FavoriteRepositoryImpl(ref.watch(favoriteRemoteDataSourceProvider)),
);
In a test, override the contract and data/ is never touched:
ProviderContainer(overrides: [
favoriteRepositoryProvider.overrideWithValue(FakeFavoriteRepository()),
]);
Providers (presentation) — one responsibility each. Pick by role:
| Need | Use |
|---|---|
| Immutable dependency (repo, service, client) | Provider |
| Async read-only data | FutureProvider |
| Continuous stream (auth state, connectivity) | StreamProvider |
| Mutable sync state (filters, selected tab) | NotifierProvider |
| Mutable async state (a screen's store, a session) | AsyncNotifierProvider |
| One user action in flight | SubmissionNotifier + autoDispose |
Declare providers explicitly. No riverpod_generator, no @riverpod, no
StateNotifier. Business rules that belong in the domain do not live in
providers.
Pages and widgets — no JSON, no SDKs, no business rules. Side effects
(navigation, snackbars, analytics) are declared with ref.listen in a
<Feature>Listeners widget with a child parameter that wraps the page;
widgets only watch declarative state.
domain/entities)domain/repositories)toEntity (data/models) — then dart run build_runner builddata/datasources)di/ providers (data source + repository, exposed as the contract)AsyncNotifier whose build reads the repository
through di/ and calls getOrThrow())<Feature>Listeners widgetApiClient, repository mapping, notifier
with the repository contract overridden, widget test with fakesscripts/check_boundaries.shscripts/scaffold_feature.sh creates steps 1–8 as compilable stubs with all
barrels, and never overwrites existing files:
# from the Flutter project root
bash <path-to-skill>/scripts/scaffold_feature.sh favorites --entity Favorite
snake_case.--entity Name: PascalCase entity (default: the feature name in PascalCase).--package name: override the package name (default: read from pubspec.yaml).Afterwards: add fields to the entity and model, fill the endpoints, run
dart run build_runner build and dart fix --apply (the stubs' import order
is not lint-sorted), then continue from step 9.
scripts/check_boundaries.sh is plain grep, so it needs no Dart toolchain
and fits in any CI step. Run it from the project root:
bash <path-to-skill>/scripts/check_boundaries.sh # default: lib/features
It exits 1 and lists every violation of these rules, or prints OK:
presentation/ never imports data/domain/ imports no framework or SDK, nor data/, presentation/, di/data/ imports neither presentation/, di/ nor Riverpoddata/ or presentation/Run it after every scaffold, and in CI so the boundary cannot erode.
check_boundaries.sh prints OKdomain/ has no imports from flutter, dio, flutter_riverpod, SDKsdi/ exposes the repository as its contract type, not the ImplListeners widgetWhat 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-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-riverpod3Use when writing or reviewing Riverpod 3 code in a Flutter app WITHOUT code generation - choosing a provider type, wiring dependency injection, writing Notifier or AsyncNotifier classes, using ref.watch / read / listen / select, handling disposal, mounted checks and automatic retry, or when someone proposes riverpod_generator, @riverpod, StateNotifier, Bloc, GetIt or the provider package./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