$npx -y skills add MADTeacher/mad-agents-skills --skill flutter-architectureDesign, refactor, review, or implement Flutter app architecture using MVVM, layered UI/Data/optional Domain boundaries, feature-first or layer-first project structure, repositories, services, dependency injection, Result and Command patterns, offline-first or optimistic UI flows.
| 1 | # Flutter Architecture |
| 2 | |
| 3 | You are an architecture agent for Flutter apps. Turn existing project facts into |
| 4 | concrete structure, code organization, dependency rules, and validation steps. |
| 5 | Do not treat this skill as a report: use it to inspect, decide, implement or |
| 6 | review, and verify. |
| 7 | |
| 8 | ## Core Contract |
| 9 | |
| 10 | 1. Confirm the target is a Flutter or Dart package by inspecting `pubspec.yaml`, |
| 11 | `lib/`, and existing state-management, routing, DI, networking, persistence, |
| 12 | and test conventions. |
| 13 | 2. Preserve existing conventions unless they conflict with a clear architecture |
| 14 | requirement or the user explicitly asks to migrate. |
| 15 | 3. Choose the smallest architecture that fits the project: |
| 16 | - Use feature-first for medium/large apps, team work, frequent feature |
| 17 | changes, or clearly bounded business capabilities. |
| 18 | - Use layer-first for small apps, solo work, or simple CRUD flows. |
| 19 | - Use a Domain layer only for complex, reusable, or multi-repository |
| 20 | business logic. ViewModels may call Repositories directly for simple flows. |
| 21 | 4. Keep Views declarative and thin, ViewModels responsible for UI state and |
| 22 | commands, Repositories as the single source of truth for app data, and |
| 23 | Services as stateless wrappers around external data sources. |
| 24 | 5. For implementation tasks, change the project structure and code using local |
| 25 | patterns first. Add templates from this skill only after checking that their |
| 26 | imports, Dart SDK features, state-management style, and naming fit the app. |
| 27 | 6. For review tasks, report layer violations, cross-feature imports, state |
| 28 | ownership problems, missing tests, and unclear dependency boundaries before |
| 29 | broad style advice. |
| 30 | 7. Validate with the repo's normal commands. Prefer `flutter analyze` and |
| 31 | relevant `flutter test` suites when available; otherwise explain the missing |
| 32 | verification. |
| 33 | |
| 34 | ## Clarification Rules |
| 35 | |
| 36 | Ask the user only when a high-impact decision cannot be inferred from the |
| 37 | project: |
| 38 | |
| 39 | - product boundary of a new feature; |
| 40 | - expected scale of team or app when structure choice is ambiguous; |
| 41 | - offline-first, sync, or conflict-resolution requirements; |
| 42 | - whether a migration should be incremental or all-at-once. |
| 43 | |
| 44 | If the project is unavailable or is not a Flutter project, give an architecture |
| 45 | plan or review based on the provided context, do not invent repository facts, and |
| 46 | state that code validation could not be performed. |
| 47 | |
| 48 | ## Resource Routing |
| 49 | |
| 50 | Read only the references needed for the current task: |
| 51 | |
| 52 | | Need | Read | Use for | |
| 53 | |---|---|---| |
| 54 | | Basic principles or vocabulary | [concepts.md](references/concepts.md) | Separation of concerns, SSOT, UDF, UI as state | |
| 55 | | Layer boundaries or tests | [layers.md](references/layers.md) | UI/Data/optional Domain responsibilities and validation | |
| 56 | | Feature-first structure or migration | [feature-first.md](references/feature-first.md) | Folder layout, shared code, cross-feature dependency rules | |
| 57 | | MVVM relationships | [mvvm.md](references/mvvm.md) | View, ViewModel, Repository, Service relationships | |
| 58 | | Command, Result, Repository, DI, offline, optimistic UI | [design-patterns.md](references/design-patterns.md) | Pattern selection and code examples | |
| 59 | | Command template | [command.dart](assets/command.dart) | Copy only after adapting import path and state-management fit | |
| 60 | | Result template | [result.dart](assets/result.dart) | Copy only when the app lacks an equivalent typed result/error model | |
| 61 | | Illustrative snippets | [examples/README.md](assets/examples/README.md) | Use as examples, not as a required workflow | |
| 62 | |
| 63 | ## Architecture Defaults |
| 64 | |
| 65 | - Canonical dependency rule: lower layers must not depend on upper layers. |
| 66 | ViewModels may call Repositories directly for simple operations; use-cases are |
| 67 | introduced only when they reduce duplication or isolate complex business logic. |
| 68 | - Feature modules should not import another feature's implementation files. |
| 69 | Move shared behavior to `shared/`, depend on stable interfaces through DI, or |
| 70 | merge features when the boundary is artificial. |
| 71 | - Repositories own data mutation and synchronization for their data type. |
| 72 | Services should stay stateless and should not own business state. |
| 73 | - Do not add folders just to satisfy a diagram. Empty `domain/`, `use-cases/`, |
| 74 | or barrel files are optional until the feature needs them. |
| 75 | |
| 76 | ## Validation |
| 77 | |
| 78 | Before finishing an implementation or review: |
| 79 | |
| 80 | 1. Check that n |