Agent skill · affaan-m

swiftui-patterns

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices. Use when building or reviewing SwiftUI views, @Observable state, navigation, or render performance.

What it needs

About 3k tokens when loaded.

What this skill does

SwiftUI Patterns Modern SwiftUI patterns for building declarative, performant user interfaces on Apple platforms. Covers the Observation framework, view composition, type-safe navigation, and performance optimization. When to Activate Building SwiftUI views and managing state (@State, @Observable, @Binding) Designing navigation flows with NavigationStack Structuring view models and data flow Optimizing rendering performance for lists and complex layouts Working with environment values and dependency injection in SwiftUI State Management Property Wrapper Selection Choose the simplest wrapper that fits: Wrapper Use Case --------- ---------- @State View-local value types (toggles, form fields, sheet presentation) @Binding Two-way reference to parent's @State @Observable class + @State Owned model with multiple properties @Observable class (no wrapper) Read-only reference passed from parent @Bindable Two-way binding to an @Observable property @Environment Shared dependencies injected via .environment() @Observable ViewModel Use @Observable (not ObservableObject) — it tracks property-level changes so SwiftUI only re-renders views that read the changed property: View Consuming the ViewModel Environment Injection Replace @EnvironmentObject with @Environment: View Composition Extract Subviews to Limit Invalidation Break views into small, focused structs. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/swiftui-patterns--3243f7

View the source on GitHub

Browse the @skills marketplace