ios-swiftui-architecture-review
SwiftUI Architecture Review
When to Use This Skill:
- Reviewing EXISTING SwiftUI views/ViewModels
- Code review for architectural violations
- Refactoring guidance for specific files
- Validating state management patterns
When to Use
project-architecture-analystAgent Instead:
- Planning NEW features (uncertain file placement)
- Understanding project-wide architecture
- Major changes affecting multiple modules
- Need to discover existing patterns before implementing
Review Checklist
Separation of Concerns
- Views: presentation only (no business logic, network, DB)
- ViewModels: state + business logic (@Observable or ObservableObject)
- Data access separated from views
State Management
@State- view-local state only@StateObject- view-owned ViewModels (avoid in List rows)@ObservedObject- passed-in ViewModels@Bindable- two-way binding to Observable objects (iOS 17+)@Environment- shared state (read-only preferred)@EnvironmentObject- injected dependencies (check for missing inject)
State Lifecycle Issues
- No retained cycles in ViewModels (@Published closures)
- Proper cleanup in deinit or .onDisappear
- @StateObject not recreated on parent refresh
- Environment values exist before access
Dependency Injection
- Dependencies injected (check project: Swinject, Resolver, Factory, manual)
- No hardcoded singletons in views
- ViewModels receive dependencies
View Composition
- Views are small (single responsibility)
- Complex views broken into components
- Reusable components extracted
Common Issues
| Issue | Fix |
|---|---|
| Business logic in view | Extract to ViewModel |
| Network call in view | Move to ViewModel with task |
| Singleton in view | Inject via DI or @Environment |
| 200+ line view | Break into components |
Severity
- 🔴 Critical: Architecture violation
- 🟡 Improvement: Better pattern available
- 🟢 Enhancement: Optional optimization
More from desquared/agents-rules-skills
shared-bug-investigation
Scientific method expert for systematic bug investigation and root cause analysis. Use when users report bugs, crashes, unexpected behavior, or debugging requests. Applies hypothesis-driven investigation, controlled experiments, and rigorous validation across any programming language or platform.
23android-performance-profiler
Identifies potential performance bottlenecks in Jetpack Compose code including expensive recompositions, unnecessary redraws, and memory issues. Use when code involves lists, animations, complex UI, or when the user asks about performance optimization.
19android-compose-architecture-review
Analyze Jetpack Compose UI hierarchies and suggest MVVM/MVI or other architectural improvements. Use when reviewing existing Compose code, creating new Compose components, analyzing composable structure, or when the user asks about Compose architecture patterns. Best for code review and refactoring guidance.
13android-accessibility-validator
Checks and suggests accessibility improvements for Jetpack Compose and Android Views including TalkBack labels, dynamic text support, and color contrast. Use when creating or modifying UI components, screens, or when the user asks about accessibility.
12android-kotlin-api-design-reviewer
Review function and class interfaces for Kotlin Coding Conventions compliance. Use when creating public APIs, reusable components, library interfaces, or when the user asks for API design review or Kotlin naming conventions.
11flutter-performance-optimizer
Use when Flutter UI has jank, slow scrolling, excessive rebuilds, or memory leaks. Also use when optimizing lists, animations, or complex widget trees, or when the user asks about Flutter rendering performance.
10