[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M730W9XCP9TWDH2HRVTGAT90":3,"skill-same:01M730W9XCP9TWDH2HRVTGAT90":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M730W9XCP9TWDH2HRVTGAT90","swiftui-patterns",null,"SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS\u002FmacOS UI best practices.","SriramGandhiS\u002FSkills","SriramGandhiS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F211849986?v=4","01M72WQCW12BYX71C6WN584TTA","Sriram S","01M72WQCWTJ2RD0ET1X31AF1RC",1,"MIT","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fskills\u002Feverything-claude-code\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: swiftui-patterns\ndescription: SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS\u002FmacOS UI best practices.\n---\n\n# SwiftUI Patterns\n\nModern SwiftUI patterns for building declarative, performant user interfaces on Apple platforms. Covers the Observation framework, view composition, type-safe navigation, and performance optimization.\n\n## When to Activate\n\n- Building SwiftUI views and managing state (`@State`, `@Observable`, `@Binding`)\n- Designing navigation flows with `NavigationStack`\n- Structuring view models and data flow\n- Optimizing rendering performance for lists and complex layouts\n- Working with environment values and dependency injection in SwiftUI\n\n## State Management\n\n### Property Wrapper Selection\n\nChoose the simplest wrapper that fits:\n\n| Wrapper | Use Case |\n|---------|----------|\n| `@State` | View-local value types (toggles, form fields, sheet presentation) |\n| `@Binding` | Two-way reference to parent's `@State` |\n| `@Observable` class + `@State` | Owned model with multiple properties |\n| `@Observable` class (no wrapper) | Read-only reference passed from parent |\n| `@Bindable` | Two-way binding to an `@Observable` property |\n| `@Environment` | Shared dependencies injected via `.environment()` |\n\n### @Observable ViewModel\n\nUse `@Observable` (not `ObservableObject`) — it tracks property-level changes so SwiftUI only re-renders views that read the changed property:\n\n```swift\n@Observable\nfinal class ItemListViewModel {\n    private(set) var items: [Item] = []\n    private(set) var isLoading = false\n    var searchText = \"\"\n\n    private let repository: any ItemRepository\n\n    init(repository: any ItemRepository = DefaultItemRepository()) {\n        self.repository = repository\n    }\n\n    func load() async {\n        isLoading = true\n        defer { isLoading = false }\n        items = (try? await repository.fetchAll()) ?? []\n    }\n}\n```\n\n### View Consuming the ViewModel\n\n```swift\nstruct ItemListView: View {\n    @State private var viewModel: ItemListViewModel\n\n    init(viewModel: ItemListViewModel = ItemListViewModel()) {\n        _viewModel = State(initialValue: viewModel)\n    }\n\n    var body: some View {\n        List(viewModel.items) { item in\n            ItemRow(item: item)\n        }\n        .searchable(text: $viewModel.searchText)\n        .overlay { if viewModel.isLoading { ProgressView() } }\n        .task { await viewModel.load() }\n    }\n}\n```\n\n### Environment Injection\n\nReplace `@EnvironmentObject` with `@Environment`:\n\n```swift\n\u002F\u002F Inject\nContentView()\n    .environment(authManager)\n\n\u002F\u002F Consume\nstruct ProfileView: View {\n    @Environment(AuthManager.self) private var auth\n\n    var body: some View {\n        Text(auth.currentUser?.name ?? \"Guest\")\n    }\n}\n```\n\n## View Composition\n\n### Extract Subviews to Limit Invalidation\n\nBreak views into small, focused structs. When state changes, only the subview reading that state re-renders:\n\n```swift\nstruct OrderView: View {\n    @State private var viewModel = OrderViewModel()\n\n    var body: some View {\n        VStack {\n            OrderHeader(title: viewModel.title)\n            OrderItemList(items: viewModel.items)\n            OrderTotal(total: viewModel.total)\n        }\n    }\n}\n```\n\n### ViewModifier for Reusable Styling\n\n```swift\nstruct CardModifier: ViewModifier {\n    func body(content: Content) -> some View {\n        content\n            .padding()\n            .background(.regularMaterial)\n            .clipShape(RoundedRectangle(cornerRadius: 12))\n    }\n}\n\nextension View {\n    func cardStyle() -> some View {\n        modifier(CardModifier())\n    }\n}\n```\n\n## Navigation\n\n### Type-Safe NavigationStack\n\nUse `NavigationStack` with `NavigationPath` for programmatic, type-safe routing:\n\n```swift\n@Observable\nfinal class Router {\n    var path = NavigationPath()\n\n    func navigate(to destination: Destination) {\n        path.append(destination)\n    }\n\n    func popToRoot() {\n        path = NavigationPath()\n    }\n}\n\nenum Destination: Hashable {\n    case detail(Item.ID)\n    case settings\n    case profile(User.ID)\n}\n\nstruct RootView: View {\n    @State private var router = Router()\n\n    var body: some View {\n        NavigationStack(path: $router.path) {\n            HomeView()\n                .navigationDestination(for: Destination.self) { dest in\n                    switch dest {\n                    case .detail(let id): ItemDetailView(itemID: id)\n                    case .settings: SettingsView()\n                    case .profile(let id): ProfileView(userID: id)\n                    }\n                }\n        }\n        .environment(router)\n    }\n}\n```\n\n## Performance\n\n### Use Lazy Containers for Large Collections\n\n`LazyVStack` and `LazyHStack` create views only when visible:\n\n```swift\nScrollView {\n    LazyVStack(spacing: 8) {\n        ForEach(items) { item in\n            ItemRow(item: item)\n        }\n    }\n}\n```\n\n### Stable Identifiers\n\nAlways use stable, unique IDs in `ForEach` — avoid using array indices:\n\n```swift\n\u002F\u002F Use Identifiable conformance or explicit id\nForEach(items, id: \\.stableID) { item in\n    ItemRow(item: item)\n}\n```\n\n### Avoid Expensive Work in body\n\n- Never perform I\u002FO, network calls, or heavy computation inside `body`\n- Use `.task {}` for async work — it cancels automatically when the view disappears\n- Use `.sensoryFeedback()` and `.geometryGroup()` sparingly in scroll views\n- Minimize `.shadow()`, `.blur()`, and `.mask()` in lists — they trigger offscreen rendering\n\n### Equatable Conformance\n\nFor views with expensive bodies, conform to `Equatable` to skip unnecessary re-renders:\n\n```swift\nstruct ExpensiveChartView: View, Equatable {\n    let dataPoints: [DataPoint] \u002F\u002F DataPoint must conform to Equatable\n\n    static func == (lhs: Self, rhs: Self) -> Bool {\n        lhs.dataPoints == rhs.dataPoints\n    }\n\n    var body: some View {\n        \u002F\u002F Complex chart rendering\n    }\n}\n```\n\n## Previews\n\nUse `#Preview` macro with inline mock data for fast iteration:\n\n```swift\n#Preview(\"Empty state\") {\n    ItemListView(viewModel: ItemListViewModel(repository: EmptyMockRepository()))\n}\n\n#Preview(\"Loaded\") {\n    ItemListView(viewModel: ItemListViewModel(repository: PopulatedMockRepository()))\n}\n```\n\n## Anti-Patterns to Avoid\n\n- Using `ObservableObject` \u002F `@Published` \u002F `@StateObject` \u002F `@EnvironmentObject` in new code — migrate to `@Observable`\n- Putting async work directly in `body` or `init` — use `.task {}` or explicit load methods\n- Creating view models as `@State` inside child views that don't own the data — pass from parent instead\n- Using `AnyView` type erasure — prefer `@ViewBuilder` or `Group` for conditional views\n- Ignoring `Sendable` requirements when passing data to\u002Ffrom actors\n\n## References\n\nSee skill: `swift-actor-persistence` for actor-based persistence patterns.\nSee skill: `swift-protocol-di-testing` for protocol-based DI and testing with Swift Testing.\n","# SwiftUI Patterns\n\nModern SwiftUI patterns for building declarative, performant user interfaces on Apple platforms. Covers the Observation framework, view composition, type-safe navigation, and performance optimization.\n\n## When to Activate\n\n- Building SwiftUI views and managing state (`@State`, `@Observable`, `@Binding`)\n- Designing navigation flows with `NavigationStack`\n- Structuring view models and data flow\n- Optimizing rendering performance for lists and complex layouts\n- Working with environment values and dependency injection in SwiftUI\n\n## State Management\n\n### Property Wrapper Selection\n\nChoose the simplest wrapper that fits:\n\n| Wrapper | Use Case |\n|---------|----------|\n| `@State` | View-local value types (toggles, form fields, sheet presentation) |\n| `@Binding` | Two-way reference to parent's `@State` |\n| `@Observable` class + `@State` | Owned model with multiple properties |\n| `@Observable` class (no wrapper) | Read-only reference passed from parent |\n| `@Bindable` | Two-way binding to an `@Observable` property |\n| `@Environment` | Shared dependencies injected via `.environment()` |\n\n### @Observable ViewModel\n\nUse `@Observable` (not `ObservableObject`) — it tracks property-level changes so SwiftUI only re-renders views that read the changed property:\n\n```swift\n@Observable\nfinal class ItemListViewModel {\n    private(set) var items: [Item] = []\n    private(set) var isLoading = false\n    var searchText = \"\"\n\n    private let repository: any ItemRepository\n\n    init(repository: any ItemRepository = DefaultItemRepository()) {\n        self.repository = repository\n    }\n\n    func load() async {\n        isLoading = true\n        defer { isLoading = false }\n        items = (try? await repository.fetchAll()) ?? []\n    }\n}\n```\n\n### View Consuming the ViewModel\n\n```swift\nstruct ItemListView: View {\n    @State private var viewModel: ItemListViewModel\n\n    init(viewModel: ItemListViewModel = ItemListViewModel()) {\n        _viewModel = State(initialValue: viewModel)\n    }\n\n    var body: some View {\n        List(viewModel.items) { item in\n            ItemRow(item: item)\n        }\n        .searchable(text: $viewModel.searchText)\n        .overlay { if viewModel.isLoading { ProgressView() } }\n        .task { await viewModel.load() }\n    }\n}\n```\n\n### Environment Injection\n\nReplace `@EnvironmentObject` with `@Environment`:\n\n```swift\n\u002F\u002F Inject\nContentView()\n    .environment(authManager)\n\n\u002F\u002F Consume\nstruct ProfileView: View {\n    @Environment(AuthManager.self) private var auth\n\n    var body: some View {\n        Text(auth.currentUser?.name ?? \"Guest\")\n    }\n}\n```\n\n## View Composition\n\n### Extract Subviews to Limit Invalidation\n\nBreak views into small, focused structs. When state changes, only the subview reading that state re-renders:\n\n```swift\nstruct OrderView: View {\n    @State private var viewModel = OrderViewModel()\n\n    var body: some View {\n        VStack {\n            OrderHeader(title: viewModel.title)\n            OrderItemList(items: viewModel.items)\n            OrderTotal(total: viewModel.total)\n        }\n    }\n}\n```\n\n### ViewModifier for Reusable Styling\n\n```swift\nstruct CardModifier: ViewModifier {\n    func body(content: Content) -> some View {\n        content\n            .padding()\n            .background(.regularMaterial)\n            .clipShape(RoundedRectangle(cornerRadius: 12))\n    }\n}\n\nextension View {\n    func cardStyle() -> some View {\n        modifier(CardModifier())\n    }\n}\n```\n\n## Navigation\n\n### Type-Safe NavigationStack\n\nUse `NavigationStack` with `NavigationPath` for programmatic, type-safe routing:\n\n```swift\n@Observable\nfinal class Router {\n    var path = NavigationPath()\n\n    func navigate(to destination: Destination) {\n        path.append(destination)\n    }\n\n    func popToRoot() {\n        path = NavigationPath()\n    }\n}\n\nenum Destination: Hashable {\n    case detail(Item.ID)\n    case settings\n    case profile(User.ID)\n}\n\nstruct RootView: View {\n    @State private var router = Router()\n\n    var body: some View {\n        NavigationStack(path: $router.path) {\n            HomeView()\n                .navigationDestination(for: Destination.self) { dest in\n                    switch dest {\n                    case .detail(let id): ItemDetailView(itemID: id)\n                    case .settings: SettingsView()\n                    case .profile(let id): ProfileView(userID: id)\n                    }\n                }\n        }\n        .environment(router)\n    }\n}\n```\n\n## Performance\n\n### Use Lazy Containers for Large Collections\n\n`LazyVStack` and `LazyHStack` create views only when visible:\n\n```swift\nScrollView {\n    LazyVStack(spacing: 8) {\n        ForEach(items) { item in\n            ItemRow(item: item)\n        }\n    }\n}\n```\n\n### Stable Identifiers\n\nAlways use stable, unique IDs in `ForEach` — avoid using array indices:\n\n```swift\n\u002F\u002F Use Identifiable conformance or explicit id\nForEach(items, id: \\.stableID) { item in\n    ItemRow(item: item)\n}\n```\n\n### Avoid Expensive Work in body\n\n- Never perform I\u002FO, network calls, or heavy computation inside `body`\n- Use `.task {}` for async work — it cancels automatically when the view disappears\n- Use `.sensoryFeedback()` and `.geometryGroup()` sparingly in scroll views\n- Minimize `.shadow()`, `.blur()`, and `.mask()` in lists — they trigger offscreen rendering\n\n### Equatable Conformance\n\nFor views with expensive bodies, conform to `Equatable` to skip unnecessary re-renders:\n\n```swift\nstruct ExpensiveChartView: View, Equatable {\n    let dataPoints: [DataPoint] \u002F\u002F DataPoint must conform to Equatable\n\n    static func == (lhs: Self, rhs: Self) -> Bool {\n        lhs.dataPoints == rhs.dataPoints\n    }\n\n    var body: some View {\n        \u002F\u002F Complex chart rendering\n    }\n}\n```\n\n## Previews\n\nUse `#Preview` macro with inline mock data for fast iteration:\n\n```swift\n#Preview(\"Empty state\") {\n    ItemListView(viewModel: ItemListViewModel(repository: EmptyMockRepository()))\n}\n\n#Preview(\"Loaded\") {\n    ItemListView(viewModel: ItemListViewModel(repository: PopulatedMockRepository()))\n}\n```\n\n## Anti-Patterns to Avoid\n\n- Using `ObservableObject` \u002F `@Published` \u002F `@StateObject` \u002F `@EnvironmentObject` in new code — migrate to `@Observable`\n- Putting async work directly in `body` or `init` — use `.task {}` or explicit load methods\n- Creating view models as `@State` inside child views that don't own the data — pass from parent instead\n- Using `AnyView` type erasure — prefer `@ViewBuilder` or `Group` for conditional views\n- Ignoring `Sendable` requirements when passing data to\u002Ffrom actors\n\n## References\n\nSee skill: `swift-actor-persistence` for actor-based persistence patterns.\nSee skill: `swift-protocol-di-testing` for protocol-based DI and testing with Swift Testing.\n",{"name":5,"description":7},"master","d6ca01da0f24a3b0e26e4a8b7b66cbd25d429f5d","skills\u002Feverything-claude-code\u002Fskills\u002Fswiftui-patterns",0,"https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills","https:\u002F\u002Fgithub.com\u002FSriramGandhiS","https:\u002F\u002Fsriram.website\u002F","Curious guy who keeps tinkering until something works","2026-05-20 16:21:34",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add SriramGandhiS\u002FSkills --skill swiftui-patterns",{"tool":39,"command":40},"bunx","bunx skills add SriramGandhiS\u002FSkills --skill swiftui-patterns",{"tool":42,"command":43},"pnpm","pnpm dlx skills add SriramGandhiS\u002FSkills --skill swiftui-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fskills\u002Feverything-claude-code\u002Fskills\u002Fswiftui-patterns\u002FSKILL.md",true,[],[48,55,60,66,73,80],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M732609EPJWV13PVTX3GT4TM","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":56,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7325XM47AGWB6K6C4VXKE6B","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7325WP6DES69JKC840VMFEP","verification-loop","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fverification-loop\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7325TFQF1DZTQ6J3WGQQ1VR","tdd-workflow","Use this skill when writing new features, fixing bugs, or refactoring code. Enforces test-driven development with 80%+ coverage including unit, integration, and E2E tests.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Ftdd-workflow\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7325RGV9AY9PK92D2V8KKPW","strategic-compact","Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fstrategic-compact\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7325MZC28SE86E7NMCNEFS4","security-review","Use this skill when adding authentication, handling user input, working with secrets, creating API endpoints, or implementing payment\u002Fsensitive features. Provides comprehensive security checklist and patterns.","https:\u002F\u002Fgithub.com\u002FSriramGandhiS\u002FSkills\u002Fblob\u002Fmaster\u002Fweb-assets\u002Fdocs\u002Fzh-TW\u002Fskills\u002Fsecurity-review\u002FSKILL.md",[],[]]