Swift & SwiftUI Expert
БесплатноБез исполняемых скриптовНе проверенThis skill should be used when the user is working with Swift or SwiftUI, asks to "write SwiftUI code", "create iOS app", "fix SwiftUI view", "help with…
от ojowwalker77★ 110 звёзд на GitHubОб этом скилле
Swift & SwiftUI Expert
Expert-level guidance for Swift and SwiftUI development with modern patterns, iOS 17+/macOS 14+ best practices, and production-ready code generation.
Core Principles
When writing Swift/SwiftUI code, ALWAYS follow these principles:
1. Modern State Management (iOS 17+)
Use @Observable macro instead of ObservableObject:
// MODERN (iOS 17+)
@Observable
class UserViewModel {
var name: String = ""
var isLoggedIn: Bool = false
}
// View owns the model
struct ContentView: View {
@State private var viewModel = UserViewModel()
var body: some View {
Text(viewModel.name)
}
}
// Child view (read-only) - NO wrapper needed
struct ProfileView: View {
var viewModel: UserViewModel // Just pass it
var body: some View {
Text(viewModel.name)
}
}
// Child view (needs binding)
struct EditView: View {
@Bindable var viewModel: UserViewModel
var body: some View {
TextField("Name", text: $viewModel.name)
}
}
2. Property Wrapper Decision Tree
| Use Case | Property Wrapper |
|---|---|
| Local view state (value types) | @State |
| Two-way binding to parent state | @Binding |
| Observable model (view owns) | @State + @Observable class |
| Observable model (read-only child) | No wrapper (just pass object) |
| Observable model (needs binding) | @Bindable |
| Shared app-wide state | @Environment |
| User defaults | @AppStorage |
| Scene storage | @SceneStorage |
| Focus state | @FocusState |
3. Architecture Patterns
For most apps: Modern MVVM with @Observable
For large apps with teams: TCA (Composable Architecture)
For simple views: No ViewModel needed
See references/architecture.md for detailed patterns.
Anti-Patterns to AVOID
State Management
// WRONG: @ObservedObject with initialization
@ObservedObject var viewModel = ViewModel() // Will crash!
// RIGHT: Use @StateObject or @State
@StateObject private var viewModel = ViewModel() // Legacy
@State private var viewModel = ViewModel() // Modern (iOS 17+)
// WRONG: @State with reference types
@State var user: User // Where User is a class
// RIGHT: @State only for value types
@State var userName: String
@State private var viewModel = ViewModel() // Only with @Observable
// WRONG: Clearing data on error
func refresh() async {
self.items = [] // Data disappears if error occurs!
do {
self.items = try await fetchItems()
} catch {
// Items now empty forever
}
}
// RIGHT: Preserve existing data
func refresh() async {
do {
self.items = try await fetchItems()
} catch {
// Keep existing items, show error toast
}
}
Performance
// WRONG: Heavy computation in body
var body: some View {
let sorted = items.sorted { ... }.filter { ... } // Runs every render!
List(sorted) { ... }
}
// RIGHT: Memoize or compute elsewhere
var sortedItems: [Item] {
items.sorted { ... }.filter { ... }
} // Or use @State for expensive computations
// WRONG: Using id modifier on lazy content
LazyVStack {
ForEach(items) { item in
ItemView(item: item)
.id(item.id) // Breaks lazy loading!
}
}
// RIGHT: Let ForEach handle identity
LazyVStack {
ForEach(items) { item in
ItemView(item: item) // ForEach uses Identifiable
}
}
Navigation
// WRONG: Using deprecated NavigationView
NavigationView {
List { ... }
}
// RIGHT: Use NavigationStack (iOS 16+)
NavigationStack {
List { ... }
}
Code Generation Guidelines
When generating Swift/SwiftUI code:
- Target iOS 17+/macOS 14+ unless user specifies otherwise
- Use
@Observableinstead ofObservableObject/@Published - Use NavigationStack instead of NavigationView
- Use
.taskinstead of.onAppearfor async work - Use Swift concurrency (async/await) instead of Combine for new code
- Make @State private always
- Prefer value types (structs, enums) over classes
- Use optionals correctly - never force unwrap without safety
- Handle errors explicitly - use do-catch, not try?
- Add accessibility - labels, hints, traits
Reference Documents
For detailed guidance, consult:
references/state-management.md- Property wrappers, @Observable, data flowreferences/architecture.md- MVVM, TCA, Clean Architecture patternsreferences/navigation.md- NavigationStack, programmatic navigation, deep linksreferences/performance.md- Lazy views, List optimization, render cyclesreferences/concurrency.md- async/await, actors, MainActor, Taskreferences/testing.md- Unit tests, ViewInspector, UI testsreferences/accessibility.md- VoiceOver, Dynamic Type, accessibility modifiersreferences/swiftdata.md- @Model, @Query, persistence patterns- **`references
Установить Swift & SwiftUI Expert в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
mcp__plugin_matrix_matrix__matrix_find_callersmcp__plugin_matrix_matrix__matrix_find_definitionmcp__plugin_matrix_matrix__matrix_search_symbolsmcp__plugin_matrix_matrix__matrix_list_exportsmcp__plugin_matrix_matrix__matrix_get_importsmcp__plugin_matrix_matrix__matrix_index_statusmcp__plugin_matrix_matrix__matrix_recallmcp__plugin_matrix_matrix__matrix_storemcp__plugin_matrix_matrix__matrix_rewardmcp__plugin_matrix_matrix__matrix_failuremcp__plugin_matrix_context7__resolve-library-idmcp__plugin_matrix_context7__query-docsReadEditWriteGrepGlobBashВложенные файлы
FAQ
Что делает скилл Swift & SwiftUI Expert?
This skill should be used when the user is working with Swift or SwiftUI, asks to "write SwiftUI code", "create iOS app", "fix SwiftUI view", "help with Swift", "SwiftUI architecture", "iOS development", or needs expert-level Swift/SwiftUI guidance with modern patterns and best practices.
Как установить скилл Swift & SwiftUI Expert?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Swift & SwiftUI Expert запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic