swiftui-expert-skill
Frontend & Expérience UX"Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, modern APIs, Swift concurrency, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns."
Documentation
SwiftUI Expert Skill
Overview
Use this skill to build, review, or improve SwiftUI features with correct state management, modern API usage, Swift concurrency best practices, optimal view composition, and iOS 26+ Liquid Glass styling. Prioritize native APIs, Apple design guidance, and performance-conscious patterns. This skill focuses on facts and best practices without enforcing specific architectural patterns.
When to Use This Skill
Use this skill when:
Workflow Decision Tree
1) Review existing SwiftUI code
references/state-management.md)references/modern-apis.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/liquid-glass.md)2) Improve existing SwiftUI code
@Observable over ObservableObject)references/modern-apis.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)UIImage(data:) is used (as optional optimization, see references/image-optimization.md)3) Implement new SwiftUI feature
references/state-management.md)references/modern-apis.md)@Observable for shared state (with @MainActor if not using default actor isolation)references/view-structure.md)references/layout-best-practices.md)references/liquid-glass.md)#available and provide fallbacksCore Guidelines
State Management
@Observable over ObservableObject for new code@Observable classes with @MainActor unless using default actor isolation@State and @StateObject as private (makes dependencies clear)@State or @StateObject (they only accept initial values)@State with @Observable classes (not @StateObject)@Binding only when child needs to modify parent state@Bindable for injected @Observable objects needing bindingslet for read-only values; var + .onChange() for reactive reads@StateObject for owned ObservableObject; @ObservedObject for injectedObservableObject doesn't work (pass nested objects directly); @Observable handles nesting fineModern APIs
foregroundStyle() instead of foregroundColor()clipShape(.rect(cornerRadius:)) instead of cornerRadius()Tab API instead of tabItem()Button instead of onTapGesture() (unless need location/count)NavigationStack instead of NavigationViewnavigationDestination(for:) for type-safe navigationonChange() variantImageRenderer for rendering SwiftUI views.sheet(item:) instead of .sheet(isPresented:) for model-based contentdismiss() internallyScrollViewReader for programmatic scrolling with stable IDsUIScreen.main.bounds for sizingGeometryReader when alternatives exist (e.g., containerRelativeFrame())Swift Best Practices
.format parameters, not String(format:))localizedStandardContains() for user-input filtering (not contains()).blue vs Color.blue).task modifier for automatic cancellation of async work.task(id:) for value-dependent tasksView Composition
body simple and pure (no side effects or complex logic)@ViewBuilder functions only for small, simple sections@ViewBuilder let content: Content over closure-based content propertiesPerformance
onReceive, onChange, scroll handlersLazyVStack/LazyHStack for large listsForEach (never .indices for dynamic content)ForEach elementForEach (prefilter and cache)AnyView in list rowsUIImage(data:) is encountered (as optional optimization)GeometryReader)Self._printChanges() to debug unexpected view updatesLiquid Glass (iOS 26+)
Only adopt when explicitly requested by the user.
glassEffect, GlassEffectContainer, and glass button stylesGlassEffectContainer.glassEffect() after layout and visual modifiers.interactive() only for tappable/focusable elementsglassEffectID with @Namespace for morphing transitionsQuick Reference
Property Wrapper Selection (Modern)
| Wrapper | Use When |
|---------|----------|
| @State | Internal view state (must be private), or owned @Observable class |
| @Binding | Child modifies parent's state |
| @Bindable | Injected @Observable needing bindings |
| let | Read-only value from parent |
| var | Read-only value watched via .onChange() |
Legacy (Pre-iOS 17):
| Wrapper | Use When |
|---------|----------|
| @StateObject | View owns an ObservableObject (use @State with @Observable instead) |
| @ObservedObject | View receives an ObservableObject |
Modern API Replacements
| Deprecated | Modern Alternative |
|------------|-------------------|
| foregroundColor() | foregroundStyle() |
| cornerRadius() | clipShape(.rect(cornerRadius:)) |
| tabItem() | Tab API |
| onTapGesture() | Button (unless need location/count) |
| NavigationView | NavigationStack |
| onChange(of:) { value in } | onChange(of:) { old, new in } or onChange(of:) { } |
| fontWeight(.bold) | bold() |
| GeometryReader | containerRelativeFrame() or visualEffect() |
| showsIndicators: false | .scrollIndicators(.hidden) |
| String(format: "%.2f", value) | Text(value, format: .number.precision(.fractionLength(2))) |
| string.contains(search) | string.localizedStandardContains(search) (for user input) |
Liquid Glass Patterns
// Basic glass effect with fallback
if #available(iOS 26, *) {
content
.padding()
.glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
} else {
content
.padding()
.background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))
}
// Grouped glass elements
GlassEffectContainer(spacing: 24) {
HStack(spacing: 24) {
GlassButton1()
GlassButton2()
}
}
// Glass buttons
Button("Confirm") { }
.buttonStyle(.glassProminent)Review Checklist
State Management
@Observable instead of ObservableObject for new code@Observable classes marked with @MainActor (if needed)@State with @Observable classes (not @StateObject)@State and @StateObject properties are private@State or @StateObject@Binding only where child modifies parent state@Bindable for injected @Observable needing bindingsObservableObject avoided (or passed directly to child views)Modern APIs (see `references/modern-apis.md`)
foregroundStyle() instead of foregroundColor()clipShape(.rect(cornerRadius:)) instead of cornerRadius()Tab API instead of tabItem()Button instead of onTapGesture() (unless need location/count)NavigationStack instead of NavigationViewUIScreen.main.boundsGeometryReader when possibleSheets & Navigation (see `references/sheet-navigation-patterns.md`)
.sheet(item:) for model-based sheetsnavigationDestination(for:) for type-safe navigationScrollView (see `references/scroll-patterns.md`)
ScrollViewReader with stable IDs for programmatic scrolling.scrollIndicators(.hidden) instead of initializer parameterText & Formatting (see `references/text-formatting.md`)
String(format:))localizedStandardContains() for search filteringView Structure (see `references/view-structure.md`)
@ViewBuilder let content: ContentPerformance (see `references/performance-patterns.md`)
body kept simple and pure (no side effects)bodybodyList Patterns (see `references/list-patterns.md`)
.indices)AnyView in list rowsLayout (see `references/layout-best-practices.md`)
Liquid Glass (iOS 26+)
#available(iOS 26, *) with fallback for Liquid GlassGlassEffectContainer.glassEffect() applied after layout/appearance modifiers.interactive() only on user-interactable elementsReferences
references/state-management.md - Property wrappers and data flow (prefer @Observable)references/view-structure.md - View composition, extraction, and container patternsreferences/performance-patterns.md - Performance optimization techniques and anti-patternsreferences/list-patterns.md - ForEach identity, stability, and list best practicesreferences/layout-best-practices.md - Layout patterns, context-agnostic views, and testabilityreferences/modern-apis.md - Modern API usage and deprecated replacementsreferences/sheet-navigation-patterns.md - Sheet presentation and navigation patternsreferences/scroll-patterns.md - ScrollView patterns and programmatic scrollingreferences/text-formatting.md - Modern text formatting and string operationsreferences/image-optimization.md - AsyncImage, image downsampling, and optimizationreferences/liquid-glass.md - iOS 26+ Liquid Glass APIPhilosophy
This skill focuses on facts and best practices, not architectural opinions:
@MainActor and @ObservableCompétences similaires
Explorez d'autres agents de la catégorie Frontend & Expérience UX
browser-extension-builder
"Expert in building browser extensions that solve real problems - Chrome, Firefox, and cross-browser extensions. Covers extension architecture, manifest v3, content scripts, popup UIs, monetization strategies, and Chrome Web Store publishing. Use when: browser extension, chrome extension, firefox addon, extension, manifest v3."
scroll-experience
"Expert in building immersive scroll-driven experiences - parallax storytelling, scroll animations, interactive narratives, and cinematic web experiences. Like NY Times interactives, Apple product pages, and award-winning web experiences. Makes websites feel like experiences, not just pages. Use when: scroll animation, parallax, scroll storytelling, interactive story, cinematic website."
react-flow-architect
"Expert ReactFlow architect for building interactive graph applications with hierarchical node-edge systems, performance optimization, and auto-layout integration. Use when Claude needs to create or optimize ReactFlow applications for: (1) Interactive process graphs with expand/collapse navigation, (2) Hierarchical tree structures with drag & drop, (3) Performance-optimized large datasets with incremental rendering, (4) Auto-layout integration with Dagre, (5) Complex state management for nodes and edges, or any advanced ReactFlow visualization requirements."