Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/efremidze/swift-patterns-skill --skill swift-patterns- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads swift-patterns automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
swift-patterns
Review, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, and performance-conscious patterns. Prioritize native APIs, Apple design guidance, and testable code structure. This skill focuses on facts and best practices without enforcing specific architectural patterns.
Workflow Decision Tree
1) Review existing SwiftUI code
→ Read references/workflows-review.md for review methodology
- Check state management against property wrapper selection (see
references/state.md) - Verify view composition and extraction patterns (see
references/view-composition.md) - Audit list performance and identity stability (see
references/lists-collections.md) - Validate modern API usage (see
references/modern-swiftui-apis.md) - Check async work patterns with .task (see
references/concurrency.md) - Verify navigation implementation (see
references/navigation.md) - Use Review Response Template (below)
2) Refactor existing SwiftUI code
→ Read references/workflows-refactor.md for refactor methodology
- Extract complex views using playbooks (see
references/refactor-playbooks.md) - Migrate deprecated APIs to modern equivalents (see
references/modern-swiftui-apis.md) - Optimize performance hot paths (see
references/performance.md) - Restructure state ownership (see
references/state.md) - Apply common patterns (see
references/patterns.md) - Use Refactor Response Template (below)
3) Implement new SwiftUI features
- Design data flow first: identify owned vs injected state (see
references/state.md) - Structure views for optimal composition (see
references/view-composition.md) - Use modern APIs only (see
references/modern-swiftui-apis.md) - Handle async work with .task modifier (see
references/concurrency.md) - Apply performance patterns early (see
references/performance.md) - Implement navigation flows (see
references/navigation.md)
4) Answer best practice questions
- Load relevant reference file(s) based on topic (see Reference Files below)
- Provide direct guidance with examples
If intent unclear, ask: "Do you want findings only (review), or should I change the code (refactor)?"
Response Templates
Review Response:
- Scope - What was reviewed
- Findings - Grouped by severity with actionable statements
- Evidence - File paths or code locations
- Risks and tradeoffs - What could break or needs attention
- Next steps - What to fix first or verify
Refactor Response:
- Intent + scope - What is being changed and why
- Changes - Bulleted list with file paths
- Behavior preservation - What should remain unchanged
- Next steps - Tests or verification needed
Quick Reference: Property Wrapper Selection
| Wrapper | Use When | Ownership |
|---|---|---|
@State | Internal view state (value type or @Observable class) | View owns |
@Binding | Child needs to modify parent's state | Parent owns |
@Bindable | Injected @Observable object needing bindings | Injected |
let | Read-only value from parent | Injected |
var + .onChange() | Read-only value needing reactive updates | Injected |
Key rules:
- Always mark
@Stateasprivate(makes ownership explicit) - Never use
@Statefor passed values (accepts initial value only) - Use
@Statewith@Observableclasses (not@StateObject)
See references/state.md for detailed guidance and tradeoffs.
Quick Reference: Modern API Replacements
| Deprecated | Modern Alternative | Notes |
|---|---|---|
foregroundColor() | foregroundStyle() | Supports dynamic type |
cornerRadius() | .clipShape(.rect(cornerRadius:)) | More flexible |
NavigationView | NavigationStack | Type-safe navigation |
tabItem() | Tab API | iOS 18+ |
onTapGesture() | Button | Unless need location/count |
onChange(of:) { value in } | onChange(of:) { old, new in } or onChange(of:) { } | Two or zero parameters |
UIScreen.main.bounds | GeometryReader or layout APIs | Avoid hard-coded sizes |
See references/modern-swiftui-apis.md for complete migration guide.
Review Checklist
Use this when reviewing SwiftUI code:
State Management
-
@Stateproperties markedprivate - Passed values NOT declared as
@Stateor@StateObject -
@Bindingonly where child modifies parent state - Property wrapper selection follows ownership rules
- State ownership clear and intentional
Modern APIs
- No deprecated modifiers (foregroundColor, cornerRadius, etc.)
- Using
NavigationStackinstead ofNavigationView - Using
Buttoninstead ofonTapGesturewhen appropriate - Using two-parameter or no-parameter
onChange()
View Composition
- Using modifiers over conditionals for state changes (maintains identity)
- Complex views extracted to separate subviews
- Views kept small and focused
- View
bodysimple and pure (no side effects)
Navigation & Sheets
- Using
navigationDestination(for:)for type-safe navigation - Using
.sheet(item:)for model-based sheets - Sheets own their dismiss actions
Lists & Collections
-
ForEachuses stable identity (never.indicesfor dynamic data) - Constant number of views per
ForEachelement - No inline filtering in
ForEach(prefilter and cache) - No
AnyViewin list rows
Performance
- Passing only needed values to views (not large config objects)
- Eliminating unnecessary dependencies
- Checking value changes before state assignment in hot paths
- Using
LazyVStack/LazyHStackfor large lists - No object creation in view
body
Async Work
- Using
.taskfor automatic cancellation - Using
.task(id:)for value-dependent tasks - Not mixing
.onAppearwith async work
See reference files for detailed explanations of each item.
Constraints
- Swift/SwiftUI focus only - Exclude server-side Swift and UIKit unless bridging required
- No Swift concurrency patterns - Use
.taskfor SwiftUI async work - No architecture mandates - Don't require MVVM/MVC/VIPER or specific structures
- No formatting/linting rules - Focus on correctness and patterns
- No tool-specific guidance - No Xcode, Instruments, or IDE instructions
- Citations allowed:
developer.apple.com/documentation/swiftui/,developer.apple.com/documentation/swift/
All workflows must follow these constraints.
Philosophy
This skill focuses on facts and best practices from Apple's documentation:
- Modern APIs over deprecated ones
- Clear state ownership patterns
- Performance-conscious view composition
- Testable code structure
- No architectural mandates (MVVM/VIPER not required)
- Apple Human Interface Guidelines adherence
Reference Files
All references in references/:
workflows-review.md- Review methodology and findings taxonomyworkflows-refactor.md- Refactor methodology and invariantsrefactor-playbooks.md- Step-by-step refactor guidesstate.md- Property wrappers and ownership patternsnavigation.md- Navigation implementation patternsview-composition.md- View structure and extractionlists-collections.md- Identity and ForEach patternsscrolling.md- Scroll handling and paginationconcurrency.md- Async work with .taskperformance.md- Optimization strategiestesting-di.md- Testing and dependency injectionpatterns.md- Common SwiftUI patternsmodern-swiftui-apis.md- Legacy API migrationcode-review-refactoring.md- Code quality checks
FAQ
What does the swift-patterns skill do?
Review, refactor, or build SwiftUI features with correct state management, modern API usage, optimal view composition, navigation patterns, performance optimization, and testing best practices.
How do I install swift-patterns?
Run npx skills add https://github.com/efremidze/swift-patterns-skill --skill swift-patterns in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/swift-patterns/ (personal) or .claude/skills/swift-patterns/ (project).
Which AI agents can use swift-patterns?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is swift-patterns safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains swift-patterns?
It is published by efremidze in efremidze/swift-patterns-skill. It has 159 recorded installs.
Popular mobile skills
design-mobile-apps
designed-by-ai/skills
Design mobile app screens with Sleek, edit Sleek projects, and implement their designs in React Native or HTML.
ios-design
uizze.sh
Design and review iOS UI/UX for iPhone apps in SwiftUI, UIKit, or React Native. Use for mobile app design, screen redesigns, navigation flows, typography, forms, keyboard and safe-area layout, and accessibility checks. Apply Apple Human Interface Guidelines and consult real product references through the optional Uizze connection.
vercel-react-native-skills
vercel-labs/agent-skills
React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.
animate-expo
emilkowalski/skills
Build animations in React Native and Expo, making the decisions in the order that determines whether they feel right — should it animate, which thread it runs on, which properties, spring or timing, how the gesture hands off, how it degrades. Writes the implementation with Reanimated, Gesture Handler, Expo Router and expo-haptics. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on device. For web animation use animate.
xcode-project-setup
firebase/agent-skills
Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).
firebase-remote-config-basics
firebase/agent-skills
Manages Firebase Remote Config templates, feature flags, loading strategies, and SDKs (Android, iOS). Use when downloading/deploying remoteconfig JSON templates, managing version history/feature flags, setting in-app defaults, fetchAndActivate(), real-time listeners, or SDK setup. Don't use for Firebase Hosting, Auth, Firestore, Data Connect, Crashlytics, or App Hosting.
