swiftui-patterns

Implement SwiftUI architecture patterns with @Observable state and NavigationStack routing.

Updated Sep 13, 2025
One-click install
npx skills add https://github.com/llmh333/employee_management_spring --skill swiftui-patterns-llmh333
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-patterns
Source: https://github.com/llmh333/employee_management_spring/tree/main/.gemini/skills/swiftui-patterns
Command: npx skills add https://github.com/llmh333/employee_management_spring --skill swiftui-patterns-llmh333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

SwiftUI apps can become slow, hard to reason about, and difficult to maintain when state management, view composition, and navigation patterns are inconsistent or outdated.

Core Features & Use Cases

  • Correct modern state management: Choose the right property wrapper and use the Observation framework with @Observable to minimize unnecessary re-renders.
  • Scalable view architecture: Structure view models and data flow so that subviews only invalidate when the specific data they read changes.
  • Type-safe navigation: Build routing using NavigationStack and NavigationPath with an explicit destination model for predictable flows.
  • Performance best practices: Use lazy containers, stable identifiers, and avoid expensive work inside body to reduce rendering overhead.

Quick Start

Apply the patterns in this skill to refactor your SwiftUI screens by replacing ObservableObject patterns with @Observable, composing smaller subviews, and wiring navigation through a NavigationStack-driven Router model.

Frequently Asked Questions about swiftui-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce unnecessary view re-renders in SwiftUI?

Reduce unnecessary SwiftUI view re-renders by adopting the @Observable macro and structuring view models so subviews only invalidate when the specific data they read changes. This narrows the invalidation scope to views actively consuming updated state.

What is the best way to build type-safe navigation in SwiftUI?

Build type-safe SwiftUI navigation by routing with NavigationStack and NavigationPath using an explicit destination model. This approach replaces string-based routing with predictable, compile-time checked navigation flows.

How do I migrate from ObservableObject to the Observable framework in SwiftUI?

Migrate from ObservableObject to the Observable framework by replacing ObservableObject conformances with the @Observable macro, updating property wrappers, and composing smaller subviews to minimize invalidation scope during state updates.

Why is my SwiftUI list slow to scroll and how do I optimize rendering performance?

SwiftUI list rendering becomes slow when expensive work executes inside the body. Optimize performance by using lazy containers, stable identifiers, and reducing invalidation scope to prevent unnecessary recalculations during scrolling.

Can I use these SwiftUI architecture patterns for both iOS and macOS apps?

Yes, these SwiftUI architecture patterns apply to both iOS and macOS apps. The state management, view composition, and NavigationStack routing techniques target responsive UI requirements across Apple platforms.

When should I avoid using @Observable in SwiftUI?

Avoid using @Observable in SwiftUI when integrating with older codebases that still rely on ObservableObject, as the frameworks have different invalidation behaviors. Stick with ObservableObject where legacy compatibility is required.