Install
openclaw skills install swift-patternsReview, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, navigation patterns, performance optimization, and testing best practices.
openclaw skills install swift-patternsReview, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, and performance-conscious patterns. Prioritize native APIs, Apple design guidance, and testable code structure. This skill focuses on facts and best practices without enforcing specific architectural patterns.
→ Read references/workflows-review.md for review methodology
references/state.md)references/view-composition.md)references/lists-collections.md)references/modern-swiftui-apis.md)references/concurrency.md)references/navigation.md)→ Read references/workflows-refactor.md for refactor methodology
references/refactor-playbooks.md)references/modern-swiftui-apis.md)references/performance.md)references/state.md)references/patterns.md)references/state.md)references/view-composition.md)references/modern-swiftui-apis.md)references/concurrency.md)references/performance.md)references/navigation.md)If intent unclear, ask: "Do you want findings only (review), or should I change the code (refactor)?"
Review Response:
Refactor Response:
| Wrapper | Use When | Ownership |
|---|---|---|
@State | Internal view state (value type or @Observable class) | View owns |
@Binding | Child needs to modify parent's state | Parent owns |
@Bindable | Injected @Observable object needing bindings | Injected |
let | Read-only value from parent | Injected |
var + .onChange() | Read-only value needing reactive updates | Injected |
Key rules:
@State as private (makes ownership explicit)@State for passed values (accepts initial value only)@State with @Observable classes (not @StateObject)See references/state.md for detailed guidance and tradeoffs.
| Deprecated | Modern Alternative | Notes |
|---|---|---|
foregroundColor() | foregroundStyle() | Supports dynamic type |
cornerRadius() | .clipShape(.rect(cornerRadius:)) | More flexible |
NavigationView | NavigationStack | Type-safe navigation |
tabItem() | Tab API | iOS 18+ |
onTapGesture() | Button | Unless need location/count |
onChange(of:) { value in } | onChange(of:) { old, new in } or onChange(of:) { } | Two or zero parameters |
UIScreen.main.bounds | GeometryReader or layout APIs | Avoid hard-coded sizes |
See references/modern-swiftui-apis.md for complete migration guide.
Use this when reviewing SwiftUI code:
@State properties marked private@State or @StateObject@Binding only where child modifies parent stateNavigationStack instead of NavigationViewButton instead of onTapGesture when appropriateonChange()body simple and pure (no side effects)navigationDestination(for:) for type-safe navigation.sheet(item:) for model-based sheetsForEach uses stable identity (never .indices for dynamic data)ForEach elementForEach (prefilter and cache)AnyView in list rowsLazyVStack/LazyHStack for large listsbody.task for automatic cancellation.task(id:) for value-dependent tasks.onAppear with async workSee reference files for detailed explanations of each item.
.task for SwiftUI async workdeveloper.apple.com/documentation/swiftui/, developer.apple.com/documentation/swift/All workflows must follow these constraints.
This skill focuses on facts and best practices from Apple's documentation:
All references in references/:
workflows-review.md - Review methodology and findings taxonomyworkflows-refactor.md - Refactor methodology and invariantsrefactor-playbooks.md - Step-by-step refactor guidesstate.md - Property wrappers and ownership patternsnavigation.md - Navigation implementation patternsview-composition.md - View structure and extractionlists-collections.md - Identity and ForEach patternsscrolling.md - Scroll handling and paginationconcurrency.md - Async work with .taskperformance.md - Optimization strategiestesting-di.md - Testing and dependency injectionpatterns.md - Common SwiftUI patternsmodern-swiftui-apis.md - Legacy API migrationcode-review-refactoring.md - Code quality checks