4.6 KiB
4.6 KiB
Agent Development Rules
These rules are NON-NEGOTIABLE. They are designed to prevent architectural degradation by automated agents.
1. File Creation & Structure
- Feature-First Packaging:
- DO: Create new features as independent packages in
packages/features/<feature_name>. - DO NOT: Add features to
packages/coreor existing apps directly.
- DO: Create new features as independent packages in
- Path Conventions:
- Entities:
packages/domain/lib/src/entities/<entity>.dart - Repositories (Interface):
packages/<feature>/lib/src/domain/repositories/<name>_repository_interface.dart - Repositories (Impl):
packages/<feature>/lib/src/data/repositories_impl/<name>_repository_impl.dart - Use Cases:
packages/<feature>/lib/src/application/<name>_usecase.dart - BLoCs:
packages/<feature>/lib/src/presentation/blocs/<name>_bloc.dart - Pages:
packages/<feature>/lib/src/presentation/pages/<name>_page.dart
- Entities:
- Barrel Files:
- DO: Use
exportinlib/<package_name>.dartonly for public APIs. - DO NOT: Export internal implementation details (like mocks or helper widgets) in the main package file.
- DO: Use
2. Naming Conventions
Follow Dart standards strictly.
| Type | Convention | Example |
|---|---|---|
| Files | snake_case |
user_profile_page.dart |
| Classes | PascalCase |
UserProfilePage |
| Variables | camelCase |
userProfile |
| Interfaces | terminate with Interface |
AuthRepositoryInterface |
| Implementations | terminate with Impl |
FirebaseDataConnectAuthRepositoryImpl |
| Mocks | terminate with Mock |
AuthRepositoryMock |
3. Logic Placement (Strict Boundaries)
- Business Rules: MUST reside in Use Cases (Domain/Feature Application layer).
- Forbidden: Placing business rules in BLoCs or Widgets.
- State Logic: MUST reside in BLoCs.
- Forbidden:
setStatein Pages (except for purely ephemeral UI animations).
- Forbidden:
- Data Transformation: MUST reside in Repositories (Data Connect layer).
- Forbidden: Parsing JSON in the UI or Domain.
- Navigation Logic: MUST reside in Modular Routes.
- Forbidden:
Navigator.pushwith hardcoded widgets.
- Forbidden:
4. Data Connect Mocking Strategy
Since the backend does not exist, you must mock strictly:
- Define Interface: Create
abstract interface class <name>RepositoryInterfaceinpackages/<feature>/lib/src/domain/repositories/<name>_repository_interface.dart. - Create Mock: Create
class MockRepository implements IRepositoryinpackages/data_connect/lib/src/mocks/. - Fake Data: Return hardcoded
Futures with realistic dummy entities. - Injection: Register the
MockRepositoryin theAppModule(inapps/clientorapps/staff) until the real implementation exists.
DO NOT use mockito or mocktail for these runtime mocks. Use simple fake classes.
5. Prototype Migration Rules
You have access to prototypes/ folders. When migrating code:
- Extract Assets:
- You MAY copy icons, images, and colors. But they should be tailored to the current design system. Do not change the colours and typgorahys in the design system. They are final. And you have to use these in the UI.
- When you matching colous and typography, from the POC match it with the design system and use the colors and typography from the design system. As mentioned in the
docs/03-design-system-usage.md.
- When you matching colous and typography, from the POC match it with the design system and use the colors and typography from the design system. As mentioned in the
- You MAY copy icons, images, and colors. But they should be tailored to the current design system. Do not change the colours and typgorahys in the design system. They are final. And you have to use these in the UI.
- Extract Layouts: You MAY copy
buildmethods for UI structure. - REJECT Architecture: You MUST NOT copy the
GetX,Provider, orMVCpatterns often found in prototypes. Refactor immediately to Bloc + Clean Architecture with Flutter Modular and Melos.
6. Handling Ambiguity
If a user request is vague:
- STOP: Do not guess domain fields or workflows.
- ANALYZE:
- For architecture related questions, refer to
docs/01-architecture-principles.mdor existing code. - For design system related questions, refer to
docs/03-design-system-usage.mdor existing code.
- DOCUMENT: If you must make an assumption to proceed, add a comment
// ASSUMPTION: <explanation>and mention it in your final summary. - ASK: Prefer asking the user for clarification on business rules (e.g., "Should a 'Job' have a 'status'?").
7. Dependencies
- DO NOT add 3rd party packages without checking
packages/corefirst. - DO NOT add
firebase_authorcloud_firestoreto any Feature package. They belong indata_connectonly.
8. Follow Clean Code Principles
- Add doc comments to all classes and methods you create.