Reference location:
.claude/references/DECISION_MATRIX.md
A decision guide for selecting optimal patterns based on the situation.
UseCase Patterns#
โ Standard: Optional Constructor Injection (Pure DI)
UseCase ์ฌ์ฉ? โYesโ Optional Constructor Injection
โNoโ Repository ์ง์ ์ ๊ทผ ๊ธ์ง (UseCase ํตํด์๋ง!)
Pattern#
| Criteria | Optional Constructor Injection |
|---|---|
| Recommended | โ Standard pattern |
| DI Setup | getIt/injectable not needed |
| Testing | Bloc(useCase: mockUseCase) direct injection |
Key Points:
- UseCase:
const UseCase([IRepo? repo]) : _repo = repo ?? ConcreteRepo() - BLoC:
Bloc({UseCase? useCase}) : _useCase = useCase ?? const UseCase() - Test:
Bloc(useCase: mockUseCase)- getIt.reset() Not needed
-> Details: patterns/usecase-patterns.md
BLoC State Pattern Selection#
Clear state separation? โYesโโบ Freezed Union (๊ถ์ฅ)
โ
โNoโโบ Avoid code generation? โYesโโบ Sealed Class
โ
โNoโโบ Single State
Detailed Comparison#
| Criteria | Freezed Union | Sealed Class | Single State |
|---|---|---|---|
| Code Generation | Required | Not needed | Required |
| State Separation | โ Clear | โ Clear | โ ๏ธ Less clear |
| copyWith | โ Auto | โ ๏ธ Manual | โ Auto |
| Pattern Matching | โ when/map | โ switch | โ ๏ธ Conditionals |
| Recommended For | General use | Dart 3.0+, avoiding codegen | Pagination, filtering |
Selection Criteria:
- โ Freezed Union: Clear Initial/Loading/Loaded/Error separation
- โ Sealed Class: Type-safe without code generation
- โ Single State: Multiple state combinations (isLoading + items + hasMore)
-> Details: patterns/bloc-patterns.md
Repository Implementation Pattern Selection#
Need network logic reuse? โYesโโบ Mixin ํจํด (๊ถ์ฅ)
โ
โNoโโบ Multiple data source combination? โYesโโบ Mixin ํจํด
โ
โNoโโบ Direct implementation
Detailed Comparison#
| Criteria | Mixin Pattern | Direct implementation |
|---|---|---|
| Logic Reuse | โ Easy | โ ๏ธ Difficult |
| Structural Complexity | โ ๏ธ Increased | โ Simple |
| Testing | โ Independent Mixin tests | โ ๏ธ Full tests |
| Recommended For | Complex APIs, multiple data sources | Simple CRUD |
Selection Criteria:
- โ Mixin Pattern: API logic reuse, caching layer separation, complex data processing
- โ Direct Implementation: Simple CRUD, quick implementation, no reuse needed
-> Details: patterns/repository-patterns.md
Caching Strategy Selection#
Data changes frequently? โYesโโบ SWR (Stale-While-Revalidate)
โ
โNoโโบ Need offline? โYesโโบ Cache-First
โ
โNoโโบ SWR
Detailed Comparison#
| Criteria | SWR | Cache-First |
|---|---|---|
| Response Speed | โ Instant (cache) + refresh | โ Instant (cache) |
| Network Usage | โ ๏ธ Called every time | โ Skipped when cached |
| Data Freshness | โ Latest | โ ๏ธ Until cache expires |
| Offline Support | โ ๏ธ Only when cached | โ Cache first |
Suitable cases:
| SWR | Cache-First |
|---|---|
| Feed, timeline | User profile |
| Chat messages | App settings |
| Notification List | Category List |
| Real-time status | Static content |
-> Details: patterns/caching-patterns.md
Entity Definition Pattern Selection#
Code generation available? โYesโโบ Freezed (๊ถ์ฅ)
โ
โNoโโบ Dart 3.0+? โYesโโบ Final Class
โ
โNoโโบ ์ผ๋ฐ Class
Detailed Comparison#
| Criteria | Freezed | Final Class | ์ผ๋ฐ Class |
|---|---|---|---|
| copyWith | โ Auto | โ ๏ธ Manual | โ ๏ธ Manual |
| equality | โ Auto | โ ๏ธ Manual | โ ๏ธ Manual |
| Immutability | โ Enforced | โ final Enforced | โ ๏ธ Selection |
| JSON serialization | โ Auto | โ ๏ธ Manual | โ ๏ธ Manual |
UI Component Selection#
Existing component available? โYesโโบ /coui:improve (Improvement)
โ
โNoโโบ Form component? โYesโโบ /coui:form
โ
โNoโโบ Full screen? โYesโโบ /coui:screen
โ
โNoโโบ /coui:component
Test Strategy Selection#
E2E test? โYesโโบ /bdd:generate (BDD ์๋๋ฆฌ์ค)
โ
โNoโโบ BLoC test? โYesโโบ bloc_test ํจํค์ง
โ
โNoโโบ Unit test? โYesโโบ mocktail + flutter_test
Agent Selection Guide#
Feature Development#
| Scenario | Invocation | Description |
|---|---|---|
| Full Feature creation | /feature:create |
Domain + Data + Presentation |
| Domain only | /feature:domain |
Entity, UseCase, Repository Interface |
| Data only | /feature:data | Repository impl, Cache, DAO |
| Presentation only | /feature:presentation | BLoC, Page, Widget |
| BLoC only | /feature:bloc | State management only |
Backend Development#
| Scenario | Invocation | Description |
|---|---|---|
| New model definition | /serverpod:model | .spy.yaml file creation |
| Endpoint creation | /serverpod:endpoint | API endpoints |
UI Development#
| Scenario | Invocation | Description |
|---|---|---|
| Single component | /coui:component | Buttons, cards, etc. |
| Form creation | /coui:form | Complete input form |
| Full screen | /coui:screen | Page composition |
| Existing UI improvement | /coui:improve |
Refactoring, style improvement |
Quick Reference Checklist#
When Starting a New Feature#
/serverpod:model- Backend model definition/serverpod:endpoint- API endpoints/feature:domain- Entity, UseCase Definition/feature:data- Repository Implementation/feature:presentation- BLoC, UI Implementation/bdd:generate- Test scenarios
When Selecting Patterns#
- UseCase โ
patterns/usecase-patterns.md - BLoC State โ
patterns/bloc-patterns.md - Repository โ
patterns/repository-patterns.md - Caching โ
patterns/caching-patterns.md
When Checking Workflow#
- Feature Generation โ
DEPENDENCY_GRAPH.md -
Parallel Execution โ
DEPENDENCY_GRAPH.md#parallel-execution-available-work
Referencing Agents#
- All
/feature:*Agents /serverpod:*Agents/coui:*Agents