swift-patterns

Review SwiftUI state management, navigation, and performance patterns.

3|Updated Jan 14, 2014
One-click install
npx skills add https://github.com/prateek/dotfiles --skill swift-patterns-prateek
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-patterns
Source: https://github.com/prateek/dotfiles/tree/main/.agents/skills/swift-patterns
Command: npx skills add https://github.com/prateek/dotfiles --skill swift-patterns-prateek

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides guided, factual SwiftUI state management, navigation, and performance guidance to help AI agents review, refactor, or extend SwiftUI features without enforcing architectural constraints.

Core Features & Use Cases

  • State ownership guidance for @State, @Binding, @Observable, and @Environment, with decision trees.
  • Navigation patterns using NavigationStack, navigationDestination(for:), and sheets, with a single source of truth.
  • Lists, performance patterns, and view composition guidance to enable safe refactors and scalable UI code.
  • Lightweight testing/DI seams that support refactor safety without tool-specific requirements.

Quick Start

Invoke the Swift Patterns skill to review a SwiftUI view for state management and navigation improvements.

Frequently Asked Questions about swift-patterns

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

FAQPage Schema
How do I manage SwiftUI state ownership when refactoring views with @Observable and @Environment?

SwiftUI state ownership is managed by selecting property wrappers like @State, @Binding, @Observable, and @Environment using decision trees. This approach preserves behavior during refactors by ensuring correct ownership boundaries without enforcing rigid architectural mandates.

What's the best way to structure SwiftUI navigation with a single source of truth?

SwiftUI navigation should use a single source of truth with NavigationStack and navigationDestination(for:). This pattern centralizes routing logic, enabling safe refactors of navigation paths and sheets while preventing state synchronization issues across views.

How do I improve SwiftUI list performance and identity during a code review?

SwiftUI list performance is improved by applying stable list identity and performance patterns during code reviews. This ensures scalable UI composition and safe refactors by maintaining consistent element identity, preventing unnecessary view redraws.

Can I use cancellation-aware async work in SwiftUI without adopting a specific architecture?

Cancellation-aware asynchronous work can be implemented in SwiftUI without architectural mandates. The guidance focuses on safe SwiftUI patterns for managing async tasks and cancellation, allowing you to preserve existing behavior while extending features.

Does this SwiftUI refactoring guidance include testing and dependency injection seams?

The guidance includes lightweight testing and dependency injection seams to support refactor safety. These seams are tool-agnostic, meaning they integrate into your existing workflow without requiring specific testing frameworks or tool-specific setups.