evanca/flutter-ai-rules/architecture-feature-first
Claude Code and agent skill by evanca/flutter-ai-rules
- community
Checking that the SKILL.md file is still in the repository.
Use when creating a feature, designing folder structure, adding repositories/services/view models, wiring dependency injection, or deciding which layer owns logic.
Install
npx vskill@latest install evanca/flutter-ai-rules/architecture-feature-firstSKILL.md
Flutter Architecture — Feature-First Skill
This skill defines how to design, structure, and implement Flutter applications using the recommended layered architecture with feature-first file organization.
It is state management agnostic: the business logic holder in the UI layer may be named ViewModel, Controller, Cubit, Bloc, Provider, or Notifier — depending on the chosen state management approach. The architectural rules apply equally to all of them.
When to Use
Use this skill when:
- Designing the folder/file structure of a new Flutter app or feature.
- Creating a new View, ViewModel, Repository, or Service.
- Deciding which layer owns a piece of logic.
- Wiring dependency injection between components.
- Adding a domain (logic) layer for complex business logic.
- Refactoring an existing app from type-first to feature-first organization.
1. Layers
Separate every app into a UI Layer and a Data Layer. Add a Logic (Domain) Layer between them only for complex apps.
Rules:
- Only adjacent layers may communicate. The UI layer must never access a Service directly.
- The Logic layer is added only when business logic is too complex for the business logic holder or is reused across multiple screens.
- Data changes always happen in the Data layer (SSOT = Repository). No mutation in UI or Logic layers.
- Follow unidirectional data flow: state flows down (Data → UI), events flow up (UI → Data).
2. Feature-First File Structure
Organize code by feature, not by type. Group all layers belonging to one feature together in a single directory.
Sample directory structure
Each feature directory contains the files needed for that feature, named according to the chosen state management approach:
| Approach | Business logic holder file | |
|---|---|---|
| MVVM / ChangeNotifier | *_viewmodel.dart / *_controller.dart | |
| BLoC | *_cubit.dart / *_bloc.dart | |
| Provider / Riverpod | *_provider.dart / *_notifier.dart |
3. Component Responsibilities
View
- Describes how to present data to the user; keep logic minimal and only UI-related.
- Passes events to the business logic holder in response to user interactions.
- Extract reusable widgets into separate components within a
widgets/subdirectory. - Use
StatelessWidgetwhen possible; keep build methods simple.
Business Logic Holder (ViewModel / Cubit / Controller / Provider)
- Contains logic to convert app data into UI state and maintains current state needed by the view.
- Exposes callbacks (commands) to the View and retrieves/transforms data from repositories.
Repository
- Single Source of Truth (SSOT) for a given type of model data.
- The only class allowed to mutate its data; all other classes read from it.
- Handles caching, error handling, and data refresh logic.
- Transforms raw data from services into domain models.
Service
- Wraps API endpoints and exposes asynchronous response objects.
- Isolates data-loading and holds no state.
4. Domain Layer (Use Cases)
Introduce use cases/interactors only when:
- Logic is complex or does not fit cleanly in the UI or Data layers.
- Logic is reused across multiple business logic holders or merges data from multiple repositories.
Do not add a domain layer for simple CRUD apps.
5. Dependency Injection
Use dependency injection to provide components with their dependencies, enabling testability and flexibility.
- Supply repositories to business logic holders via constructors.
- Supply services to repositories via constructors.
- Define abstract interfaces so implementations can be swapped without changing consumers.
6. Workflow: Add a New Feature
- Create the `features/<name>/` directory with
data/,ui/, and optionallydomain/subdirectories. - Implement the Service — wrap the API endpoints in
data/<name>_api_service.dart. - Implement the Repository — inject the Service, add caching/error handling in
data/<name>_repository.dart. - Implement the ViewModel — inject the Repository, expose UI state and commands in
ui/<name>_viewmodel.dart. - Implement the View — bind to the ViewModel, render state, dispatch events in
ui/<name>_screen.dart. - Register in DI — add the new Service, Repository, and ViewModel to the service locator.
- Verify — confirm the View never accesses the Service directly and data flows unidirectionally.
References
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/architecture-feature-first/SKILL.md
Popularity
- Repository stars
- 492
- Repository forks
- 50
- 7-day trend score
- 31
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 21 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/evanca/flutter-ai-rules/architecture-feature-first)