Validate Clean Architecture implementation in iOS. Checks layer separation (Presentation/Domain/Data), MVVM patterns, dependency injection with Swinject, and UseCase/Repository patterns. Use when reviewing architecture, checking layer boundaries, or validating DI.
/plugin marketplace add daispacy/py-claude-marketplace/plugin install py-plugin@py-claude-marketplaceThis skill is limited to using the following tools:
examples.mdVerify Clean Architecture and MVVM implementation in iOS code following Payoo Merchant patterns.
Presentation → ViewControllers, ViewModels, Views Domain → UseCases (business logic), Models, Repository protocols Data → Repository implementations, API Services, Local Storage
Correct Flow:
UI → ViewController → ViewModel → UseCase → Repository → API/DB
Classify files into layers:
*ViewController.swift, *ViewModel.swift*UseCase.swift, *Repository.swift (protocols)*RepositoryImpl.swift, *ApiService.swiftCritical Issues:
BaseViewModel:
✅ class PaymentViewModel: BaseViewModel<PaymentState>
❌ class PaymentViewModel // Should extend BaseViewModel
UseCase Pattern:
✅ protocol PaymentUseCase { }
✅ class PaymentUseCaseImpl: PaymentUseCase { }
❌ class PaymentUseCase { } // Should be protocol + impl
Repository Pattern:
✅ protocol PaymentRepository { } // In Domain
✅ class PaymentRepositoryImpl: PaymentRepository { } // In Data
Dependency Injection:
✅ init(paymentUC: PaymentUseCase) { // Constructor injection
self.paymentUC = paymentUC
}
❌ let paymentUC = PaymentUseCaseImpl() // Direct instantiation
Provide:
class PaymentViewModel {
private let apiService: PaymentApiService // WRONG LAYER!
}
Should be:
class PaymentViewModel {
private let paymentUC: PaymentUseCase // CORRECT!
}
class PaymentViewModel {
func processPayment(amount: Double) {
// ❌ Validation in ViewModel
guard amount > 1000 else { return }
// ❌ Business rules in ViewModel
let fee = amount * 0.01
}
}
Should be in UseCase:
class PaymentUseCaseImpl {
func execute(amount: Double) -> Single<PaymentResult> {
// ✅ Validation in UseCase
return validateAmount(amount)
.flatMap { processPayment($0) }
}
}
# Clean Architecture Review
## Compliance Score: X/100
## Critical Violations: X
### 1. ViewModel Bypassing UseCase
**File**: `PaymentViewModel.swift:15`
**Current**: ViewModel → API
**Should be**: ViewModel → UseCase → Repository → API
**Fix**: [Refactoring steps]
---
## Dependency Graph
### Current (Problematic)
ViewModel → ApiService ❌
### Should Be
ViewModel → UseCase → Repository → ApiService ✅
## Recommendations
1. Create missing UseCases
2. Move business logic to Domain layer
3. Setup DI container
4. Add Repository layer
## Effort Estimate
- Module refactoring: X hours
- DI setup: X hours
- Testing: X hours
Layer Boundaries:
Dependency Injection:
Patterns:
Detailed Examples: See examples.md for complete architecture patterns and refactoring guides.