swiftui-ui-patterns

Compose scalable layouts with stacks and grids in SwiftUI development workflows.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/irchamaji/agents --skill swiftui-ui-patterns-irchamaji
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-ui-patterns
Source: https://github.com/irchamaji/agents/tree/main/skills/swiftui-ui-patterns
Command: npx skills add https://github.com/irchamaji/agents --skill swiftui-ui-patterns-irchamaji

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill solves the problem of inconsistent, fragile SwiftUI UI implementations by providing component-level, example-driven guidance for building views that scale with navigation, sheets, and modern state management.

Core Features & Use Cases

  • Navigation & tabbed architecture: guidance for structuring per-tab NavigationStack routing patterns and keeping navigation history predictable.
  • State ownership & data flow: clear rules for when to use @State, @Binding, @Environment, and @Observable, including iOS 17 vs iOS 16 fallbacks.
  • Sheets & presentation patterns: enum-driven, centralized sheet routing that avoids brittle boolean combinations and keeps modals owning their confirm/cancel actions.
  • Async loading & lifecycle: recommends .task vs .task(id:), cancellation-safe async work, and explicit loading/error UI states.
  • Responsive layout composition: guidance for building declarative iOS interfaces using stacks and grids, with attention to performance and render-cost guardrails.

Quick Start

Use the swiftui-ui-patterns skill to refactor a SwiftUI screen into small composable subviews with correct state ownership and centralized navigation/sheet patterns.

Frequently Asked Questions about swiftui-ui-patterns

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

FAQPage Schema
How do I manage SwiftUI state ownership correctly across iOS 16 and iOS 17?

SwiftUI state ownership requires choosing @State for local UI, @Binding for child dependencies, and @Observable for iOS 17 shared models, with @StateObject fallbacks for iOS 16. Apply clear rules for data flow property wrappers to ensure reliable screen composition.

What's the best way to handle sheet routing in SwiftUI without brittle boolean flags?

Sheet routing in SwiftUI is best handled using enum-driven centralized presentation logic. This avoids brittle boolean combinations by mapping sheet destinations to enumeration cases, keeping modals owning their confirm and cancel actions for predictable modal navigation.

How do I structure per-tab NavigationStack routing patterns in SwiftUI?

Per-tab NavigationStack routing requires structuring each TabView tab with its own navigation path to keep history predictable. This skill guides designing tab architectures that isolate routing state per tab to prevent cross-tab navigation conflicts.

How do I implement cancellation-safe async loading in SwiftUI using .task?

Cancellation-safe async loading in SwiftUI uses .task or .task(id:) to bind loading lifecycles to view appearance. Using .task(id:) ensures previous tasks cancel automatically when identifiers change, providing explicit loading and error UI states.

What are common SwiftUI anti-patterns for component composition and how do I avoid them?

Common SwiftUI anti-patterns include creating giant monolithic views and building redundant gesture state machines. This skill guides refactoring screens into small composable subviews with correct state ownership to avoid these structural fragility issues.

Does this SwiftUI skill provide guidance on responsive layout composition using stacks and grids?

Yes, this SwiftUI skill provides guidance on responsive layout composition using stacks and grids. It includes performance and render-cost guardrails for declarative iOS interfaces to ensure efficient component-level patterns and minimum OS-aware API selection.