Agent skill

Swiftui Patterns

by robinebers in robinebers/openusage

Best practices and example-driven guidance for building native macOS SwiftUI scenes and components, including windows, commands, toolbars, settings, split views, inspectors, menu bar extras, and…

MITAuto-check passedMobile

Install Swiftui Patterns

skills CLI
$ npx skills add robinebers/openusage --skill swiftui-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install robinebers/openusage swiftui-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/robinebers/openusage.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/swiftui-patterns .claude/skills/swiftui-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
swiftui-patterns
GitHub stars
4.3k
Token cost
~3.4k tokens
SKILL.md length
1,613 words
Files
7 (incl. references)
Skills in repo
25
Repo updated
First seen
Licence
MIT

At a glance

Best practices and example-driven guidance for building native macOS SwiftUI scenes and components, including windows, commands, toolbars, settings, split views, inspectors, menu bar extras, and…

  • Works in 5 steps: Choose the scene model. → Choose state ownership: app-wide,… → Sketch file and module boundaries. → …
  • Refactoring macOS SwiftUI UI
  • SKILL.md covers Quick Start, New App File Structure, Pre-Edit Checklist For New App… and General Rules To Follow, plus 7 more sections
  • Calls git

What it does

Swiftui Patterns is an agent skill from robinebers/openusage. Best practices and example-driven guidance for building native macOS SwiftUI scenes and components, including windows, commands, toolbars, settings, split views, inspectors, menu bar extras, and keyboard-driven workflows. Use when creating or refactoring macOS SwiftUI UI, choosing scene types, wiring menus or settings, or needing desktop-specific component patterns and examples.

Its SKILL.md is about 3.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files, including reference files (for example `references/commands-menus.md`, `references/components-index.md` and `references/menu-bar-extra.md`).

It sits in Mobile, covering iOS development. It works with SwiftUI, macOS and Git. The repository describes itself as: Burning through your subscriptions too fast? Paying for stuff you never use? Stop guessing. OpenUsage is free and open source. The licence is MIT.

When your agent uses it

  • Refactoring macOS SwiftUI UI
  • Choosing scene types
  • Needing desktop-specific component patterns and examples

Example prompts

  • “/swiftui-patterns”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Choose the scene model.
  2. Choose state ownership: app-wide, scene-scoped, window-scoped, or view-local.
  3. Sketch file and module boundaries.
  4. Create the folder structure before filling in the UI.
  5. Keep script/build_and_run.sh separate from app source.

What it can do on your machine

Read from SKILL.md and the folder at commit cb21465. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Swiftui Patterns loads about 3.4k tokens when it runs, and up to ~5.9k if it reads all its reference files. Until then it costs about 100 tokens; SKILL.md has 1,613 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~100
When it runs · the whole SKILL.md, loaded when a task matches
~3.4k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~5.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from robinebers/openusage at commit cb21465, republished under its MIT licence (© robinebers). 1,613 words, ~3,425 tokens.

Download SKILL.mdSave it as .claude/skills/swiftui-patterns/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
swiftui-patterns
description
Best practices and example-driven guidance for building native macOS SwiftUI scenes and components, including windows, commands, toolbars, settings, split views, inspectors, menu bar extras, and keyboard-driven workflows. Use when creating or refactoring macOS SwiftUI UI, choosing scene types, wiring menus or settings, or needing desktop-specific component patterns and examples.

SwiftUI Patterns

Quick Start

Choose a track based on your goal:

Existing project
  • Identify the feature or scene and the primary interaction model: document, editor, sidebar-detail, utility window, settings, or menu bar extra.
  • Read the nearest existing scene or root view before inventing a new desktop structure.
  • Choose the relevant reference from references/components-index.md.
  • If SwiftUI cannot express the required platform behavior cleanly, use the appkit-interop skill rather than forcing a shaky workaround.
New app scaffolding
  • Choose the scene model first: WindowGroup, Window, Settings, MenuBarExtra, or DocumentGroup.
  • If the app combines a normal main window and a MenuBarExtra, use WindowGroup(..., id:) for the primary window when it should appear at launch. Treat Window(...) as a better fit for auxiliary/on-demand singleton windows; in menu-bar-heavy apps, a Window(...) scene may not present the main window automatically at launch.
  • Before creating the scaffold, check whether the workspace is already inside a git repo with git rev-parse --is-inside-work-tree. If not, run git init at the project root so git-backed editor features unlock from the start. Do not initialize a nested repo inside an existing parent checkout.
  • For a new app scaffold, also create one project-local script/build_and_run.sh so the app has a single kill + build + run entrypoint from the start. Use the exact bootstrap contract from build-run-debug and its references/build-script.md file rather than inventing a second variant here.
  • Decide which state is app-wide, scene-scoped, or window-scoped before writing views.
  • Sketch file and module boundaries before writing the full UI. For any non-trivial app, create the folder structure first and split files by responsibility from the start.
  • Use a single Swift file only for tiny throwaway examples or snippets: roughly under 50 lines, one screen, no persistence, no networking/process client, and no reusable models. Anything beyond that should be multi-file immediately.
  • Use system-adaptive colors and materials by default (Color.primary, Color.secondary, semantic foreground styles, .regularMaterial, etc.) so the app follows Light/Dark mode automatically. Do not hardcode white or light backgrounds unless the user explicitly asks for a fixed theme, and do not reach for opaque windowBackgroundColor fills for root panes by default.
  • Pick the references for the first feature surface you need: windowing, commands, split layouts, or settings.

New App File Structure

For any non-trivial macOS app, start with this shape instead of putting the app, all views, models, stores, services, and helpers in one Swift file:

  • App/<AppName>App.swift: the @main app type and AppDelegate only.
  • Views/ContentView.swift: root layout and high-level composition only.
  • Views/SidebarView.swift, Views/DetailView.swift, Views/ComposerView.swift, etc.: feature views named after their primary type.
  • Models/*.swift: value models, identifiers, and selection enums.
  • Stores/*.swift: persistence and state stores.
  • Services/*.swift: app-server, network, process, or platform clients.
  • Support/*.swift: small formatters, resolvers, extensions, and glue helpers.

Keep files small and named after the primary type they contain. If a file starts collecting unrelated views, models, stores, networking clients, and helper extensions, split it before adding more behavior.

Pre-Edit Checklist For New App Scaffolds

Before writing the full UI:

  1. Choose the scene model.
  2. Choose state ownership: app-wide, scene-scoped, window-scoped, or view-local.
  3. Sketch file and module boundaries.
  4. Create the folder structure before filling in the UI.
  5. Keep script/build_and_run.sh separate from app source.

General Rules To Follow

  • Design for pointer, keyboard, menus, and multiple windows.
  • Keep scenes explicit. A separate settings window, utility window, or menu bar extra should be modeled as its own scene, not hidden inside one monolithic ContentView.
  • Prefer system desktop affordances: commands, toolbars, sidebars, inspectors, contextual menus, and searchable.
  • For menu bar apps, keep MenuBarExtra item titles and action labels short and scannable. Cap visible menu item text at 30 characters; if source content is longer, truncate or summarize it before rendering and open the full content in a dedicated window or detail surface.
  • If a MenuBarExtra app should still behave like a regular Dock app with a visible main window/process, install an NSApplicationDelegate via @NSApplicationDelegateAdaptor, call NSApp.setActivationPolicy(.regular) during launch, and activate the app with NSApp.activate(ignoringOtherApps: true). If the app is intentionally menu-bar-only, document that .accessory / no-Dock behavior is a deliberate product choice.
  • Prefer system-adaptive colors, materials, and semantic foreground styles. Avoid fixed white/light backgrounds in scaffolding and examples unless the requested design explicitly calls for a custom non-adaptive theme.
  • Do not paint NavigationSplitView sidebars or root window panes with opaque custom Color(...) or Color(nsColor: .windowBackgroundColor) fills by default. Prefer native macOS sidebar/window materials and system-provided backgrounds unless the user explicitly asks for a custom opaque surface. In sidebar-detail-inspector layouts, let the sidebar keep the standard source-list/material appearance and reserve custom backgrounds for detail or inspector content cards where needed.
  • Use @SceneStorage for per-window ephemeral state and @AppStorage for durable user preferences.
  • Keep selection state explicit and stable. macOS layouts often pivot around sidebar selection rather than push navigation.
  • Prefer NavigationSplitView or a deliberate manual split layout over iOS-style stacked flows when the app benefits from always-visible structure.
  • For List(...).listStyle(.sidebar) and NavigationSplitView sidebars, prefer flat native rows with standard system selection/highlight behavior. Keep rows visually lightweight and Mail-like: at most one leading icon, one strong title line, and one optional secondary detail line in .secondary. Avoid stacked metadata rows, repeated inline utility icons, or dense multi-column status text in the sidebar. Reserve card-style and metadata-heavy surfaces for detail or inspector panes unless the user explicitly asks for a highly custom sidebar treatment.
  • Keep primary actions discoverable from both UI chrome and keyboard shortcuts when appropriate.
  • Use SwiftUI-native scenes and views first. If you need low-level window, responder-chain, text system, or panel control, switch to appkit-interop.

Prefer a native source-list row shape:

swift
List(selection: $selection) {
  ForEach(items) { item in
    HStack(spacing: 10) {
      Image(systemName: item.systemImage)
        .foregroundStyle(.secondary)
        .frame(width: 16)

      VStack(alignment: .leading, spacing: 2) {
        Text(item.title)
          .lineLimit(1)

        if let detail = item.detail {
          Text(detail)
            .font(.caption)
            .foregroundStyle(.secondary)
            .lineLimit(1)
        }
      }
    }
    .tag(item.id)
  }
}
.listStyle(.sidebar)

This keeps selection, highlight, spacing, and scanability aligned with standard macOS sidebars. Keep each row to one icon maximum and one or two text lines maximum, with the second line reserved for a short detail label. Use richer card treatments and denser metadata in the detail or inspector content, not in every sidebar row.

Show full SKILL.md (642 more words)Show less

Prefer letting the sidebar and split container use system backgrounds, while applying custom surfaces only to detail cards or inspector sections:

swift
NavigationSplitView {
  List(selection: $selection) {
    ForEach(items) { item in
      Label(item.title, systemImage: item.systemImage)
        .tag(item.id)
    }
  }
  .listStyle(.sidebar)
} detail: {
  ScrollView {
    VStack(alignment: .leading, spacing: 16) {
      DetailSummaryCard(item: selectedItem)
      DetailMetricsCard(item: selectedItem)
    }
    .padding()
  }
}

Avoid painting the sidebar and root split panes with opaque custom fills by default:

swift
NavigationSplitView {
  List(items) { item in
    SidebarCardRow(item: item)
  }
  .listStyle(.sidebar)
  .background(Color(nsColor: .windowBackgroundColor))
} detail: {
  DetailView(item: selectedItem)
    .background(Color(.white))
}

State Ownership Summary

Use the narrowest state tool that matches the ownership model:

ScenarioPreferred pattern
Local view or control state@State
Child mutates parent-owned value state@Binding
Root-owned reference model on macOS 14+@State with an @Observable type
Child reads or mutates an injected @Observable modelPass it explicitly as a stored property
Window-scoped ephemeral selection or expansion state@SceneStorage when practical, otherwise scene-owned @State
Shared user preference@AppStorage
Shared app service or configuration@Environment(Type.self)
Legacy reference model on older targets@StateObject at the owner and @ObservedObject when injected

Choose the ownership location first, then the wrapper. Do not turn simple desktop state into a view model by reflex.

Cross-Cutting References

  • references/components-index.md: entry point for scene and component guidance.
  • references/windowing.md: choosing between WindowGroup, Window, DocumentGroup, and window-opening patterns.
  • references/settings.md: dedicated settings scenes, SettingsLink, and preference layouts.
  • references/commands-menus.md: command menus, keyboard shortcuts, focused values, and desktop action routing.
  • references/split-inspectors.md: sidebars, split views, selection-driven layout, and inspectors.
  • references/menu-bar-extra.md: menu bar extra structure and when it fits.

Anti-Patterns

  • One huge ContentView pretending the whole app is a single screen.
  • A single Swift file containing the @main app, all views, models, stores, networking/process clients, formatters, and extensions. This is acceptable only for tiny throwaway snippets under the new-app threshold above.
  • Touch-first interaction models ported directly from iOS without desktop affordances.
  • Hiding core actions behind gestures with no menu, toolbar, or keyboard path.
  • Building a menu-bar-plus-window app around only a Window(...) scene and then expecting the main window to appear at launch. Use WindowGroup(..., id:) for the primary launch window and reserve Window(...) for auxiliary/on-demand windows.
  • Rendering full unbounded document titles, prompts, or message text directly inside a menu bar extra. Menu item labels should stay at or below 30 characters, with longer content moved into a dedicated window or detail view.
  • Treating settings as another navigation destination in the main content window.
  • Hardcoding .background(.white), Color.white, or a fixed light palette in a brand-new scaffold without an explicit design requirement.
  • Wrapping each sidebar item in large rounded custom cards inside a .sidebar list, which fights native source-list density, alignment, and selection behavior unless the user explicitly asked for a bespoke visual sidebar.
  • Building sidebar rows with multiple repeated icons, three or more text lines, or a dense strip of inline metadata counters/timestamps/models. Keep the sidebar row to one icon and one or two text lines, then move richer metadata into the detail pane.
  • Painting NavigationSplitView sidebars or root window panes with opaque custom color fills by default, instead of letting the sidebar use native source-list/material appearance and reserving custom backgrounds for actual content cards.
  • Using push navigation for layouts that want stable sidebar selection and detail panes.
  • Reaching for AppKit before the SwiftUI scene and command APIs have been used properly.

Workflow For A New macOS Scene Or View

  1. Define the scene type and ownership model before writing child views.
  2. Decide which actions live in content, toolbars, commands, inspectors, or settings.
  3. Sketch the selection model and layout: sidebar-detail, editor-inspector, document window, or utility window.
  4. Create the file/folder structure for app entrypoint, root layout, feature views, models, stores, services, and support helpers.
  5. Build with small, focused subviews and explicit inputs rather than giant computed fragments.
  6. Add keyboard shortcuts and menu or toolbar exposure for actions that matter on desktop.
  7. Validate the flow with a build and a quick usability pass: multiwindow assumptions, settings entry points, and selection stability.

Component References

Use references/components-index.md as the entry point. Each component reference should include:

  • intent and best-fit scenarios
  • minimal usage pattern with desktop conventions
  • pitfalls and discoverability notes
  • when to fall back to appkit-interop

© robinebers, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files (references) in .agents/skills/swiftui-patterns of robinebers/openusage.

  • SKILL.md
  • references/commands-menus.md
  • references/components-index.md
  • references/menu-bar-extra.md
  • references/settings.md
  • references/split-inspectors.md
  • references/windowing.md

Open the folder on GitHubat commit cb21465

Compare with similar skills

Swiftui Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Swiftui Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Swiftui Patterns this skillrobinebers/openusage4.3k—~3.4kAutomated safety check: PassMIT
macOS App Designvaayne/mori303—~789Automated safety check: PassMIT
Pulse Releasequnqin24/Pulse516—~1.3kAutomated safety check: PassApache-2.0
Swiftui Expert Skillomarshahine/HomeClaw1764 repos~2.8kAutomated safety check: PassMIT
Appkit Swiftui BridgeKartikLabhshetwar/better-shot2.4k2 repos~1.1kAutomated safety check: PassCustom licence
macOS Notch UIfayazara/Screendrop2.1k—~1.8kAutomated safety check: PassCC0-1.0

Similar skills

  • macOS App Design

    vaayne/mori

    A skill your agent uses when designing or building native macOS applications with SwiftUI or AppKit.

    303 GitHub stars~789 tokensUpdated 2 mo ago
    MobileAuto-check passed
  • Pulse Release

    qunqin24/Pulse

    Release a new Pulse version end to end — checks, bilingual CHANGELOG entry, VERSION, tag, the release workflow, syncing main, and the issue replies that go with it.

    516 GitHub stars~1.3k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Swiftui Expert Skill

    omarshahine/HomeClaw

    A skill your agent uses when writing, reviewing, or refactoring SwiftUI code for iOS or macOS, including state management, view composition, performance, Liquid Glass adoption, or Instruments .trace…

    176 GitHub starsUsed in 4 repos~2.8k tokens
    MobileAuto-check passed
  • Appkit Swiftui Bridge

    KartikLabhshetwar/better-shot

    Expert guidance for hybrid AppKit-SwiftUI development. An agent skill from KartikLabhshetwar/better-shot.

    2.4k GitHub starsUsed in 2 repos~1.1k tokens
    MobileAuto-check passed
  • macOS Notch UI

    fayazara/Screendrop

    Add a Dynamic Island-style notch UI to a macOS app. An agent skill from fayazara/Screendrop.

    2.1k GitHub stars~1.8k tokensUpdated 7 days ago
    MobileAuto-check passed
  • Hig Project Context

    raintree-technology/hig-doctor

    Create or update a shared Apple design context document that other HIG skills use to tailor guidance.

    143 GitHub starsUsed in 5 repos~1.2k tokens
    MobileAuto-check passed

More from robinebers/openusage

All 25 skills in this repo
  • macOS Telemetry

    robinebers/openusage

    Add and verify lightweight macOS runtime telemetry. An agent skill from robinebers/openusage.

    4.3k GitHub stars~934 tokensUpdated 2 days ago
    Auto-check passed
  • Release Swift

    robinebers/openusage

    Cut a release of OpenUsage (Swift menu-bar app): pick a version, generate a categorized changelog, tag from main, and publish the GitHub Release with notes.

    4.3k GitHub stars~1.6k tokensUpdated 2 days ago
    Auto-check passed
  • Telemetry

    robinebers/openusage

    Add lightweight runtime telemetry and debug instrumentation to macOS apps, then verify those events after building and running.

    4.3k GitHub stars~977 tokensUpdated 2 days ago
    Auto-check passed
  • Window Management

    robinebers/openusage

    Customize macOS 15+ SwiftUI windows and scene behavior using Window, WindowGroup, and macOS window modifiers.

    4.3k GitHub stars~2.6k tokensUpdated 2 days ago
    Auto-check passed
  • Appkit Interop

    robinebers/openusage

    Decide when and how to bridge a macOS app from SwiftUI into AppKit.

    4.3k GitHub stars~741 tokensUpdated 2 days ago
    Auto-check passed
  • Build Run Debug

    robinebers/openusage

    Build, run, and debug local macOS apps and desktop executables using shell-first Xcode and Swift workflows.

    4.3k GitHub stars~1.8k tokensUpdated 2 days ago
    Auto-check passed

Works with

Categories

Questions about Swiftui Patterns

What does Swiftui Patterns do?

Best practices and example-driven guidance for building native macOS SwiftUI scenes and components, including windows, commands, toolbars, settings, split views, inspectors, menu bar extras, and…. Swiftui Patterns is an agent skill from robinebers/openusage. Best practices and example-driven guidance for building native macOS SwiftUI scenes and components, including windows, commands, toolbars, settings, split views, inspectors, menu bar extras, and keyboard-driven workflows.

When should I use Swiftui Patterns?

Swiftui Patterns fits situations like: refactoring macOS SwiftUI UI; choosing scene types; needing desktop-specific component patterns and examples.

How do I install Swiftui Patterns in Claude Code?

Run `npx skills add robinebers/openusage --skill swiftui-patterns -a claude-code`. Or copy the skill folder (.agents/skills/swiftui-patterns in robinebers/openusage) into .claude/skills/swiftui-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Swiftui Patterns in Codex?

Run `npx skills add robinebers/openusage --skill swiftui-patterns -a codex`. Or copy the skill folder (.agents/skills/swiftui-patterns in robinebers/openusage) into .agents/skills/swiftui-patterns in your project. Codex loads it when a task matches its description.

Can I use Swiftui Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add robinebers/openusage --skill swiftui-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/swiftui-patterns, .gemini/skills/swiftui-patterns, .github/skills/swiftui-patterns and .opencode/skills/swiftui-patterns in your project.

What does Swiftui Patterns need to run?

Going by SKILL.md and its folder, Swiftui Patterns needs the command-line tools its instructions call (git).

Does Swiftui Patterns access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Swiftui Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Swiftui Patterns use?

Swiftui Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Swiftui Patterns use?

About 3.4k tokens (SKILL.md is roughly 14k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2.4k tokens, read only when the agent opens those files.

What are the alternatives to Swiftui Patterns?

Skills that share tags, products or a category with Swiftui Patterns: macOS App Design (vaayne/mori, 303 stars), Pulse Release (qunqin24/Pulse, 516 stars), Swiftui Expert Skill (omarshahine/HomeClaw, 176 stars) and Appkit Swiftui Bridge (KartikLabhshetwar/better-shot, 2.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Swiftui Patterns?

robinebers (a GitHub user) maintains it in robinebers/openusage, which has 4,333 GitHub stars. The repository holds 25 skills in this directory. The repository was last updated on October 6, 2026.

Source: robinebers/openusage on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.