flutter-riverpod-arch
Skill8 starsChanged 7 months agoMITView on GitHub
Implement Feature-First architecture with Riverpod state management and Flutter Hooks in Flutter applications
In this repository10 other files it gives its agents.
- claude-md-managerSkill
- codebase-onboardingSkill
- coding-rulesSkill
- design-md-generatorSkill
- image-compressorSkill
- knowledge-graph-initSkill
- media-transcriberSkill
- meti-ai-guidelineSkill
- nano-banana-image-genSkill
- nextjs-better-auth-postgres-dockerSkill
The file
We split this skill 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
- Distinctive: line 64
Test Repository, UseCase, controller, and widget behavior with the testing patterns used by this skill.
- Distinctive: line 74
List patterns: Follow the list and sliver rules defined in list.md.
- Distinctive: line 75
Avoid button wrapper widgets for style only: Do not create a custom wrapper widget whose sole purpose is applying a fixed button style.
- Very specific: line 76
Use targeted
MediaQuerystatic methods: Prefer MediaQuery.sizeOf, MediaQuery.paddingOf, MediaQuery.orientationOf etc. - Very specific: line 77
No
LayoutBuilderfor page-level breakpoints: Use ResponsiveLayout (which uses MediaQuery.sizeOf) so the layout decision is based on … - Very specific: line 78
Mouse cursors required on macOS/Web: Every Button variant must include enabledMouseCursor: SystemMouseCursors.click.
- Very specific: line 79
Code generation required: After adding or modifying a @riverpod annotation, always run dart run build_runner build.
≈ “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.
Files
Flutter Riverpod Architecture
Goal
Implements scalable Flutter applications using the Feature-First directory structure, Riverpod (with code generation) for state management, and flutter_hooks / HookConsumerWidget for UI composition. This architecture is a lightweight approach inspired by Domain-Driven Design and Clean Architecture. The design philosophy is three layers — Presentation, Domain, and Infrastructure — and the code-level notation in this skill is UI, UseCase, and Repository. Data source access is encapsulated inside repositories. Applies @Riverpod(keepAlive: true) for repository providers and @riverpod for screen-scoped state.
Layer Mapping (Source of Truth)
| Design philosophy | Code-level notation |
| Presentation | UI |
| Domain | UseCase |
| Infrastructure | Repository |
Decision Logic
Decide whether the task belongs in UI, UseCase, or Repository, whether it is feature-specific or shared, and which Riverpod scope is appropriate.
See architecture.md for structure and naming, providers.md for Repository/UseCase placement, and riverpod.md for provider scope rules.
Instructions
1. Plan the Feature Structure
Identify the feature, confirm whether the implementation is shared or feature-local, and place files in the correct layer before coding.
See architecture.md for directory structure and naming.
2. Implement the Repository Layer
Implement Repository code in the Repository layer and follow the Riverpod/provider rules for Repository providers.
See providers.md for Repository implementation details and riverpod.md for provider scope rules.
3. Implement the UseCase Layer
Implement UseCase code in the UseCase layer for validation, orchestration, and UI-facing state changes.
See providers.md for UseCase patterns and riverpod.md for provider scope rules.
4. Build the UI with HookConsumerWidget
Build UI in the Presentation layer using the patterns required by this skill.
See presentation.md for page and widget structure, riverpod.md for ref.watch / ref.read, and button.md for button and cursor rules.
5. Implement Responsive Layout
Apply the responsive layout rules defined for this skill.
See responsive.md for breakpoint policy and responsive layout patterns.
6. Write Tests
Test Repository, UseCase, controller, and widget behavior with the testing patterns used by this skill.
See testing.md for test structure, overrides, and fake/mock patterns.
Constraints
- Prefer
HookConsumerWidget: This skill usesHookConsumerWidget(withflutter_hooks) for all stateful pages and complex widgets.StatefulWidgetmay be used for isolated, purely local UI state with no Riverpod interaction. - No
ref.read()inbuild:ref.read()must only appear inside event handlers or callbacks, never at the top of abuildmethod to derive reactive UI state. - No
ref.watch()in event handlers:ref.watch()must only appear insidebuild()or a provider'sbuild()method. - No business logic in Views: Widget classes must contain only layout, conditional rendering, and navigation. All data transformation and validation must reside in Use Cases or Repositories.
- List patterns: Follow the list and sliver rules defined in list.md.
- Avoid button wrapper widgets for style only: Do not create a custom wrapper widget whose sole purpose is applying a fixed button style. If you need to encapsulate behavior such as loading state or submission flow, a wrapper is acceptable.
- Use targeted
MediaQuerystatic methods: PreferMediaQuery.sizeOf,MediaQuery.paddingOf,MediaQuery.orientationOfetc. overMediaQuery.of(context)to avoid unnecessary rebuilds. - No
LayoutBuilderfor page-level breakpoints: UseResponsiveLayout(which usesMediaQuery.sizeOf) so the layout decision is based on actual screen width, not parent constraints. - Mouse cursors required on macOS/Web: Every
Buttonvariant must includeenabledMouseCursor: SystemMouseCursors.click. EveryInkWellmust includemouseCursor: SystemMouseCursors.click. - Code generation required: After adding or modifying a
@riverpodannotation, always rundart run build_runner build. - Naming conventions: Files and directories use
snake_case; classes useUpperCamelCase; page classes end inPage; repository classes end inRepository; use case classes use verb-noun format (e.g.,FetchPosts,CreatePost).
Reference Files
- architecture.md — Project structure, directory layout, naming conventions
- providers.md — Repository and use case implementation patterns
- riverpod.md — Provider types,
ref.watchvsref.read, caching, code generation - presentation.md — Page structure, navigation, hooks usage, error handling
- testing.md — Test patterns, mocking strategy,
ProviderContainerusage - button.md — Button patterns,
styleFrom, hover cursor for macOS/Web - list.md —
ListView.builder, Pull-to-Refresh, pagination with Slivers - responsive.md — Breakpoints,
ResponsiveLayout, platform-specific layouts
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
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.

