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,…
Test a macOS app at three levels, from Swift Testing unit tests and an in-app self-test to a debug bridge that lets an agent drive the running app and read its state, plus computer use for real clicks. Use when adding logic, fixing a bug, before a release, or when the user asks
Claude Code
$ npx -y skills add daveebbelaar/bama --skill test-mac-app --agent claude-code
Codex
$ npx skills add daveebbelaar/bama --skill test-mac-app -a codex -y
Cursor
$ npx skills add daveebbelaar/bama --skill test-mac-app -a cursor -y
Gemini CLI
$ npx skills add daveebbelaar/bama --skill test-mac-app -a gemini-cli -y
GitHub Copilot
$ npx skills add daveebbelaar/bama --skill test-mac-app -a github-copilot -y
OpenCode
$ npx skills add daveebbelaar/bama --skill test-mac-app -a opencode -y
Windsurf
$ npx skills add daveebbelaar/bama --skill test-mac-app -a windsurf -y
name: test-mac-app description: Test a macOS app at three levels, from Swift Testing unit tests and an in-app self-test to a debug bridge that lets an agent drive the running app and read its state, plus computer use for real clicks. Use when adding logic, fixing a bug, before a release, or when the user asks for tests, end-to-end checks, or "make sure it works".
Three levels, cheapest first. Each new story gets the cheapest level that can prove its acceptance criteria. A bug fix starts with a test that fails.
| Level | Proves | Speed | | --- | --- | --- | | Unit tests (Swift Testing) | Rules, parsing, data | Seconds | | Self-test (`--selftest`) | The app's real functions on a test store | Seconds | | Key events and menu audit (inside the self-test) | Keyboard flows and every shortcut, without the screen | Seconds | | Debug bridge + computer use | Global shortcuts, panels, permissions, other apps | Minutes |
Snapshots (`build-and-verify` skill) prove how it looks. This skill proves how it behaves.
Logic lives in a library target (`<App>Kit`) with no SwiftUI, so tests run without the app.
import Testing
@testable import AppKitCore
@Test("Natural dates", arguments: [("tomorrow 9am", 1, 9), ("next fri", 5, nil)])
func parses(_ phrase: String, dayOffset: Int, hour: Int?) throws {
let result = try #require(DateParser.parse(phrase, now: .fixed))
#expect(result.dayOffset == dayOffset)
#expect(result.hour == hour)
}swift test --scratch-path ~/Library/Developer/<App>/test-build
negative rows: real titles that contain date or time words ("Watch Friday Night Lights"). Add consistency rows for related phrases ("next week" and "next friday"), and a tested way to undo a parsed part.
`docs/research/<topic>.md` too, and add a row there before changing behavior. A date parser easily needs 100 rows.
A launch flag that runs the same functions the UI calls, prints PASS or FAIL per step, and exits 0 or 1:
APP_STORE=/tmp/<App>-self.store ~/Applications/<App>.app/Contents/MacOS/<App> --selftest # PASS add task # PASS complete task # PASS undo
Always point it at a store in `/tmp`. Never at the user's data.
Checks worth adding to any self-test:
that page. After an action removes the selected row, selection moves to the next row.
few seconds, then print PASS. It is the only check that catches crashes on background queues.
A single-instance app (menu bar utility) cannot launch a second copy with `--selftest`. Make it a bridge command instead. Xcode and XcodeGen apps without a library target: see [../build-and-verify/existing-app.md](../build-and-verify/existing-app.md) for a test target with no host app.
The self-test can press real keys without computer use:
let event = NSEvent.keyEvent(with: .keyDown, location: .zero, modifierFlags: [],
timestamp: 0, windowNumber: window.windowNumber, context: nil,
characters: "\r", charactersIgnoringModifiers: "\r", isARepeat: false, keyCode: 36)!
NSApp.sendEvent(event) // Return in the focused list
NSApp.mainMenu?.performKeyEquivalent(with: commandK) // a menu shortcutSend events with the flags a real keyboard sends. Arrow keys always carry `.numericPad` and `.function`; an event built with `modifierFlags: []` passes a check that the real keyboard fails. In app code, compare only the modifiers people hold down:
let held = event.modifierFlags.intersection(.deviceIndependentFlagsMask)
.subtracting([.numericPad, .function, .capsLock])
if event.keyCode == 124, held.isEmpty { browseInto() } // → with nothing heldTest typing by typing: send key events through `NSApp.sendEvent` and check what the field received. Never set the model's text instead. Setting the text skips focus, and a field that never gets the keyboard still passes. Two apps shipped a typing bug this way: letters went to a panel instead of its filter field, and a typed name landed inside the selected placeholder text.
Walk `NSApp.mainMenu` and check every command's title, key equivalent, modifiers, and symbol against the command map. One loop turns "every action has a menu item and a shortcut" into a check per item.
Focus the list after making the window key (`window.makeKey()`, then `makeFirstResponder(list)`). `NSApp.sendEvent` sends a key event to the key window, so a key event is lost when no window is key. A search field in the toolbar can take focus first, and then list keys and menu items miss the list.
Do not test SwiftUI menu state from inside the app. Its items carry no action selector, `isEnabled` updates on SwiftUI's schedule, and the checks fail whenever another app is in front, which is always true while an agent works. In the self-test, check what the commands receive (the selection passed into them) and run the actions the items call.
Check the real menu from outside, through Accessibility, on a seeded test copy. Computer use `app_menu` works in the background:
1. Nothing selected: To-Do > Complete is reported disabled. 2. Click a row (`app_click`), then To-Do > Complete: the row is done and the next row is selected (`app_screenshot`).
Write these steps into the app's `CLAUDE.md`, so every agent runs them after touching commands.
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…
Swift 6 and SwiftUI code rules for macOS apps, including concurrency, state, SwiftData, AppKit bridges, and fixes for common…
Liquid Glass macOS app icon made as an Icon Composer file (Icon/AppIcon.icon, JSON plus SVG layers), compiled with actool, and…
Decompile Android APK, XAPK, JAR, and AAR files using jadx or Fernflower/Vineflower. Reverse engineer Android apps, extract HTTP…