From swift-guardian
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.
How this skill is triggered — by the user, by Claude, or both
Slash command
/swift-guardian:swiftui-expertThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
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.
references/animation-advanced.mdreferences/animation-basics.mdreferences/animation-transitions.mdreferences/image-optimization.mdreferences/layout-best-practices.mdreferences/liquid-glass.mdreferences/list-patterns.mdreferences/performance-patterns.mdreferences/scroll-patterns.mdreferences/sheet-navigation-patterns.mdreferences/state-management.mdreferences/view-structure.mdUse 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.
references/state-management.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/animation-basics.md, references/animation-transitions.md)references/liquid-glass.md)references/state-management.md)references/view-structure.md)references/performance-patterns.md)references/list-patterns.md)references/animation-basics.md, references/animation-transitions.md)UIImage(data:) is used (as optional optimization, see references/image-optimization.md)references/state-management.md)references/view-structure.md)references/layout-best-practices.md)references/animation-basics.md, references/animation-transitions.md, references/animation-advanced.md)references/liquid-glass.md)#available and provide fallbacks@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@State with @Observable classes; use @Bindable for injected observables needing bindingslet for read-only values; var + .onChange() for reactive reads@State or @StateObject — they only accept initial valuesObservableObject doesn't propagate changes — pass nested objects directly; @Observable handles nesting finebody simple and pure (no side effects or complex logic)@ViewBuilder functions only for small, simple sections@ViewBuilder let content: Content over closure-based content propertiesonReceive, 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 updates.animation(_:value:) with value parameter (deprecated version without value is too broad)withAnimation for event-driven animations (button taps, gestures)offset, scale, rotation) over layout changes (frame) for performanceAnimatable implementations must have explicit animatableData.phaseAnimator for multi-step sequences (iOS 17+).keyframeAnimator for precise timing control (iOS 17+).transaction(value:) for reexecutionOnly 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 transitions| Wrapper | Use When |
|---|---|
@State | Internal view state (must be private) |
@Binding | Child modifies parent's state |
@StateObject | View owns an ObservableObject |
@ObservedObject | View receives an ObservableObject |
@Bindable | iOS 17+: Injected @Observable needing bindings |
let | Read-only value from parent |
var | Read-only value watched via .onChange() |
// 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)
@State properties are private@Binding only where child modifies parent state@StateObject for owned, @ObservedObject for injected@State with @Observable, @Bindable for injected@State or @StateObjectObservableObject avoided (or passed directly to child views)references/sheet-navigation-patterns.md).sheet(item:) for model-based sheetsreferences/scroll-patterns.md)ScrollViewReader with stable IDs for programmatic scrollingreferences/view-structure.md)@ViewBuilder let content: Contentreferences/performance-patterns.md)body kept simple and pure (no side effects)bodybodyreferences/list-patterns.md).indices)AnyView in list rowsreferences/layout-best-practices.md)references/animation-basics.md, references/animation-transitions.md, references/animation-advanced.md).animation(_:value:) with value parameterwithAnimation for event-driven animationsAnimatable has explicit animatableData implementation.transaction(value:) for reexecution#available(iOS 26, *) with fallback for Liquid GlassGlassEffectContainer.glassEffect() applied after layout/appearance modifiers.interactive() only on user-interactable elementsreferences/state-management.md - Property wrappers and data flowreferences/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/animation-basics.md - Core animation concepts, implicit/explicit animations, timing, performancereferences/animation-transitions.md - Transitions, custom transitions, Animatable protocolreferences/animation-advanced.md - Transactions, phase/keyframe animations (iOS 17+), completion handlers (iOS 17+)references/sheet-navigation-patterns.md - Sheet presentation and navigation patternsreferences/scroll-patterns.md - ScrollView patterns and programmatic scrollingreferences/image-optimization.md - AsyncImage, image downsampling, and optimizationreferences/liquid-glass.md - iOS 26+ Liquid Glass APIThis skill focuses on facts and best practices, not architectural opinions:
npx claudepluginhub xmgrex/ccx-arsenal --plugin swift-guardianBuilds, reviews, and refactors SwiftUI code with guidance on state management, view composition, performance, accessibility, and iOS 26+ Liquid Glass styling.
Creates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.