home / skills / willsigmon / sigstack / swift-expert
This skill provides Swift and SwiftUI expert guidance for fixing bindings, actor isolation, @Observable migrations, and common compiler errors to improve apps.
npx playbooks add skill willsigmon/sigstack --skill swift-expertReview the files below or copy the command above to add this skill to your agents.
---
name: Swift Expert
description: Swift/SwiftUI issues - compiler errors, bindings, @Observable, actor isolation, best practices
allowed-tools: Read, Edit, Grep
model: sonnet
---
# Swift Expert
Swift and SwiftUI expertise for Leavn app.
## Binding Fixes
Problem: `$viewModel.property` errors
Fix: Add `@Bindable` wrapper in View:
```swift
@Bindable var viewModel: MyViewModel
```
## Actor Isolation (Swift 6)
- `@MainActor` for UI-touching code
- `nonisolated` for pure functions
- `Task { @MainActor in }` for async UI updates
- Never access @MainActor properties in deinit
## @Observable Migration
Old: `@Published var x` + `ObservableObject`
New: `@Observable class` + plain `var x`
View: `@State var vm = ViewModel()` (not @StateObject)
## SwiftUI Anti-Patterns
- Heavy computation in View body → Extract to ViewModel
- @State for reference types → Use @StateObject/@State with @Observable
- Missing @MainActor on ViewModels → Add it
- Force unwrapping in Views → Use nil coalescing
## Common Compiler Errors
- "Cannot convert" → Check Optional unwrapping
- "Actor-isolated" → Add @MainActor or nonisolated
- "Missing conformance" → Add protocol or use type erasure
- "Ambiguous" → Add explicit type annotation
Use when: Swift errors, SwiftUI bugs, migration issues, best practices
This skill provides practical Swift and SwiftUI guidance for fixing compiler errors, migration to the new observation model, actor-isolation issues, and UI binding problems. It focuses on concrete fixes developers can apply quickly in app views and view models. The goal is to reduce time spent debugging SwiftUI quirks and modernize code to Swift 5/6 patterns.
I inspect common compiler messages, SwiftUI binding failures, and actor-isolation diagnostics and map them to minimal, safe code changes. I recommend specific attribute usage (@Observable, @Bindable, @MainActor, nonisolated) and state/property wrappers for views and view models. I also point out anti-patterns to extract work into view models and give targeted fixes for migration issues.
When should I use @Bindable vs @StateObject?
@Bindable is for binding into an @Observable value exposed by the view. Use @StateObject when you own a reference-type view model that conforms to older ObservableObject semantics; prefer @State with @Observable view models after migration.
How do I stop actor-isolated errors touching UI state?
Mark the view model or UI-touching methods with @MainActor, or make helper methods nonisolated if they are pure. For async updates, use Task { @MainActor in ... } to hop to the main actor.