swiftui-expert-skill
Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, macOS-specific APIs, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns.
What this skill does
# SwiftUI Expert Skill ## Overview Use this skill to build, review, or improve SwiftUI features with correct state management, 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. ## Workflow Decision Tree ### 1) Review existing SwiftUI code - **First, consult `references/latest-apis.md`** to ensure only current, non-deprecated APIs are used - Check property wrapper usage against the selection guide (see `references/state-management.md`) - Verify view composition follows extraction rules (see `references/view-structure.md`) - Check performance patterns are applied (see `references/performance-patterns.md`) - Verify list patterns use stable identity (see `references/list-patterns.md`) - Check animation patterns for correctness (see `references/animation-basics.md`, `references/animation-transitions.md`) - Review accessibility: proper grouping, traits, Dynamic Type support (see `references/accessibility-patterns.md`) - Check chart patterns for correct mark usage, stable data identity, and availability gating (see `references/charts.md`; for accessibility and fallback strategies see `references/charts-accessibility.md`) - For macOS targets: verify correct use of macOS-specific APIs and patterns (see `references/macos-scenes.md`, `references/macos-window-styling.md`, `references/macos-views.md`) - Inspect Liquid Glass usage for correctness and consistency (see `references/liquid-glass.md`) - Validate iOS 26+ availability handling with sensible fallbacks ### 2) Improve existing SwiftUI code - **First, consult `references/latest-apis.md`** to replace any deprecated APIs with their modern equivalents - Audit state management for correct wrapper selection (see `references/state-management.md`) - Extract complex views into separate subviews (see `references/view-structure.md`) - Refactor hot paths to minimize redundant state updates (see `references/performance-patterns.md`) - Ensure ForEach uses stable identity (see `references/list-patterns.md`) - Improve animation patterns (use value parameter, proper transitions, see `references/animation-basics.md`, `references/animation-transitions.md`) - Improve accessibility: use `Button` over tap gestures, add `@ScaledMetric` for Dynamic Type (see `references/accessibility-patterns.md`) - Review chart code for correct modifier scope, styling, and accessibility (see `references/charts.md`, `references/charts-accessibility.md`) - For macOS targets: adopt macOS-specific APIs (MenuBarExtra, Settings, Table, Commands, etc.) where appropriate (see `references/macos-scenes.md`, `references/macos-window-styling.md`, `references/macos-views.md`) - Suggest image downsampling when `UIImage(data:)` is used (as optional optimization, see `references/image-optimization.md`) - Adopt Liquid Glass only when explicitly requested by the user ### 3) Implement new SwiftUI feature - **First, consult `references/latest-apis.md`** to use only current, non-deprecated APIs for the target deployment version - Design data flow first: identify owned vs injected state (see `references/state-management.md`) - Structure views for optimal diffing (extract subviews early, see `references/view-structure.md`) - Keep business logic in services and models for testability (see `references/layout-best-practices.md`) - Use correct animation patterns (implicit vs explicit, transitions, see `references/animation-basics.md`, `references/animation-transitions.md`, `references/animation-advanced.md`) - Use `Button` for tappable elements, add accessibility grouping and labels (see `references/accessibility-patterns.md`) - For charts: use correct mark types, stable data identity, and gate iOS 17+/18+/26+ APIs (see `references/charts.md`; for accessibility see `references/charts-accessibility.md`) - For macOS targets: use macOS-specific scenes (see `references/macos-scenes.md`), window styling (see `references/macos-window-styling.md`), and views like HSplitView, Table (see `references/macos-views.md`) - Apply glass effects after layout/appearance modifiers (see `references/liquid-glass.md`) - Gate iOS 26+ features with `#available` and provide fallbacks ## Core Guidelines ### State Management - `@State` must be `private`; use for internal view state - `@Binding` only when a child needs to **modify** parent state - `@StateObject` when view **creates** the object; `@ObservedObject` when **injected** - iOS 17+: Use `@State` with `@Observable` classes; use `@Bindable` for injected observables needing bindings - Use `let` for read-only values; `var` + `.onChange()` for reactive reads - Never pass values into `@State` or `@StateObject` — they only accept initial values - Nested `ObservableObject` doesn't propagate changes — pass nested objects directly; `@Observable` handles nesting fine ### View Composition - Extract complex views into separate subviews for better readability and performance - Prefer modifiers over conditional views for state changes (maintains view identity) - Keep view `body` simple and pure (no side effects or complex logic) - Use `@ViewBuilder` functions only for small, simple sections - Prefer `@ViewBuilder let content: Content` over closure-based content properties - Keep business logic in services and models; views should orchestrate UI flow - Action handlers should reference methods, not contain inline logic - Views should work in any context (don't assume screen size or presentation style) ### Performance - Pass only needed values to views (avoid large "config" or "context" objects) - Eliminate unnecessary dependencies to reduce update fan-out - Consider per-item `@Observable` state objects in lists to narrow update/dependency scope - Consider whether frequently-changing values belong in the environment; prefer more local state when it reduces unnecessary view updates - Check for value changes before assigning state in hot paths - Avoid redundant state updates in `onReceive`, `onChange`, scroll handlers - Minimize work in frequently executed code paths - Use `LazyVStack`/`LazyHStack` for large lists - Use stable identity for `ForEach` (never `.indices` for dynamic content) - Ensure constant number of views per `ForEach` element - Avoid inline filtering in `ForEach` (prefilter and cache) - Avoid `AnyView` in list rows - Consider POD views for fast diffing (or wrap expensive views in POD parents) - Suggest image downsampling when `UIImage(data:)` is encountered (as optional optimization) - Avoid layout thrash (deep hierarchies, excessive `GeometryReader`) - Gate frequent geometry updates by thresholds - Use `Self._logChanges()` or `Self._printChanges()` to debug unexpected view updates - `Shape.path()`, `visualEffect`, `Layout`, and `onGeometryChange` closures may run off the main thread — capture values instead of accessing `@MainActor` state ### Animations - Use `.animation(_:value:)` with value parameter (deprecated version without value is too broad) - Use `withAnimation` for event-driven animations (button taps, gestures) - Prefer transforms (`offset`, `scale`, `rotation`) over layout changes (`frame`) for performance - Transitions require animations outside the conditional structure - Custom `Animatable` implementations must have explicit `animatableData` (or use `@Animatable` macro on iOS 26+) - iOS 26+: Use `@Animatable` macro to auto-synthesize `animatableData`; use `@AnimatableIgnored` to exclude properties - Use `.phaseAnimator` for multi-step sequences (iOS 17+) - Use `.keyframeAnimator` for precise timing control (iOS 17+) - Animation completion handlers need `.transaction(value:)` for reexecution - Implicit animations override explicit animations (later in view tree wins) ### Accessibility - Prefer `Button` over `onTapGesture` for tappable elements (free VoiceOver support) - Use `@ScaledMetric` for custom numeric values that should s
Related in Code Review
gstack
IncludedFast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)
startup-due-diligence
IncludedLegal due diligence review for seed-stage and Series A startups (US, Delaware C-Corp focus). Supports both investor and founder perspectives. Capabilities include: (1) Interactive document review and issue spotting; (2) Document request list generation; (3) Cap table and SAFE/convertible note analysis; (4) Red flag identification with severity ratings; (5) Diligence report generation. TRIGGERS: due diligence, DD, startup investment, cap table review, Series A, seed round, investor diligence, legal review startup, SAFE analysis, convertible note, 409A, founder vesting.
interview-master
IncludedThis skill should be used when the user asks to "generate interview questions", "prepare for interview", "optimize resume", "conduct mock interview", "analyze git commits for resume", "generate resume from code", "review my resume", or mentions interview preparation, career assistance, or extracting project experience from git history. Provides comprehensive interview and career development guidance for both job seekers and interviewers.
fix-issue
IncludedFixes GitHub issues using parallel analysis agents for root cause investigation, code exploration, and regression detection. Reads issue context from gh CLI, searches codebase and memory for related patterns, generates a fix with tests, and links the resolution back to the issue via PR. Includes prevention analysis to avoid recurrence. Use when debugging errors, resolving regressions, fixing bugs, or triaging issues.
sf-apex
IncludedGenerates and reviews Salesforce Apex code with 150-point scoring. TRIGGER when: user writes, reviews, or fixes Apex classes, triggers, test classes, batch/queueable/schedulable jobs, or touches .cls/.trigger files. DO NOT TRIGGER when: LWC JavaScript (use sf-lwc), Flow XML (use sf-flow), SOQL-only queries (use sf-soql), or non-Salesforce code.
swift-development
IncludedComprehensive Swift development for building, testing, and deploying iOS/macOS applications. Use when Claude needs to: (1) Build Swift packages or Xcode projects from command line, (2) Run tests with XCTest or Swift Testing framework, (3) Manage iOS simulators with simctl, (4) Handle code signing, provisioning profiles, and app distribution, (5) Format or lint Swift code with SwiftFormat/SwiftLint, (6) Work with Swift Package Manager (SPM), (7) Implement Swift 6 concurrency patterns (async/await, actors, Sendable), (8) Create SwiftUI views with MVVM architecture, (9) Set up Core Data or SwiftData persistence, or any other Swift/iOS/macOS development tasks.