swiftui-development
Skill275 starsChanged 52 days agoApache-2.0View on GitHub
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.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- ProjAnvil/MindForgetheir own version, first seen Nov 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- ProjAnvil/MindForge★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository264 other files it gives its agents.
- accessibility-a11ySkill
- alpine-jsSkill
- analytics-data-analysisSkill
- android-developmentSkill
- angular-developmentSkill
- angularSkill
- anime-jsSkill
- anthropic-claude-developmentSkill
- api-developmentSkill
- apollo-graphqlSkill
- aspnet-coreSkill
- astroSkill
- auth0-authenticationSkill
- autogen-developmentSkill
- automl-hyperparameter-optimizationSkill
- aws-developmentSkill
- azureSkill
- backend-developmentSkill
- bash-scriptingSkill
- beautifulsoup-parsingSkill
- bitbucket-workflowSkill
- blazorSkill
- blender-python-addonSkill
- blockchainSkill
- bootstrapSkill
- business-central-developmentSkill
- cheerio-parsingSkill
- chrome-extension-developmentSkill
- ci-cd-best-practicesSkill
- clean-architectureSkill
- clean-codeSkill
- clerk-authenticationSkill
- cloudflare-developmentSkill
- computer-vision-opencvSkill
- convexSkill
- cppSkill
- c-sharpSkill
- cssSkill
- cypressSkill
- data-analysis-jupyterSkill
- data-analystSkill
- data-jupyter-pythonSkill
- deep-learning-pythonSkill
- deep-learning-pytorchSkill
- deep-learningSkill
- deno-typescriptSkill
- design-systemsSkill
- devopsSkill
- django-pythonSkill
- django-rest-api-developmentSkill
- dockerSkill
- dotnetSkill
- drizzle-ormSkill
- drupal-developmentSkill
- elasticsearch-best-practicesSkill
- electron-developmentSkill
- elixirSkill
- embedded-stm32Skill
- esbuild-bundlerSkill
- ethereumSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
29 rules. About 0 are common, 10 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Write correct, up-to-date, bug-free, fully functional, secure, and performant code
- Distinctive: line 23
Use MVVM (Model-View-ViewModel) or Clean Architecture.
- Distinctive: line 31
Use extensions for code organization and separation of concerns
- Distinctive: line 35
Keep views small and focused on a single responsibility
- Very specific: line 36
Treat 50 lines as a practical ceiling for a body property — past that, extract subviews into small, reusable structs or private extension …
- Very specific: line 37
Use @ViewBuilder for custom container views and complex conditional view logic
- Very specific: line 53
Use descriptive, verbose names — fetchUserData over getData
- Distinctive: line 55
Use verb phrases for function names
- Distinctive: line 59
Use SF Symbols for system icons.
- Very specific: line 61
Use NavigationStack (iOS 16+) over the deprecated NavigationView
- Very specific: line 62
Prefer type-inferred shorthand dot syntax where available (e.g., .background(.blue))
- Very specific: line 63
Add .contentShape(Rectangle()) to HStack/VStack rows that have transparent backgrounds, so taps register across the whole row rather than …
- Very specific: line 67
Use native SwiftUI layout containers (VStack, HStack, ZStack, Grid).
- Very specific: line 68
Use GeometryReader sparingly — it expands to fill all available space and can hurt layout performance.
- Very specific: line 71
Use ViewModifiers for reusable styling.
- Very specific: line 75
Prefer .animation(_:value:) scoped to a specific state value over broad withAnimation calls, especially inside body
- Very specific: line 78
Use TimelineView for high-frequency, time-driven visual updates instead of a Timer + published property
- Very specific: line 83
Prefer .task(id:) over .onAppear for starting async work — it automatically cancels the task when the view disappears or the id changes, …
- Very specific: line 84
Use async/await for asynchronous operations and Result (or typed throws) for error handling
- Very specific: line 85
Prefer actor types for shared mutable state or services accessed from multiple tasks
- Very specific: line 87
Never block the main thread — move heavy computation to a detached Task
- Very specific: line 92
Default to [weak self] in closures that outlive the current scope.
- Very specific: line 93
Only use [unowned self] when the closure's lifetime is provably shorter than self's
- Distinctive: line 105
Add accessibility labels, hints, and traits appropriately.
- Distinctive: line 107
Test with accessibility features (Dynamic Type, VoiceOver, Reduce Motion) enabled
- Very specific: line 111
Always provide a preview using #Preview (Xcode 15+) or PreviewProvider on older toolchains, injecting realistic mock data
- Distinctive: line 117
Write self-documenting code.
- Distinctive: line 118
Follow the Swift API Design Guidelines
- Very specific: line 119
Use MARK: - Section Name to organize longer files, and place private helpers in a private extension
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.onAppearfor starting async work — it automatically cancels the task when the view disappears or the id changes, avoiding orphaned work - Use
async/awaitfor asynchronous operations andResult(or typed throws) for error handling - Prefer
actortypes for shared mutable state or services accessed from multiple tasks - Mark pure logic functions
nonisolatedwhen they don't touch the main actor, to avoid unnecessary hops - Never block the main thread — move heavy computation to a detached
Task - Handle loading, error, and success states explicitly rather than leaving implicit/undefined states
Memory Management & Safety
- Default to
[weak self]in closures that outlive the current scope; useguard let self else { return }at the start of async closures - Only use
[unowned self]when the closure's lifetime is provably shorter thanself's - Handle optionals safely — no force unwrapping; use
guardfor early returns - For remote images, use
AsyncImage(with a caching layer, or a library like Nuke/Kingfisher for production apps) and apply.resizable()immediately
Performance Optimization
- Minimize view body recalculations; adopt
Equatableconformance where it helps SwiftUI skip redundant diffing - Implement proper list diffing with
Identifiableitems and stable ids - Profile with Instruments before optimizing; cache expensive computations rather than recomputing them in
body
Accessibility
- Add accessibility labels, hints, and traits appropriately; support VoiceOver
- Assign distinct
accessibilityIdentifierstrings to interactive elements so UI tests can target them reliably - Test with accessibility features (Dynamic Type, VoiceOver, Reduce Motion) enabled
Testing and Previews
- Always provide a preview using
#Preview(Xcode 15+) orPreviewProvideron older toolchains, injecting realistic mock data - Preview in multiple color schemes and device sizes
- Structure unit tests with Given-When-Then; generate protocol-based mocks for external dependencies so view models can be tested without hitting real services
Code Quality
- Write self-documenting code; add comments only for non-obvious logic
- Follow the Swift API Design Guidelines
- Use
MARK: - Section Nameto organize longer files, and place private helpers in aprivate extension
Common Patterns
View with @Observable ViewModel (iOS 17+)
@Observable
@MainActor
final class ContentViewModel {
var items: [Item] = []
var isLoading = false
func loadItems() async {
isLoading = true
defer { isLoading = false }
// Load items
}
}
struct ContentView: View {
@State private var viewModel = ContentViewModel()
var body: some View {
List(viewModel.items) { item in
Text(item.name)
}
.task(id: viewModel.items.count) {
await viewModel.loadItems()
}
}
}View with ObservableObject ViewModel (pre-iOS 17 / legacy)
struct ContentView: View {
@StateObject private var viewModel = ContentViewModel()
var body: some View {
// View implementation
}
}
@MainActor
class ContentViewModel: ObservableObject {
@Published var items: [Item] = []
@Published var isLoading = false
func loadItems() async {
isLoading = true
// Load items
isLoading = false
}
}Reusable View Modifier
struct CardModifier: ViewModifier {
func body(content: Content) -> some View {
content
.padding()
.background(Color(.systemBackground))
.cornerRadius(12)
.shadow(radius: 4)
}
}
extension View {
func cardStyle() -> some View {
modifier(CardModifier())
}
}</content>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

