flutter-clean-arch
Skill12 starsChanged 56 days agoMITView on GitHub
Use when creating or auditing the layers of a Flutter feature or package - where a use case, repository, datasource, entity or model belongs; whether domain may import Flutter; whether a dependency between layers is inverted. Triggers on "where does this go?" in a feature, or a request for an architecture review.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- GustavoAlecio/claude-setuptheir own version, first seen Oct 16, 2026
- duckyman-ai/agent-skillstheir own version, first seen May 18, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- duckyman-ai/agent-skills★ 1same name
- GustavoAlecio/claude-setup★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- flutter-accessibilitySkill
- flutter-cachingSkill
- flutter-concurrencySkill
- flutter-dart-styleSkill
- flutter-design-systemSkill
- flutter-diSkill
- flutter-formsSkill
- flutter-monorepoSkill
- flutter-new-moduleSkill
- flutter-runSkill
- flutter-stateSkill
- flutter-store-cdSkill
- flutter-testingSkill
- flutter-themingSkill
- flutter-webSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 2 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 29
When argument is scaffold or no argument, create all layers for <feature_name>:
- Very specific: line 191
Read the existing code for <feature_name> and check:
- Very specific: line 193
Domain isolation: Do entities import anything from Flutter/Dio/external?
- Distinctive: line 215
Read existing domain/data files before creating new ones
- Very specific: line 216
Check core/lib/injections.dart to see what's already registered
- Distinctive: line 217
Only create layers that don't exist yet
- Very specific: line 218
After scaffolding, run /flutter-di to register new dependencies
- Very specific: line 219
After DI, run /flutter-state to create the Cubit
≈ “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
You are working with Clean Architecture in a Flutter project.
Layer Responsibilities
┌─────────────────────────────────────────┐
│ PRESENTATION │
│ Modules, Screens, Controllers (Cubits) │
│ Only knows: Domain entities + Usecases │
├─────────────────────────────────────────┤
│ DOMAIN (pure Dart, no Flutter) │
│ Entities, Repository interfaces, │
│ Usecases │
│ Depends on: nothing │
├─────────────────────────────────────────┤
│ DATA │
│ Models, Datasources, Repo impls │
│ Depends on: Domain interfaces + Dio │
└─────────────────────────────────────────┘Full Feature Scaffold
When argument is scaffold or no argument, create all layers for <feature_name>:
Domain Layer
entity (domain/entities/<feature>.dart):
import 'package:equatable/equatable.dart';
class <Feature> extends Equatable {
final String id;
final String name;
// Add all business-relevant fields (no JSON, no framework types)
const <Feature>({
required this.id,
required this.name,
});
@override
List<Object?> get props => [id, name];
<Feature> copyWith({String? id, String? name}) => <Feature>(
id: id ?? this.id,
name: name ?? this.name,
);
}repository interface (domain/repositories/<feature>_repository.dart):
import '../entities/<feature>.dart';
abstract class <Feature>Repository {
Future<List<<Feature>>> getAll();
Future<<Feature>> getById(String id);
Future<void> create(<Feature> entity);
Future<void> update(<Feature> entity);
Future<void> delete(String id);
}usecases (domain/usecases/<feature>/):
Each usecase = one file, one responsibility:
// get_<feature>s_usecase.dart
class Get<Feature>sUsecase {
final <Feature>Repository _repository;
Get<Feature>sUsecase(this._repository);
Future<List<<Feature>>> call() => _repository.getAll();
}
// create_<feature>_usecase.dart
class Create<Feature>Usecase {
final <Feature>Repository _repository;
Create<Feature>Usecase(this._repository);
Future<void> call(<Feature> entity) => _repository.create(entity);
}Data Layer
model (data/models/<feature>_model.dart):
import '../../domain/entities/<feature>.dart';
class <Feature>Model {
final String id;
final String name;
const <Feature>Model({required this.id, required this.name});
factory <Feature>Model.fromJson(Map<String, dynamic> json) =>
<Feature>Model(
id: json['id'] as String,
name: json['name'] as String,
);
Map<String, dynamic> toJson() => {'id': id, 'name': name};
<Feature> toEntity() => <Feature>(id: id, name: name);
static <Feature>Model fromEntity(<Feature> entity) =>
<Feature>Model(id: entity.id, name: entity.name);
}datasource (data/datasources/<feature>_datasource.dart):
import 'package:dio/dio.dart';
import '../models/<feature>_model.dart';
class <Feature>Datasource {
final Dio _dio;
<Feature>Datasource(this._dio);
Future<List<<Feature>Model>> getAll() async {
final response = await _dio.get('/<feature>s');
return (response.data as List)
.map((e) => <Feature>Model.fromJson(e as Map<String, dynamic>))
.toList();
}
Future<<Feature>Model> getById(String id) async {
final response = await _dio.get('/<feature>s/$id');
return <Feature>Model.fromJson(response.data as Map<String, dynamic>);
}
Future<void> create(<Feature>Model model) async {
await _dio.post('/<feature>s', data: model.toJson());
}
Future<void> update(<Feature>Model model) async {
await _dio.put('/<feature>s/${model.id}', data: model.toJson());
}
Future<void> delete(String id) async {
await _dio.delete('/<feature>s/$id');
}
}repository impl (data/repositories/<feature>_repository_impl.dart):
import '../../domain/entities/<feature>.dart';
import '../../domain/repositories/<feature>_repository.dart';
import '../datasources/<feature>_datasource.dart';
import '../models/<feature>_model.dart';
class <Feature>RepositoryImpl implements <Feature>Repository {
final <Feature>Datasource _dataSource;
<Feature>RepositoryImpl(this._dataSource);
@override
Future<List<<Feature>>> getAll() async {
final models = await _dataSource.getAll();
return models.map((m) => m.toEntity()).toList();
}
@override
Future<<Feature>> getById(String id) async {
final model = await _dataSource.getById(id);
return model.toEntity();
}
@override
Future<void> create(<Feature> entity) =>
_dataSource.create(<Feature>Model.fromEntity(entity));
@override
Future<void> update(<Feature> entity) =>
_dataSource.update(<Feature>Model.fromEntity(entity));
@override
Future<void> delete(String id) => _dataSource.delete(id);
}When argument is audit
Read the existing code for <feature_name> and check:
- Domain isolation: Do entities import anything from Flutter/Dio/external? (They shouldn't)
- Repository pattern: Does the datasource return models? Does the repo impl map to entities?
- Usecase single responsibility: Does each usecase do exactly one thing?
- Dependency direction: Does data layer depend on domain? (Yes, correct) Does domain depend on data? (No, wrong)
- Model ↔ Entity separation: Are API models separate from domain entities?
- Exception handling: Are data-layer exceptions caught and re-thrown as domain exceptions?
Report findings and fix any violations.
Architecture Rules
- Domain layer has zero external dependencies — pure Dart, no Flutter, no Dio
- Entities use Equatable — value equality for BLoC state comparisons
- Models handle JSON — entities never have
fromJson/toJson - Repository interface in domain — implementation in data
- Usecases are thin — orchestrate repo calls, no business logic in datasources
- One usecase = one operation — don't create
MenuUsecaseswith 5 methods - Datasources return models — repositories return entities
- Exceptions: datasource throws HTTP exceptions, repository catches and rethrows domain exceptions
Instructions
- Read existing domain/data files before creating new ones
- Check
core/lib/injections.dartto see what's already registered - Only create layers that don't exist yet
- After scaffolding, run
/flutter-dito register new dependencies - After DI, run
/flutter-stateto create the Cubit
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.

