← ClaudeAtlas

swiftui-mvvmlisted

Use this skill when working with SwiftUI ViewModels — creating, refactoring, or testing them. Triggers for: setting up a ViewModel for a SwiftUI screen, extracting logic from a View into a ViewModel, migrating from ObservableObject to @Observable, modeling async state (instead of separate Bool flags like isLoading/hasError), injecting dependencies into ViewModels, writing unit tests for @Observable ViewModels, NavigationStack/Router setup, or any question about SwiftUI app architecture. Also use when a SwiftUI View imports too much business logic, when someone asks how to structure a SwiftUI screen 'the modern way,' or when they ask about @State/@Bindable ownership, ViewState patterns, or why their ViewModel shouldn't import SwiftUI.
christim427-rgb/ios-agent-skills · ★ 1 · AI & Automation · score 77
Install: claude install-skill christim427-rgb/ios-agent-skills
> **Approach: Production-First Iterative Refactoring** — This skill is built for production enterprise codebases where stability and reviewability matter more than speed. Architecture changes are delivered through iterative refactoring — small, focused PRs (≤200 lines, single concern) tracked in a `refactoring/` directory. Critical safety issues ship first; cosmetic improvements come last. # SwiftUI MVVM Architecture (iOS 17+) Enterprise-grade SwiftUI MVVM architecture skill. Opinionated: prescribes @Observable ViewModels, Router navigation, constructor injection, ViewState enum, and Repository-based networking. Adopts a **production-first iterative refactoring** approach — every pattern is chosen for testability, reviewability, and safe incremental adoption in large teams. For non-architectural SwiftUI API guidance (animations, modern API replacements, Liquid Glass), use a general SwiftUI skill instead. ## Architecture Layers ``` View Layer → SwiftUI Views. Declarative UI only. Owns ViewModel via @State. ViewModel Layer → @Observable @MainActor final class. Exposes ViewState<T>. Repository Layer → Protocol-based data access. Hides data source details. Service Layer → URLSession, persistence. Injected via protocol. ``` ## Quick Decision Trees ### "Should this View have a ViewModel?" ``` Is there business logic, networking, or complex state? ├── YES → Create @Observable ViewModel └── NO → Is it a reusable UI component (button, card, cell)? ├── YES