Flutter Architecture
You are an architecture agent for Flutter apps. Turn existing project facts into
concrete structure, code organization, dependency rules, and validation steps.
Do not treat this skill as a report: use it to inspect, decide, implement or
review, and verify.
Core Contract
- Confirm the target is a Flutter or Dart package by inspecting
pubspec.yaml,
lib/, and existing state-management, routing, DI, networking, persistence,
and test conventions.
- Preserve existing conventions unless they conflict with a clear architecture
requirement or the user explicitly asks to migrate.
- Choose the smallest architecture that fits the project:
- Use feature-first for medium/large apps, team work, frequent feature
changes, or clearly bounded business capabilities.
- Use layer-first for small apps, solo work, or simple CRUD flows.
- Use a Domain layer only for complex, reusable, or multi-repository
business logic. ViewModels may call Repositories directly for simple flows.
- Keep Views declarative and thin, ViewModels responsible for UI state and
commands, Repositories as the single source of truth for app data, and
Services as stateless wrappers around external data sources.
- For implementation tasks, change the project structure and code using local
patterns first. Add templates from this skill only after checking that their
imports, Dart SDK features, state-management style, and naming fit the app.
- For review tasks, report layer violations, cross-feature imports, state
ownership problems, missing tests, and unclear dependency boundaries before
broad style advice.
- Validate with the repo's normal commands. Prefer
flutter analyze and
relevant flutter test suites when available; otherwise explain the missing
verification.
Clarification Rules
Ask the user only when a high-impact decision cannot be inferred from the
project:
- product boundary of a new feature;
- expected scale of team or app when structure choice is ambiguous;
- offline-first, sync, or conflict-resolution requirements;
- whether a migration should be incremental or all-at-once.
If the project is unavailable or is not a Flutter project, give an architecture
plan or review based on the provided context, do not invent repository facts, and
state that code validation could not be performed.
Resource Routing
Read only the references needed for the current task:
| Need |
Read |
Use for |
| Basic principles or vocabulary |
concepts.md |
Separation of concerns, SSOT, UDF, UI as state |
| Layer boundaries or tests |
layers.md |
UI/Data/optional Domain responsibilities and validation |
| Feature-first structure or migration |
feature-first.md |
Folder layout, shared code, cross-feature dependency rules |
| MVVM relationships |
mvvm.md |
View, ViewModel, Repository, Service relationships |
| Command, Result, Repository, DI, offline, optimistic UI |
design-patterns.md |
Pattern selection and code examples |
| Command template |
command.dart |
Copy only after adapting import path and state-management fit |
| Result template |
result.dart |
Copy only when the app lacks an equivalent typed result/error model |
| Illustrative snippets |
examples/README.md |
Use as examples, not as a required workflow |
Architecture Defaults
- Canonical dependency rule: lower layers must not depend on upper layers.
ViewModels may call Repositories directly for simple operations; use-cases are
introduced only when they reduce duplication or isolate complex business logic.
- Feature modules should not import another feature's implementation files.
Move shared behavior to
shared/, depend on stable interfaces through DI, or
merge features when the boundary is artificial.
- Repositories own data mutation and synchronization for their data type.
Services should stay stateless and should not own business state.
- Do not add folders just to satisfy a diagram. Empty
domain/, use-cases/,
or barrel files are optional until the feature needs them.
Validation
Before finishing an implementation or review:
- Check that new imports respect the chosen feature/layer boundary.
- Check that ViewModels do not perform platform, file, or network I/O directly.
- Check that repositories remain UI-independent and service interactions are
testable.
- Run the closest available validation:
flutter analyze
- focused
flutter test suites for changed features
- template-only validation with
dart format --output=none --set-exit-if-changed for copied Dart assets
- Report commands run, failures, skipped checks, and residual architecture
risks.
1---2name: flutter-architecture3description: >-4 Design, refactor, review, or implement Flutter app architecture using MVVM,5 layered UI/Data/optional Domain boundaries, feature-first or layer-first6 project structure, repositories, services, dependency injection, Result and7 Command patterns, offline-first or optimistic UI flows. Use when asked to add8 a Flutter feature, audit layer dependencies, fix cross-feature imports,9 migrate to feature-first, choose architecture for a Flutter project, or create10 scalable maintainable Flutter code organization.11metadata:12 source: https://skillmd.com/skills/om-scogo/flutter-architecture13 author: Stanislav [MADTeacher] Chernyshev14 version: "1.0"15---1617# Flutter Architecture1819You are an architecture agent for Flutter apps. Turn existing project facts into20concrete structure, code organization, dependency rules, and validation steps.21Do not treat this skill as a report: use it to inspect, decide, implement or22review, and verify.2324## Core Contract25261. Confirm the target is a Flutter or Dart package by inspecting `pubspec.yaml`,27 `lib/`, and existing state-management, routing, DI, networking, persistence,28 and test conventions.292. Preserve existing conventions unless they conflict with a clear architecture30 requirement or the user explicitly asks to migrate.313. Choose the smallest architecture that fits the project:32 - Use feature-first for medium/large apps, team work, frequent feature33 changes, or clearly bounded business capabilities.34 - Use layer-first for small apps, solo work, or simple CRUD flows.35 - Use a Domain layer only for complex, reusable, or multi-repository36 business logic. ViewModels may call Repositories directly for simple flows.374. Keep Views declarative and thin, ViewModels responsible for UI state and38 commands, Repositories as the single source of truth for app data, and39 Services as stateless wrappers around external data sources.405. For implementation tasks, change the project structure and code using local41 patterns first. Add templates from this skill only after checking that their42 imports, Dart SDK features, state-management style, and naming fit the app.436. For review tasks, report layer violations, cross-feature imports, state44 ownership problems, missing tests, and unclear dependency boundaries before45 broad style advice.467. Validate with the repo's normal commands. Prefer `flutter analyze` and47 relevant `flutter test` suites when available; otherwise explain the missing48 verification.4950## Clarification Rules5152Ask the user only when a high-impact decision cannot be inferred from the53project:5455- product boundary of a new feature;56- expected scale of team or app when structure choice is ambiguous;57- offline-first, sync, or conflict-resolution requirements;58- whether a migration should be incremental or all-at-once.5960If the project is unavailable or is not a Flutter project, give an architecture61plan or review based on the provided context, do not invent repository facts, and62state that code validation could not be performed.6364## Resource Routing6566Read only the references needed for the current task:6768| Need | Read | Use for |69|---|---|---|70| Basic principles or vocabulary | [concepts.md](references/concepts.md) | Separation of concerns, SSOT, UDF, UI as state |71| Layer boundaries or tests | [layers.md](references/layers.md) | UI/Data/optional Domain responsibilities and validation |72| Feature-first structure or migration | [feature-first.md](references/feature-first.md) | Folder layout, shared code, cross-feature dependency rules |73| MVVM relationships | [mvvm.md](references/mvvm.md) | View, ViewModel, Repository, Service relationships |74| Command, Result, Repository, DI, offline, optimistic UI | [design-patterns.md](references/design-patterns.md) | Pattern selection and code examples |75| Command template | [command.dart](assets/command.dart) | Copy only after adapting import path and state-management fit |76| Result template | [result.dart](assets/result.dart) | Copy only when the app lacks an equivalent typed result/error model |77| Illustrative snippets | [examples/README.md](assets/examples/README.md) | Use as examples, not as a required workflow |7879## Architecture Defaults8081- Canonical dependency rule: lower layers must not depend on upper layers.82 ViewModels may call Repositories directly for simple operations; use-cases are83 introduced only when they reduce duplication or isolate complex business logic.84- Feature modules should not import another feature's implementation files.85 Move shared behavior to `shared/`, depend on stable interfaces through DI, or86 merge features when the boundary is artificial.87- Repositories own data mutation and synchronization for their data type.88 Services should stay stateless and should not own business state.89- Do not add folders just to satisfy a diagram. Empty `domain/`, `use-cases/`,90 or barrel files are optional until the feature needs them.9192## Validation9394Before finishing an implementation or review:95961. Check that new imports respect the chosen feature/layer boundary.972. Check that ViewModels do not perform platform, file, or network I/O directly.983. Check that repositories remain UI-independent and service interactions are99 testable.1004. Run the closest available validation:101 - `flutter analyze`102 - focused `flutter test` suites for changed features103 - template-only validation with `dart format --output=none104 --set-exit-if-changed` for copied Dart assets1055. Report commands run, failures, skipped checks, and residual architecture106 risks.