swiftui-expert-skill

30
8
Source

Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, modern APIs, Swift concurrency, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns.

Install

mkdir -p .claude/skills/swiftui-expert-skill && curl -L -o skill.zip "https://mcp.directory/api/skills/download/1534" && unzip -o skill.zip -d .claude/skills/swiftui-expert-skill && rm skill.zip

Installs to .claude/skills/swiftui-expert-skill

About this skill

SwiftUI Expert Skill

Overview

Use this skill to build, review, or improve SwiftUI features with correct state management, modern API usage, Swift concurrency best practices, 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.

When to Use This Skill

Use this skill when:

  • Building new SwiftUI features
  • Refactoring existing SwiftUI views
  • Reviewing SwiftUI code quality
  • Adopting modern SwiftUI patterns
  • Working with SwiftUI state management
  • Implementing iOS 26+ Liquid Glass styling

Workflow Decision Tree

1) Review existing SwiftUI code

  • Check property wrapper usage against the selection guide (see references/state-management.md)
  • Verify modern API usage (see references/modern-apis.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)
  • 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

  • Audit state management for correct wrapper selection (prefer @Observable over ObservableObject)
  • Replace deprecated APIs with modern equivalents (see references/modern-apis.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)
  • 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

  • Design data flow first: identify owned vs injected state (see references/state-management.md)
  • Use modern APIs (no deprecated modifiers or patterns, see references/modern-apis.md)
  • Use @Observable for shared state (with @MainActor if not using default actor isolation)
  • Structure views for optimal diffing (extract subviews early, keep views small, see references/view-structure.md)
  • Separate business logic into testable models (see references/layout-best-practices.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

  • Always prefer @Observable over ObservableObject for new code
  • Mark @Observable classes with @MainActor unless using default actor isolation
  • Always mark @State and @StateObject as private (makes dependencies clear)
  • Never declare passed values as @State or @StateObject (they only accept initial values)
  • Use @State with @Observable classes (not @StateObject)
  • @Binding only when child needs to modify parent state
  • @Bindable for injected @Observable objects needing bindings
  • Use let for read-only values; var + .onChange() for reactive reads
  • Legacy: @StateObject for owned ObservableObject; @ObservedObject for injected
  • Nested ObservableObject doesn't work (pass nested objects directly); @Observable handles nesting fine

Modern APIs

  • Use foregroundStyle() instead of foregroundColor()
  • Use clipShape(.rect(cornerRadius:)) instead of cornerRadius()
  • Use Tab API instead of tabItem()
  • Use Button instead of onTapGesture() (unless need location/count)
  • Use NavigationStack instead of NavigationView
  • Use navigationDestination(for:) for type-safe navigation
  • Use two-parameter or no-parameter onChange() variant
  • Use ImageRenderer for rendering SwiftUI views
  • Use .sheet(item:) instead of .sheet(isPresented:) for model-based content
  • Sheets should own their actions and call dismiss() internally
  • Use ScrollViewReader for programmatic scrolling with stable IDs
  • Avoid UIScreen.main.bounds for sizing
  • Avoid GeometryReader when alternatives exist (e.g., containerRelativeFrame())

Swift Best Practices

  • Use modern Text formatting (.format parameters, not String(format:))
  • Use localizedStandardContains() for user-input filtering (not contains())
  • Prefer static member lookup (.blue vs Color.blue)
  • Use .task modifier for automatic cancellation of async work
  • Use .task(id:) for value-dependent tasks

View Composition

  • Prefer modifiers over conditional views for state changes (maintains view identity)
  • Extract complex views into separate subviews for better readability and performance
  • Keep views small for optimal performance
  • 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
  • Separate business logic into testable models (not about enforcing architectures)
  • Action handlers should reference methods, not contain inline logic
  • Use relative layout over hard-coded constants
  • 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, 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._printChanges() to debug unexpected view updates

Liquid Glass (iOS 26+)

Only adopt when explicitly requested by the user.

  • Use native glassEffect, GlassEffectContainer, and glass button styles
  • Wrap multiple glass elements in GlassEffectContainer
  • Apply .glassEffect() after layout and visual modifiers
  • Use .interactive() only for tappable/focusable elements
  • Use glassEffectID with @Namespace for morphing transitions

Quick Reference

Property Wrapper Selection (Modern)

WrapperUse When
@StateInternal view state (must be private), or owned @Observable class
@BindingChild modifies parent's state
@BindableInjected @Observable needing bindings
letRead-only value from parent
varRead-only value watched via .onChange()

Legacy (Pre-iOS 17):

WrapperUse When
@StateObjectView owns an ObservableObject (use @State with @Observable instead)
@ObservedObjectView receives an ObservableObject

Modern API Replacements

DeprecatedModern Alternative
foregroundColor()foregroundStyle()
cornerRadius()clipShape(.rect(cornerRadius:))
tabItem()Tab API
onTapGesture()Button (unless need location/count)
NavigationViewNavigationStack
onChange(of:) { value in }onChange(of:) { old, new in } or onChange(of:) { }
fontWeight(.bold)bold()
GeometryReadercontainerRelativeFrame() or visualEffect()
showsIndicators: false.scrollIndicators(.hidden)
String(format: "%.2f", value)Text(value, format: .number.precision(.fractionLength(2)))
string.contains(search)string.localizedStandardContains(search) (for user input)

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

State Management

  • Using @Observable instead of ObservableObject for new code
  • @Observable classes marked with @MainActor (if needed)
  • Using @State with @Observable classes (not @StateObject)
  • @State and @StateObject properties are private
  • Passed values NOT declared as @State or @StateObject
  • @Binding only where child modifies parent state
  • @Bindable for injected @Observable needing bindings
  • Nested ObservableObject avoided (or passed directly to child views)

Modern APIs (see references/modern-apis.md)

  • Using foregroundStyle() instead of foregroundColor()
  • Using clipShape(.rect(cornerRadius:)) instead of cornerRadius()
  • Using Tab API instead of tabItem()
  • Using Button instead of onTapGesture() (unless need location/count)
  • Using NavigationStack instead of NavigationView
  • Avoiding UIScreen.main.bounds
  • Using alternatives to GeometryReader when possible
  • Button images include text labels for accessibility

Sheets & Navigation (see references/sheet-navigation-patterns.md)

  • Using .sheet(item:) for model-based sheets
  • Sheets own their actions and dismiss internally
  • [

Content truncated.

unity-developer

sickn33

Build Unity games with optimized C# scripts, efficient rendering, and proper asset management. Masters Unity 6 LTS, URP/HDRP pipelines, and cross-platform deployment. Handles gameplay systems, UI implementation, and platform optimization. Use PROACTIVELY for Unity performance issues, game mechanics, or cross-platform builds.

24695

mobile-design

sickn33

Mobile-first design and engineering doctrine for iOS and Android apps. Covers touch interaction, performance, platform conventions, offline behavior, and mobile-specific decision-making. Teaches principles and constraints, not fixed layouts. Use for React Native, Flutter, or native mobile apps.

14183

frontend-slides

sickn33

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

15573

minecraft-bukkit-pro

sickn33

Master Minecraft server plugin development with Bukkit, Spigot, and Paper APIs. Specializes in event-driven architecture, command systems, world manipulation, player management, and performance optimization. Use PROACTIVELY for plugin architecture, gameplay mechanics, server-side features, or cross-version compatibility.

6772

flutter-expert

sickn33

Master Flutter development with Dart 3, advanced widgets, and multi-platform deployment. Handles state management, animations, testing, and performance optimization for mobile, web, desktop, and embedded platforms. Use PROACTIVELY for Flutter architecture, UI implementation, or cross-platform features.

11965

fastapi-pro

sickn33

Build high-performance async APIs with FastAPI, SQLAlchemy 2.0, and Pydantic V2. Master microservices, WebSockets, and modern Python async patterns. Use PROACTIVELY for FastAPI development, async optimization, or API architecture.

14962

You might also like

flutter-development

aj-geddes

Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.

1,5671,368

ui-ux-pro-max

nextlevelbuilder

"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."

1,1141,185

drawio-diagrams-enhanced

jgtolentino

Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.

1,4151,108

godot

bfollington

This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.

1,192746

nano-banana-pro

garg-aayush

Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.

1,149683

pdf-to-markdown

aliceisjustplaying

Convert entire PDF documents to clean, structured Markdown for full context loading. Use this skill when the user wants to extract ALL text from a PDF into context (not grep/search), when discussing or analyzing PDF content in full, when the user mentions "load the whole PDF", "bring the PDF into context", "read the entire PDF", or when partial extraction/grepping would miss important context. This is the preferred method for PDF text extraction over page-by-page or grep approaches.

1,306610

Stay ahead of the MCP ecosystem

Get weekly updates on new skills and servers.