What problem does it solve?
This skill guides developers in refactoring and reviewing SwiftUI view files to enforce a consistent structure, safe dependency injection, and careful observation usage. It helps teams standardize layout/ordering, handle view-models safely (prefer non-optional when possible), and ensure dependencies and @Observable state are initialized and passed correctly.
Core Features & Use Cases
- Consistent structure: Enforces a top-to-bottom ordering of SwiftUI view components and stored properties.
- MV-first guidance: Encourages lightweight views and proper separation of business logic into services/models, using @Environment, @State, @Query, and task/onChange for orchestration.
- Safety & maintainability: Promotes non-optional view models when present, clear dependency injection, and readable, composable subviews.
- Use Case: When refactoring large SwiftUI views, apply these guidelines to reduce boilerplate and improve testability.
Quick Start
Open your SwiftUI view file and apply the ordering and patterns described to reorganize the view, inject dependencies via Environment, and extract complex sections into subviews as needed. Then run the app to verify behavior remains unchanged.