swiftui-patterns

Provide SwiftUI patterns for state management and NavigationStack navigation.

Updated Dec 25, 2025
One-click install
npx skills add https://github.com/mourato/prisma --skill swiftui-patterns-mourato
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftui-patterns
Source: https://github.com/mourato/prisma/tree/main/.agents/skills/swiftui-patterns
Command: npx skills add https://github.com/mourato/prisma --skill swiftui-patterns-mourato

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides best practices and reusable patterns for building robust, maintainable, and performant SwiftUI interfaces within the Prisma project.

Core Features & Use Cases

  • State Management: Guidance on using @StateObject, @State, and @ObservedObject correctly.
  • Navigation: Implementing type-safe navigation with NavigationStack.
  • Component Reusability: Strategies for leveraging and extending existing design system components.
  • UI Patterns: Examples for view modifiers, layout alignment, and compound buttons.
  • Use Case: Refactor a complex view hierarchy to use @StateObject for better state management and extract common modifiers into reusable View extensions.

Quick Start

Apply the cardStyle() modifier to the Text("Welcome") view.

Frequently Asked Questions about swiftui-patterns

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

FAQPage Schema
When should I use @StateObject vs @State in SwiftUI for state management?

Use @StateObject to create and own observable objects, and @State for simple local view properties. Correct state management prevents unexpected data resets during view redraws.

How do I implement type-safe navigation with NavigationStack in SwiftUI?

Implement NavigationStack by defining a navigation path using type-safe values. This pattern allows route management via value types, replacing fragile string-based navigation to improve maintainability.

What is the best way to reuse and extend SwiftUI design system components?

Adopt a reuse -> extend -> create approach: first check existing design system components, extend them using view modifiers, and only create new views when absolutely necessary to ensure consistency.

How do I extract common SwiftUI view modifiers into reusable extensions?

Extract common modifiers into reusable View extensions by wrapping them in custom modifier functions. This pattern declutters complex view hierarchies and centralizes styling logic like cardStyle().

Does this Skill provide patterns for refactoring complex SwiftUI view hierarchies?

Yes, it provides patterns to refactor complex views by using @StateObject for better state management and extracting common modifiers into reusable View extensions to simplify hierarchy.