macos-patterns

Implements native macOS UI patterns in SwiftUI and AppKit for menu bar apps, panels, and shortcuts.

Updated Mar 12, 2026
One-click install
npx skills add https://github.com/RavitejaKarra24/dotfiles --skill macos-patterns-ravitejakarra24
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: macos-patterns
Source: https://github.com/RavitejaKarra24/dotfiles/tree/main/agents/.agents/skills/macos-patterns
Command: npx skills add https://github.com/RavitejaKarra24/dotfiles --skill macos-patterns-ravitejakarra24

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Web developers building native macOS apps repeatedly hit platform-specific pitfalls—focus-stealing windows, invisible menu bar icons, broken global shortcuts, and flipped coordinate systems—that have no web equivalent. This Skill provides correct, working SwiftUI and AppKit patterns so generated macOS code works the first time. ## Core Features & Use Cases - Menu Bar Apps: Build menu-bar-only apps with SwiftUI MenuBarExtra or AppKit NSStatusItem, including template icons, popovers, and Dock icon toggling via activation policies. - Floating Panels & Window Levels: Create non-activating NSPanel overlays with correct window levels, collection behaviors, and screen-capture exclusion. - System Integration: Register Carbon global hotkeys, handle file pickers, pasteboard operations, drag and drop, launch-at-login via SMAppService, Quick Look previews, and ScreenCaptureKit captures. - Use Case: When asked to build a floating screenshot annotation tool, consult this Skill to correctly configure a borderless non-activating NSPanel that floats above fullscreen apps and stays invisible to screen recording. ## Quick Start Use the macos-patterns skill to review my SwiftUI code for a menu bar app and fix any native macOS pattern mistakes.

Frequently Asked Questions about macos-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a menu bar app in SwiftUI?

Use MenuBarExtra in your App scene with a label and content view for simple menus. For richer popover-style UI, apply the .menuBarExtraStyle(.window) modifier, or drop to AppKit NSStatusItem for full control over icons and menus.

How do I make a floating window that doesn't steal focus on macOS?

Use NSPanel with the .nonactivatingPanel style mask instead of a SwiftUI Window scene. Set isFloatingPanel, hidesOnDeactivate = false, and collectionBehavior with .canJoinAllSpaces and .fullScreenAuxiliary so it stays visible across spaces.

How do I register a global keyboard shortcut on macOS?

Use the Carbon RegisterEventHotKey API, which is the only way to get true system-wide hotkeys that fire when your app is not focused. NSEvent global monitors can observe keys but cannot consume them, and SwiftUI keyboardShortcut only works in-app.

Why is my menu bar icon invisible in light mode?

The icon image is missing isTemplate = true. Setting isTemplate on the NSImage makes macOS automatically adapt the icon's rendering for dark and light menu bar appearances.

Why does writing to the macOS clipboard fail or merge with old content?

NSPasteboard requires calling clearContents() before writing new data. Forgetting this leaves previous pasteboard items in place, causing mixed or stale clipboard content.

Does macOS use the same coordinate system as the web?

No. AppKit uses a bottom-left origin with a flipped Y axis compared to the web, while Core Graphics uses top-left origin. Convert between them using the union of all screen frames, and use NSScreen.visibleFrame to account for the menu bar and Dock.