
Swift Swiftui
Swift 6 and SwiftUI code rules for macOS apps, including concurrency, state, SwiftData...
Install
npx skills add daveebbelaar/bama --skill swift-swiftui -g -a claude-code -y- Repository
- daveebbelaar/bama1.3k
- Category
- Testing
- Updated
- 3d ago
- License
- MIT
- Context cost
- Mediumabout 1,813 tokens
- Runs scripts
- No, instructions only
What it does
Swift 6 and SwiftUI code rules for macOS apps, including concurrency, state, SwiftData, AppKit bridges, and fixes for common compiler errors. Use when writing, reviewing, or debugging Swift code in a Mac app, or on concurrency, Sendable, or "not in scope" errors.
Swift and SwiftUI
The code is right when it compiles with zero warnings in Swift 6 language
mode and the app does what the story says. For how it should look, call the
Skill tool with mac-design. For copyable view code, read
../../design/mac-design/patterns.md.
Concurrency
The template sets main-actor default isolation: every type and function runs on the main actor unless you say otherwise. UI code needs no annotations.
| Work | Put it in |
|---|---|
| UI state, views, view models | Default (main actor) |
| CPU-heavy pure work (parsing, image work, diffing) | A nonisolated function marked @concurrent |
| Shared mutable state used off the main thread | An actor |
| A C callback (event tap, Carbon hotkey, CoreAudio listener) | A nonisolated static func that hops back with Task { @MainActor in ... } |
- Data that crosses actors is
Sendable: structs and enums ofSendablevalues, orfinal classwith onlyletproperties. MainActor.assumeIsolated { }inside a callback you know runs on the main thread (a main run loopTimer, a main queue notification).Task { }inherits the actor.Task.detachedonly when it must not.- Fix a concurrency error at its type, not with
@unchecked Sendableornonisolated(unsafe). Those two are a last resort, with a comment why. - Runtime trap the compiler misses. A closure created inside a
@MainActortype and passed to an API without a@Sendableclosure parameter (DispatchSource.setEventHandler,DispatchWorkItem,addPeriodicTimeObserver, CoreAudio listener blocks) inherits the main actor. When it runs on a background queue, Swift 6 crashes the app. Write it as{ @Sendable in ... }, and run every background path once after any concurrency change.


