swiftui-development
FreeNo executable scriptsNot checkedGuidelines for building SwiftUI applications with MVVM/Clean Architecture, Swift 6 strict concurrency, and modern state management. Use when building SwiftUI…
by Mindrally★ 323 GitHub starsAbout this skill
SwiftUI Development
This skill covers best practices for building clear, performant, and maintainable SwiftUI applications, including architecture, state management, Swift 6 concurrency, layout, animation, and testing.
Key Principles
- Write correct, up-to-date, bug-free, fully functional, secure, and performant code
- Favor readability, but not at the expense of correctness or safety
- Fully implement all requested functionality — leave no TODOs, placeholders, or missing pieces
- Target Swift 6.0+ with strict concurrency checking enabled; treat concurrency warnings as errors
- Target iOS 17+ where possible to use modern APIs (
@Observable,NavigationStack,#Preview); note the minimum deployment target when it forces older patterns
Architecture
- Use MVVM (Model-View-ViewModel) or Clean Architecture; introduce a Coordinator layer for complex, multi-screen navigation flows
- Apply SOLID principles to views and view models:
- Single Responsibility — each view or view model has one reason to change
- Open/Closed — extend behavior via composition and protocols rather than modifying existing types
- Liskov Substitution — protocol conformances must be substitutable without surprising callers
- Interface Segregation — keep protocols small and focused rather than one large "do everything" interface
- Dependency Inversion — depend on protocol abstractions, not concrete types, and inject dependencies via
init
- Implement protocol-oriented programming; prefer structs over classes for data models
- Use extensions for code organization and separation of concerns
SwiftUI View Structure
- Keep views small and focused on a single responsibility
- Treat 50 lines as a practical ceiling for a
bodyproperty — past that, extract subviews into small, reusable structs or private extension functions - Use
@ViewBuilderfor custom container views and complex conditional view logic - Implement proper view composition patterns
State Management
@State— local, value-type view state (Bool, Int, String, small structs)@Binding— two-way data binding with child views@StateObject— use only in the view that creates/owns the object's lifecycle@ObservedObject— use in child views that react to changes but don't own the object@EnvironmentObject/@Environment— use sparingly for broadly shared dependencies or system values; prefer explicit dependency injection viainitwhen a dependency belongs to a specific view hierarchy rather than the whole app@Published— for observable properties onObservableObjectclasses (pre-iOS 17 or whenObservableObjectis otherwise required)@Observablemacro (iOS 17+) — prefer this overObservableObject/@Publishedfor new view models; it removes the need for@Publishedon every property and only triggers view updates for properties actually read by that view, which reduces unnecessary redraws
Naming Conventions
- camelCase for variables, functions, and methods; PascalCase for types (classes, structs, enums, protocols)
- Use descriptive, verbose names —
fetchUserDataovergetData - Prefix boolean variables with
is,has,should, etc. - Use verb phrases for function names
SwiftUI Best Practices
- Use SF Symbols for system icons; use semantic colors from the asset catalog for automatic dark mode support
- Support Dynamic Type and implement proper keyboard avoidance
- Use
NavigationStack(iOS 16+) over the deprecatedNavigationView - Prefer type-inferred shorthand dot syntax where available (e.g.,
.background(.blue)) - Add
.contentShape(Rectangle())toHStack/VStackrows that have transparent backgrounds, so taps register across the whole row rather than only on opaque content
Layout and Styling
- Use native SwiftUI layout containers (VStack, HStack, ZStack, Grid); use
LazyVStack/LazyHStackfor dynamic or long lists - Use
GeometryReadersparingly — it expands to fill all available space and can hurt layout performance; prefer.background(GeometryReader { ... })scoped to a single view, or theLayoutprotocol for custom layouts - Give list items stable, meaningful
ids (fromIdentifiable) rather than\.self - Implement adaptive layouts for different screen sizes
- Use
ViewModifiers for reusable styling; create customButtonStyle,TextFieldStyle, etc.
Animations and Transitions
- Prefer
.animation(_:value:)scoped to a specific state value over broadwithAnimationcalls, especially insidebody - Reserve
withAnimationfor animations explicitly triggered by user interaction - Implement custom transitions using
AnyTransition; usematchedGeometryEffectfor hero animations - Use
TimelineViewfor high-frequency, time-driven visual updates instead of aTimer+ published property
Swift 6 Concurrency & Data Flow
- Annotate view models with
@MainActor; all UI updates must happen on the main actor - Prefer
.task(id:)over.onAppear
Install swiftui-development in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the swiftui-development skill do?
Guidelines for building SwiftUI applications with MVVM/Clean Architecture, Swift 6 strict concurrency, and modern state management. Use when building SwiftUI views, structuring view models, managing state with @State/@Observable, handling async data flow, or optimizing SwiftUI view performance.
How do I install the swiftui-development skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the swiftui-development skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
by Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
by Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
by Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
by Anthropic