Tooluck logoTooluck
SKILL.md

swift-swiftui

Agent skill fromdaveebbelaar/bama

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.

How to install swift-swiftui

install swift-swiftui
# install the bama pack with the skills CLI
npx skills add daveebbelaar/bama

# or add only this skill to Claude Code: copy the folder

skills/code/swift-swiftui/

# into

~/.claude/skills/swift-swiftui/ (all projects)

.claude/skills/swift-swiftui/ (one project)

skills/code/swift-swiftui/SKILL.md

MITFull file
1# Swift and SwiftUI
2
3The code is right when it compiles with zero warnings in Swift 6 language
4mode and the app does what the story says. For how it should look, call the
5Skill tool with `mac-design`. For copyable view code, read
6[../../design/mac-design/patterns.md](../../design/mac-design/patterns.md).
7
8## Concurrency
9
10The template sets main-actor default isolation: every type and function runs
11on the main actor unless you say otherwise. UI code needs no annotations.
12
13| Work | Put it in |
14| --- | --- |
15| UI state, views, view models | Default (main actor) |
16| CPU-heavy pure work (parsing, image work, diffing) | A `nonisolated` function marked `@concurrent` |
17| Shared mutable state used off the main thread | An `actor` |
18| A C callback (event tap, Carbon hotkey, CoreAudio listener) | A `nonisolated` static func that hops back with `Task { @MainActor in ... }` |
19
20- Data that crosses actors is `Sendable`: structs and enums of `Sendable`
21 values, or `final class` with only `let` properties.
22- `MainActor.assumeIsolated { }` inside a callback you know runs on the main
23 thread (a main run loop `Timer`, a main queue notification).
24- `Task { }` inherits the actor. `Task.detached` only when it must not.
25- Fix a concurrency error at its type, not with `@unchecked Sendable` or
26 `nonisolated(unsafe)`. Those two are a last resort, with a comment why.
27- **Runtime trap the compiler misses.** A closure created inside a
28…

Excerpt shown under the repository's MIT license.

More skills in bama

Keep exploring

Similar skill repositories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates