Antigravity-awesome-skills swiftui-expert-skill
Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns.
install
source · Clone the upstream repo
git clone https://github.com/sickn33/antigravity-awesome-skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/sickn33/antigravity-awesome-skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/antigravity-awesome-skills/skills/swiftui-expert-skill" ~/.claude/skills/sickn33-antigravity-awesome-skills-swiftui-expert-skill-32d24d && rm -rf "$T"
manifest:
plugins/antigravity-awesome-skills/skills/swiftui-expert-skill/SKILL.mdsource content
SwiftUI Expert Skill
When to Use
- You are building, reviewing, or refactoring SwiftUI code and need current best practices.
- The task involves state management, view composition, performance, accessibility, or iOS 26+ Liquid Glass adoption.
- You need a fact-based SwiftUI guidance layer without locking into a specific application architecture.
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
to ensure only current, non-deprecated APIs are usedreferences/latest-apis.md - 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 - 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
to replace any deprecated APIs with their modern equivalentsreferences/latest-apis.md - 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
over tap gestures, addButton
for Dynamic Type (see@ScaledMetric
)references/accessibility-patterns.md - Suggest image downsampling when
is used (as optional optimization, seeUIImage(data:)
)references/image-optimization.md - Adopt Liquid Glass only when explicitly requested by the user
3) Implement new SwiftUI feature
- First, consult
to use only current, non-deprecated APIs for the target deployment versionreferences/latest-apis.md - 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
for tappable elements, add accessibility grouping and labels (seeButton
)references/accessibility-patterns.md - Apply glass effects after layout/appearance modifiers (see
)references/liquid-glass.md - Gate iOS 26+ features with
and provide fallbacks#available
Core Guidelines
State Management
must be@State
; use for internal view stateprivate
only when a child needs to modify parent state@Binding
when view creates the object;@StateObject
when injected@ObservedObject- iOS 17+: Use
with@State
classes; use@Observable
for injected observables needing bindings@Bindable - Use
for read-only values;let
+var
for reactive reads.onChange() - Never pass values into
or@State
— they only accept initial values@StateObject - Nested
doesn't propagate changes — pass nested objects directly;ObservableObject
handles nesting fine@Observable
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
simple and pure (no side effects or complex logic)body - Use
functions only for small, simple sections@ViewBuilder - Prefer
over closure-based content properties@ViewBuilder let content: Content - 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
- Check for value changes before assigning state in hot paths
- Avoid redundant state updates in
,onReceive
, scroll handlersonChange - Minimize work in frequently executed code paths
- Use
/LazyVStack
for large listsLazyHStack - Use stable identity for
(neverForEach
for dynamic content).indices - Ensure constant number of views per
elementForEach - Avoid inline filtering in
(prefilter and cache)ForEach - Avoid
in list rowsAnyView - Consider POD views for fast diffing (or wrap expensive views in POD parents)
- Suggest image downsampling when
is encountered (as optional optimization)UIImage(data:) - Avoid layout thrash (deep hierarchies, excessive
)GeometryReader - Gate frequent geometry updates by thresholds
- Use
orSelf._logChanges()
to debug unexpected view updatesSelf._printChanges()
Animations
- Use
with value parameter (deprecated version without value is too broad).animation(_:value:) - Use
for event-driven animations (button taps, gestures)withAnimation - Prefer transforms (
,offset
,scale
) over layout changes (rotation
) for performanceframe - Transitions require animations outside the conditional structure
- Custom
implementations must have explicitAnimatableanimatableData - Use
for multi-step sequences (iOS 17+).phaseAnimator - Use
for precise timing control (iOS 17+).keyframeAnimator - Animation completion handlers need
for reexecution.transaction(value:) - Implicit animations override explicit animations (later in view tree wins)
Accessibility
- Prefer
overButton
for tappable elements (free VoiceOver support)onTapGesture - Use
for custom numeric values that should scale with Dynamic Type@ScaledMetric - Group related elements with
for joined labelsaccessibilityElement(children: .combine) - Provide
when default labels are unclear or missingaccessibilityLabel - Use
for custom controls that should behave like native onesaccessibilityRepresentation
Liquid Glass (iOS 26+)
Only adopt when explicitly requested by the user.
- Use native
,glassEffect
, and glass button stylesGlassEffectContainer - Wrap multiple glass elements in
GlassEffectContainer - Apply
after layout and visual modifiers.glassEffect() - Use
only for tappable/focusable elements.interactive() - Use
withglassEffectID
for morphing transitions@Namespace
Quick Reference
Property Wrapper Selection
| Wrapper | Use When |
|---|---|
| Internal view state (must be ) |
| Child modifies parent's state |
| View owns an |
| View receives an |
| iOS 17+: Injected needing bindings |
| Read-only value from parent |
| Read-only value watched via |
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
Latest APIs (see references/latest-apis.md
)
references/latest-apis.md- No deprecated modifiers used (check against the quick lookup table)
- API choices match the project's minimum deployment target
State Management
-
properties are@Stateprivate -
only where child modifies parent state@Binding -
for owned,@StateObject
for injected@ObservedObject - iOS 17+:
with@State
,@Observable
for injected@Bindable - Passed values NOT declared as
or@State@StateObject - Nested
avoided (or passed directly to child views)ObservableObject
Sheets & Navigation (see references/sheet-navigation-patterns.md
)
references/sheet-navigation-patterns.md- Using
for model-based sheets.sheet(item:) - Sheets own their actions and dismiss internally
ScrollView (see references/scroll-patterns.md
)
references/scroll-patterns.md- Using
with stable IDs for programmatic scrollingScrollViewReader
View Structure (see references/view-structure.md
)
references/view-structure.md- Using modifiers instead of conditionals for state changes
- Complex views extracted to separate subviews
- Container views use
@ViewBuilder let content: Content
Performance (see references/performance-patterns.md
)
references/performance-patterns.md- View
kept simple and pure (no side effects)body - Passing only needed values (not large config objects)
- Eliminating unnecessary dependencies
- State updates check for value changes before assigning
- Hot paths minimize state updates
- No object creation in
body - Heavy computation moved out of
body
List Patterns (see references/list-patterns.md
)
references/list-patterns.md- ForEach uses stable identity (not
).indices - Constant number of views per ForEach element
- No inline filtering in ForEach
- No
in list rowsAnyView
Layout (see references/layout-best-practices.md
)
references/layout-best-practices.md- Avoiding layout thrash (deep hierarchies, excessive GeometryReader)
- Gating frequent geometry updates by thresholds
- Business logic kept in services and models (not in views)
- Action handlers reference methods (not inline logic)
- Using relative layout (not hard-coded constants)
- Views work in any context (context-agnostic)
Animations (see references/animation-basics.md
, references/animation-transitions.md
, references/animation-advanced.md
)
references/animation-basics.mdreferences/animation-transitions.mdreferences/animation-advanced.md- Using
with value parameter.animation(_:value:) - Using
for event-driven animationswithAnimation - Transitions paired with animations outside conditional structure
- Custom
has explicitAnimatable
implementationanimatableData - Preferring transforms over layout changes for animation performance
- Phase animations for multi-step sequences (iOS 17+)
- Keyframe animations for precise timing (iOS 17+)
- Completion handlers use
for reexecution.transaction(value:)
Accessibility (see references/accessibility-patterns.md
)
references/accessibility-patterns.md-
used instead ofButton
for tappable elementsonTapGesture -
used for custom values that should scale with Dynamic Type@ScaledMetric - Related elements grouped with
accessibilityElement(children:) - Custom controls use
when appropriateaccessibilityRepresentation
Liquid Glass (iOS 26+)
-
with fallback for Liquid Glass#available(iOS 26, *) - Multiple glass views wrapped in
GlassEffectContainer -
applied after layout/appearance modifiers.glassEffect() -
only on user-interactable elements.interactive() - Shapes and tints consistent across related elements
References
- Required reading for all workflows. Version-segmented guide of deprecated-to-modern API transitions (iOS 15+ through iOS 26+)references/latest-apis.md
- Property wrappers and data flowreferences/state-management.md
- View composition, extraction, and container patternsreferences/view-structure.md
- Performance optimization techniques and anti-patternsreferences/performance-patterns.md
- ForEach identity, stability, and list best practicesreferences/list-patterns.md
- Layout patterns, context-agnostic views, and testabilityreferences/layout-best-practices.md
- Accessibility traits, grouping, Dynamic Type, and VoiceOverreferences/accessibility-patterns.md
- Core animation concepts, implicit/explicit animations, timing, performancereferences/animation-basics.md
- Transitions, custom transitions, Animatable protocolreferences/animation-transitions.md
- Transactions, phase/keyframe animations (iOS 17+), completion handlers (iOS 17+)references/animation-advanced.md
- Sheet presentation and navigation patternsreferences/sheet-navigation-patterns.md
- ScrollView patterns and programmatic scrollingreferences/scroll-patterns.md
- AsyncImage, image downsampling, and optimizationreferences/image-optimization.md
- iOS 26+ Liquid Glass APIreferences/liquid-glass.md
Philosophy
This skill focuses on facts and best practices, not architectural opinions:
- We don't enforce specific architectures (e.g., MVVM, VIPER)
- We do encourage separating business logic for testability
- We optimize for performance and maintainability
- We follow Apple's Human Interface Guidelines and API design patterns
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.