agent-cli
Optional command line and MCP server for a macOS app, so Claude Code, Codex, and scripts can drive it (list, add, change, search,…
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.
Claude Code
$ npx -y skills add daveebbelaar/bama --skill swift-swiftui --agent claude-code
Codex
$ npx skills add daveebbelaar/bama --skill swift-swiftui -a codex -y
Cursor
$ npx skills add daveebbelaar/bama --skill swift-swiftui -a cursor -y
Gemini CLI
$ npx skills add daveebbelaar/bama --skill swift-swiftui -a gemini-cli -y
GitHub Copilot
$ npx skills add daveebbelaar/bama --skill swift-swiftui -a github-copilot -y
OpenCode
$ npx skills add daveebbelaar/bama --skill swift-swiftui -a opencode -y
Windsurf
$ npx skills add daveebbelaar/bama --skill swift-swiftui -a windsurf -y
name: swift-swiftui description: 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.
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](../../design/mac-design/patterns.md).
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 ... }` |
values, or `final class` with only `let` properties.
thread (a main run loop `Timer`, a main queue notification).
`nonisolated(unsafe)`. Those two are a last resort, with a comment why.
`@MainActor` type and passed to an API without a `@Sendable` closure 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.
`@Bindable` to bind to its properties, `.environment(model)` to share it.
trigger a redraw.
Keychain for secrets.
can delete: a row can read an index that no longer exists and crash. Get a binding by looking the item up by id.
`@Environment(\.modelContext)` to insert and delete.
(`APP_STORE`) so tests never touch the real data.
first save, so it breaks selection and lookups.
SwiftData's automatic undo is not reliable. Code in [../../design/mac-design/patterns.md](../../design/mac-design/patterns.md) (Undo with SwiftData).
through a small library target instead.
SwiftUI `Commands` do not observe `@Observable` models, so a title or a `.disabled(...)` that reads the model goes stale. In testing, neither `@FocusedValue` (from `.focusedSceneValue`) nor an `@ObservedObject` inside the commands updated reliably: the menu stayed disabled with a row selected. What works: mirror the selection into a small `ObservableObject`, observe it in the `App`, and pass the values into the commands. The App's body then rebuilds the menus when they change.
@MainActor final class MenuState: ObservableObject {
static let shared = MenuState()
@Published private(set) var selection: Set<UUID> = []
func update(_ s: Set<UUID>) { if selection != s { selection = s } }
}
// AppModel: var selection: Set<UUID> = [] { didSet { MenuState.shared.update(selection) } }
struct MyApp: App {
@ObservedObject private var menu = MenuState.shared
var body: some Scene {
Window("App", id: "main") { ContentView() }
.commands { AppCommands(model: model, selectedIDs: menu.selection) }
}
}Disable items with `.disabled(selectedIDs.isEmpty)` and resolve the target again when the item fires. Never ship items that stay enabled and do nothing. Check the menu from outside the app (`test-mac-app` skill, "Menu check").
A menu shortcut also fires while a text field has focus. Never use Delete, Command-Delete, arrows, or Return as menu shortcuts. Handle them on the list with `.onDeleteCommand` and `.onKeyPress`.
Never name a type `Task`, `View`, `Color`, `Image`, `Text`, `Section`, `Label`, `Menu`, `Group`, or `Settings`. `Task` breaks every `Task { }`. Use `Todo`, `TaskItem`, `NoteSection`.
SwiftUI covers windows, lists, and forms. AppKit is still the answer for:
`.nonactivatingPanel` hosting a SwiftUI view (`NSHostingView`, with `sizingOptions = []` for a fixed frame).
monitor when the view goes away.
For system hooks (hotkeys, Accessibility, screen capture), call the Skill tool with `os-integrations`.
| Error | Fix | | --- | --- | | `cannot find 'X' in scope` right after adding a file | `swift package clean --scratch-path ~/Library/Developer/<AppName>/build` | | `Main actor-isolated ..
BAMA: Build Any Mac App. Agent skills to research, clone, design, build, optimize, and test native macOS apps with Swift and SwiftUI.
Optional command line and MCP server for a macOS app, so Claude Code, Codex, and scripts can drive it (list, add, change, search,…
Architecture check-in for a growing macOS Swift codebase. Finds hot spots, proposes deeper modules, and refactors one step per…
Deep macOS integrations for a native app, such as global hotkeys, menu bar items, floating panels, window control with…
Make a macOS app fast by measuring hangs, stutter, CPU, memory, and energy, then moving work off the main thread and onto the…
Liquid Glass macOS app icon made as an Icon Composer file (Icon/AppIcon.icon, JSON plus SVG layers), compiled with actool, and…
Rebuild the look of an app the user likes as a native SwiftUI design kit, by measuring its screenshots (sizes, spacing, type,…
Decompile Android APK, XAPK, JAR, and AAR files using jadx or Fernflower/Vineflower. Reverse engineer Android apps, extract HTTP…