swiftui-expert-skill

bởi expo

Viết, xem xét hoặc cải thiện mã SwiftUI theo các phương pháp tốt nhất về quản lý trạng thái, cấu trúc view, hiệu suất, API dành riêng cho macOS và iOS 26+ Liquid…

npx skills add https://github.com/expo/agent-templates --skill swiftui-expert-skill

SwiftUI Expert Skill

Operating Rules

  • Consult references/latest-apis.md at the start of every task to avoid deprecated APIs
  • Prefer native SwiftUI APIs over UIKit/AppKit bridging unless bridging is necessary
  • Focus on correctness and performance; do not enforce specific architectures (MVVM, VIPER, etc.)
  • Encourage separating business logic from views for testability without mandating how
  • Follow Apple's Human Interface Guidelines and API design patterns
  • Only adopt Liquid Glass when explicitly requested by the user (see references/liquid-glass.md)
  • Present performance optimizations as suggestions, not requirements
  • Use #available gating with sensible fallbacks for version-specific APIs

Task Workflow

Review existing SwiftUI code

  • Read the code under review and identify which topics apply
  • Flag deprecated APIs (compare against references/latest-apis.md)
  • Run the Topic Router below for each relevant topic
  • Validate #available gating and fallback paths for iOS 26+ features

Improve existing SwiftUI code

  • Audit current implementation against the Topic Router topics
  • Replace deprecated APIs with modern equivalents from references/latest-apis.md
  • Refactor hot paths to reduce unnecessary state updates
  • Extract complex view bodies into separate subviews
  • Suggest image downsampling when UIImage(data:) is encountered (optional optimization, see references/image-optimization.md)

Implement new SwiftUI feature

  • Design data flow first: identify owned vs injected state
  • Structure views for optimal diffing (extract subviews early)
  • Apply correct animation patterns (implicit vs explicit, transitions)
  • Use Button for all tappable elements; add accessibility grouping and labels
  • Gate version-specific APIs with #available and provide fallbacks

Topic Router

Consult the reference file for each topic relevant to the current task:

TopicReference
State managementreferences/state-management.md
View compositionreferences/view-structure.md
Performancereferences/performance-patterns.md
Lists and ForEachreferences/list-patterns.md
Layoutreferences/layout-best-practices.md
Sheets and navigationreferences/sheet-navigation-patterns.md
ScrollViewreferences/scroll-patterns.md
Animations (basics)references/animation-basics.md
Animations (transitions)references/animation-transitions.md
Animations (advanced)references/animation-advanced.md
Accessibilityreferences/accessibility-patterns.md
Swift Chartsreferences/charts.md
Charts accessibilityreferences/charts-accessibility.md
Image optimizationreferences/image-optimization.md
Liquid Glass (iOS 26+)references/liquid-glass.md
macOS scenesreferences/macos-scenes.md
macOS window stylingreferences/macos-window-styling.md
macOS viewsreferences/macos-views.md
Deprecated API lookupreferences/latest-apis.md

Correctness Checklist

These are hard rules -- violations are always bugs:

  • @State properties are private
  • @Binding only where a child modifies parent state
  • Passed values never declared as @State or @StateObject (they ignore updates)
  • @StateObject for view-owned objects; @ObservedObject for injected
  • iOS 17+: @State with @Observable; @Bindable for injected observables needing bindings
  • ForEach uses stable identity (never .indices for dynamic content)
  • Constant number of views per ForEach element
  • .animation(_:value:) always includes the value parameter
  • iOS 26+ APIs gated with #available and fallback provided
  • import Charts present in files using chart types

References

  • references/latest-apis.md -- Read first for every task. Deprecated-to-modern API transitions (iOS 15+ through iOS 26+)
  • references/state-management.md -- Property wrappers, data flow, @Observable migration
  • references/view-structure.md -- View extraction, container patterns, @ViewBuilder
  • references/performance-patterns.md -- Hot-path optimization, update control, _logChanges()
  • references/list-patterns.md -- ForEach identity, Table (iOS 16+), inline filtering pitfalls
  • references/layout-best-practices.md -- Layout patterns, GeometryReader alternatives
  • references/accessibility-patterns.md -- VoiceOver, Dynamic Type, grouping, traits
  • references/animation-basics.md -- Implicit/explicit animations, timing, performance
  • references/animation-transitions.md -- View transitions, matchedGeometryEffect, Animatable
  • references/animation-advanced.md -- Phase/keyframe animations (iOS 17+), @Animatable macro (iOS 26+)
  • references/charts.md -- Swift Charts marks, axes, selection, styling, Chart3D (iOS 26+)
  • references/charts-accessibility.md -- Charts VoiceOver, Audio Graph, fallback strategies
  • references/sheet-navigation-patterns.md -- Sheets, NavigationSplitView, Inspector
  • references/scroll-patterns.md -- ScrollViewReader, programmatic scrolling
  • references/image-optimization.md -- AsyncImage, downsampling, caching
  • references/liquid-glass.md -- iOS 26+ Liquid Glass effects and fallback patterns
  • references/macos-scenes.md -- Settings, MenuBarExtra, WindowGroup, multi-window
  • references/macos-window-styling.md -- Toolbar styles, window sizing, Commands
  • references/macos-views.md -- HSplitView, Table, PasteButton, AppKit interop

Thêm skills từ expo

expo-upgrade
expo
Khung (Mã nguồn mở). Hướng dẫn nâng cấp phiên bản Expo SDK và sửa lỗi phụ thuộc
apidevelopmentofficial
expo-data-fetching
expo
Framework (OSS). Use when implementing or debugging ANY network request, API call, or data fetching. Covers fetch API, React Query, SWR, error handling, caching, offline support, and Expo Router data loaders (`useLoaderData`).
official
android-e2e-testing
expo
Kiểm tra các tính năng Expo Router trên trình giả lập Android bằng ADB. Sử dụng sau khi triển khai các tính năng Android gốc hoặc khi xác minh hành vi giao diện người dùng trên Android.
official
expo-dev-client
expo
Xây dựng các bản phát triển Expo tùy chỉnh để kiểm tra mã gốc trên thiết bị vật lý qua EAS Build hoặc cục bộ. Chỉ cần thiết khi sử dụng các mô-đun gốc tùy chỉnh, mục tiêu Apple (widget, app clips) hoặc mã gốc của bên thứ ba không có trong Expo Go; hãy thử Expo Go trước với lệnh npx expo start. Hỗ trợ xây dựng đám mây với tính năng tự động gửi lên TestFlight hoặc xây dựng cục bộ trên máy của bạn, xuất ra tệp .ipa (iOS) hoặc .apk / .aab (Android). Yêu cầu cấu hình eas.json với một hồ sơ phát triển thiết lập...
official
expo-tailwind-setup
expo
Kiểu dáng Tailwind CSS v4 phổ quát cho ứng dụng Expo trên iOS, Android và Web. Tích hợp Tailwind CSS v4 với react-native-css và NativeWind v5 thông qua Metro transformer, loại bỏ nhu cầu cấu hình Babel. Cung cấp thư viện component bọc CSS có thể tái sử dụng (View, Text, ScrollView, Pressable, TextInput, Image, Link) áp dụng className cho các phần tử gốc. Hỗ trợ kiểu dáng theo nền tảng thông qua truy vấn phương tiện CSS, biến theme tùy chỉnh qua khối @theme, và ngữ nghĩa Apple...
official
android-jetpack-compose
expo
Sử dụng khi xây dựng giao diện Android với Jetpack Compose, quản lý trạng thái bằng remember/mutableStateOf, hoặc triển khai các mẫu giao diện khai báo.
official
eas-update-insights
expo
Kiểm tra tình trạng của các bản cập nhật EAS đã phát hành: tỷ lệ sập, số lần cài đặt/khởi chạy, người dùng duy nhất, kích thước tải trọng và sự phân chia giữa người dùng nhúng và OTA theo…
official
expo-module
expo
Hướng dẫn tạo và viết các mô-đun gốc và chế độ xem của Expo bằng Expo Modules API (Swift, Kotlin, TypeScript). Bao gồm DSL định nghĩa mô-đun, gốc…
official