flutter-riverpod-arch
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
More from hukusuke1007/agent-skills
design-md-generator
URL・画像・テキスト要件からAIコーディングエージェント向けのDESIGN.mdを生成するスキル。「example.comをDESIGN.md化して」「このサムネをDESIGN.md化して」「クールでポップなLP用のDESIGN.mdを作って」といったリクエストで使用する。Claude Code / Cursor / Stitch に渡せば一貫したUIを生成できる、getdesign.md / awesome-design-md 準拠の9セクション構成のデザイン仕様書を出力する。CSS解析・画像目視抽出・要件生成の3パターンに対応。
5nextjs-better-auth-postgres-docker
Next.js + Better Auth + PostgreSQL を Docker で構築し、Cloud Run へデプロイするスキル。ローカル開発環境のセットアップから Docker Compose、Dockerfile 作成、Cloud Run + Cloud SQL + Secret Manager を使った本番デプロイまでをカバーする。「Next.js と Better Auth でアプリを作りたい」「Docker で PostgreSQL を使いたい」「Docker で構築したい」「Docker Compose を使いたい」「アプリを Docker 化したい」「Dockerfile を書きたい」「Cloud Run にデプロイしたい」「Cloud SQL や Secret Manager を使いたい」ときに使う。
4image-compressor
添付された複数の画像を一括で圧縮・リサイズするスキル。「画像を圧縮して」「このスクショを軽くして」「リサイズして」「画像を小さくして」などのリクエストで使用する。Pillowで長辺1920pxにリサイズし、JPEG/PNGで出力先ディレクトリに保存する。
3claude-md-manager
AGENTS.md / CLAUDE.mdの作成・編集・整理を行うスキル。CLAUDE.mdを50行以下を推奨とし、詳細ルールはrules/やスキルにモジュール化して分割管理する。以下のリクエストで使用する: (1)「CLAUDE.mdを作って」「AGENTS.mdを整理して」などCLAUDE.mdの新規作成・編集、(2)「ルールを追加して」「rules/に分割して」などルールの追加・分離、(3)「ディレクトリ構成を更新して」など参照の更新、(4) 新しいディレクトリやルールファイルを作成した後のCLAUDE.md反映。
3nano-banana-image-gen
Nano Banana 2(Google Gemini gemini-3.1-flash-image-preview)を使って画像を生成するスキル。「画像を生成して」「〇〇のイラストを作って」「Nano Bananaで画像を作って」「グラレコ風の画像を生成して」などのリクエストで使用する。プロンプトを受け取りpythonスクリプトを実行、タイムスタンプ付きPNGを images/generated/ に出力する。
3meti-ai-guideline
AI事業者ガイドライン(経済産業省・総務省、第1.2版、2026年3月31日)に基づいて、AIに関する取り組みのOK/NG判断・注意点・チェックリストを回答するスキル。以下のような質問で使用する: (1)「学習データに〇〇を使っていいか」「個人情報をAIに入力してもいいか」など具体的な行為のOK/NG確認、(2)「セキュリティ対策は何をすればいいか」「社内AIルールをどう作るか」などガバナンス構築の相談、(3)「AI開発者/提供者/利用者として何をすべきか」など立場別の取り組み確認、(4)「ガイドラインを更新して」などナレッジ更新の指示、(5)「グラレコ画像を生成して」「イラストにまとめて」などガイドライン内容の画像生成プロンプト作成
3