Agent skill

Swiftui UI Patterns

by Dimillian in Dimillian/Skills

Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids.

MITAuto-check passedMobile

Install Swiftui UI Patterns

skills CLI
$ npx skills add Dimillian/Skills --skill swiftui-ui-patterns -a claude-code

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

GitHub CLI
$ gh skill install Dimillian/Skills swiftui-ui-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/Dimillian/Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/swiftui-ui-patterns .claude/skills/swiftui-ui-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-ui-patterns
GitHub stars
4k
Used in
5 other repos
Token cost
~1.9k tokens
SKILL.md length
890 words
Files
32 (incl. references)
Skills in repo
12
Repo updated
First seen
Licence
MIT

At a glance

Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids.

  • Works in 6 steps: Define the view's state, ownership… → Identify which dependencies belong in… → Sketch the view hierarchy, routing… → …
  • Refactoring SwiftUI UI
  • SKILL.md covers Quick start, General rules to follow, State ownership summary and Cross-cutting references, plus 4 more sections
  • Calls rg

What it does

Swiftui UI Patterns is an agent skill from Dimillian/Skills. Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens with VStack/HStack, managing @State or @Binding, building declarative iOS interfaces, or needing component-specific patterns and examples.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 33 other files, including reference files (for example `agents/openai.yaml`, `references/app-wiring.md` and `references/async-state.md`).

It sits in Mobile, covering iOS development. It works with SwiftUI and iOS. The licence is MIT.

When your agent uses it

  • Refactoring SwiftUI UI
  • Designing tab architecture with TabView
  • Composing screens with VStack/HStack
  • Managing @State

Example prompts

  • “/swiftui-ui-patterns”

Workflow steps

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

  1. Define the view's state, ownership location, and minimum OS assumptions before writing UI code.
  2. Identify which dependencies belong in @Environment and which should stay as explicit initializer inputs.
  3. Sketch the view hierarchy, routing model, and presentation points; extract repeated parts into subviews. For complex navigation, read…
  4. Implement async loading with .task or .task(id:), plus explicit loading and error states when needed. Read references/async-state.md when…
  5. Add previews for the primary and secondary states, then add accessibility labels or identifiers when the UI is interactive. Read…
  6. Validate with a build: confirm no compiler errors, check that previews render without crashing, ensure state changes propagate correctly…

What it can do on your machine

Read from SKILL.md and the folder at commit 05ba982. 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:

    • rg

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

  • Network

    No URLs in SKILL.md.

    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 UI Patterns loads about 1.9k tokens when it runs, and up to ~21k if it reads all its reference files. Until then it costs about 113 tokens; SKILL.md has 890 words of instructions outside code blocks.

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

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 Dimillian/Skills at commit 05ba982, republished under its MIT licence (© Dimillian). 890 words, ~1,859 tokens.

Download SKILL.mdSave it as .claude/skills/swiftui-ui-patterns/SKILL.md (or your agent's skills folder). This skill also uses 31 other files; get the full folder from GitHub.
name
swiftui-ui-patterns
description
Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids. Use when creating or refactoring SwiftUI UI, designing tab architecture with TabView, composing screens with VStack/HStack, managing @State or @Binding, building declarative iOS interfaces, or needing component-specific patterns and examples.

SwiftUI UI Patterns

Quick start

Choose a track based on your goal:

Existing project
  • Identify the feature or screen and the primary interaction model (list, detail, editor, settings, tabbed).
  • Find a nearby example in the repo with rg "TabView\(" or similar, then read the closest SwiftUI view.
  • Apply local conventions: prefer SwiftUI-native state, keep state local when possible, and use environment injection for shared dependencies.
  • Choose the relevant component reference from references/components-index.md and follow its guidance.
  • If the interaction reveals secondary content by dragging or scrolling the primary content away, read references/scroll-reveal.md before implementing gestures manually.
  • Build the view with small, focused subviews and SwiftUI-native data flow.
New project scaffolding
  • Start with references/app-wiring.md to wire TabView + NavigationStack + sheets.
  • Add a minimal AppTab and RouterPath based on the provided skeletons.
  • Choose the next component reference based on the UI you need first (TabView, NavigationStack, Sheets).
  • Expand the route and sheet enums as new screens are added.

General rules to follow

  • Use modern SwiftUI state (@State, @Binding, @Observable, @Environment) and avoid unnecessary view models.
  • If the deployment target includes iOS 16 or earlier and cannot use the Observation API introduced in iOS 17, fall back to ObservableObject with @StateObject for root ownership, @ObservedObject for injected observation, and @EnvironmentObject only for truly shared app-level state.
  • Prefer composition; keep views small and focused.
  • Use async/await with .task and explicit loading/error states. For restart, cancellation, and debouncing guidance, read references/async-state.md.
  • Keep shared app services in @Environment, but prefer explicit initializer injection for feature-local dependencies and models. For root wiring patterns, read references/app-wiring.md.
  • Prefer the newest SwiftUI API that fits the deployment target and call out the minimum OS whenever a pattern depends on it.
  • Maintain existing legacy patterns only when editing legacy files.
  • Follow the project's formatter and style guide.
  • Sheets: Prefer .sheet(item:) over .sheet(isPresented:) when state represents a selected model. Avoid if let inside a sheet body. Sheets should own their actions and call dismiss() internally instead of forwarding onCancel/onConfirm closures.
  • Scroll-driven reveals: Prefer deriving a normalized progress value from scroll offset and driving the visual state from that single source of truth. Avoid parallel gesture state machines unless scroll alone cannot express the interaction.

State ownership summary

Use the narrowest state tool that matches the ownership model:

ScenarioPreferred pattern
Local UI state owned by one view@State
Child mutates parent-owned value state@Binding
Root-owned reference model on iOS 17+@State with an @Observable type
Child reads or mutates an injected @Observable model on iOS 17+Pass it explicitly as a stored property
Shared app service or configuration@Environment(Type.self)
Legacy reference model on iOS 16 and earlier@StateObject at the root, @ObservedObject when injected

Choose the ownership location first, then pick the wrapper. Do not introduce a reference model when plain value state is enough.

Cross-cutting references

  • references/navigationstack.md: navigation ownership, per-tab history, and enum routing.
  • references/sheets.md: centralized modal presentation and enum-driven sheets.
  • references/deeplinks.md: URL handling and routing external links into app destinations.
  • references/app-wiring.md: root dependency graph, environment usage, and app shell wiring.
  • references/async-state.md: .task, .task(id:), cancellation, debouncing, and async UI state.
  • references/previews.md: #Preview, fixtures, mock environments, and isolated preview setup.
  • references/performance.md: stable identity, observation scope, lazy containers, and render-cost guardrails.
Show full SKILL.md (363 more words)Show less

Anti-patterns

  • Giant views that mix layout, business logic, networking, routing, and formatting in one file.
  • Multiple boolean flags for mutually exclusive sheets, alerts, or navigation destinations.
  • Live service calls directly inside body-driven code paths instead of view lifecycle hooks or injected models/services.
  • Reaching for AnyView to work around type mismatches that should be solved with better composition.
  • Defaulting every shared dependency to @EnvironmentObject or a global router without a clear ownership reason.

Workflow for a new SwiftUI view

  1. Define the view's state, ownership location, and minimum OS assumptions before writing UI code.
  2. Identify which dependencies belong in @Environment and which should stay as explicit initializer inputs.
  3. Sketch the view hierarchy, routing model, and presentation points; extract repeated parts into subviews. For complex navigation, read references/navigationstack.md, references/sheets.md, or references/deeplinks.md. Build and verify no compiler errors before proceeding.
  4. Implement async loading with .task or .task(id:), plus explicit loading and error states when needed. Read references/async-state.md when the work depends on changing inputs or cancellation.
  5. Add previews for the primary and secondary states, then add accessibility labels or identifiers when the UI is interactive. Read references/previews.md when the view needs fixtures or injected mock dependencies.
  6. Validate with a build: confirm no compiler errors, check that previews render without crashing, ensure state changes propagate correctly, and sanity-check that list identity and observation scope will not cause avoidable re-renders. Read references/performance.md if the screen is large, scroll-heavy, or frequently updated. For common SwiftUI compilation errors — missing @State annotations, ambiguous ViewBuilder closures, or mismatched generic types — resolve them before updating callsites. If the build fails: read the error message carefully, fix the identified issue, then rebuild before proceeding to the next step. If a preview crashes, isolate the offending subview, confirm its state initialisation is valid, and re-run the preview before continuing.

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 local conventions.
  • Pitfalls and performance notes.
  • Paths to existing examples in the current repo.

Adding a new component reference

  • Create references/<component>.md.
  • Keep it short and actionable; link to concrete files in the current repo.
  • Update references/components-index.md with the new entry.

© Dimillian, 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 31 other files (references) in swiftui-ui-patterns of Dimillian/Skills.

  • SKILL.md
  • agents/openai.yaml
  • references/app-wiring.md
  • references/async-state.md
  • references/components-index.md
  • references/controls.md
  • references/deeplinks.md
  • references/focus.md
  • references/form.md
  • references/grids.md
  • references/haptics.md
  • references/input-toolbar.md
  • references/lightweight-clients.md
  • references/list.md
  • references/loading-placeholders.md
  • references/macos-settings.md
  • references/matched-transitions.md
  • references/media.md
  • references/menu-bar.md
  • … and 13 more

Open the folder on GitHubat commit 05ba982

Used in 5 other repositories

We found 15 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 5 other GitHub owners. This page covers the copy in Dimillian/Skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Swiftui UI 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 UI Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Swiftui UI Patterns this skillDimillian/Skills4k5 repos~1.9kAutomated safety check: PassMIT
Swiftui Expert SkillAvdLee/SwiftUI-Agent-Skill3.7k—~2.9kAutomated safety check: PassMIT
Swiftui Expert SkillEslzzyl/Pixiv-SwiftUI1115 repos~3.1kAutomated safety check: PassAGPL-3.0
Swiftui Liquid Glassharperreed/dotfiles3348 repos~941Automated safety check: PassNone
Update Swiftui APIsAvdLee/SwiftUI-Agent-Skill3.7k—~1.2kAutomated safety check: PassMIT
Hig Project Contextraintree-technology/hig-doctor1425 repos~1.2kAutomated safety check: PassMIT

Similar skills

  • Swiftui Expert Skill

    AvdLee/SwiftUI-Agent-Skill

    A skill your agent uses when writing, reviewing, or refactoring SwiftUI code for iOS or macOS, including state and @Observable data flow, view composition, resizable layouts, safe areas, display…

    3.7k GitHub stars~2.9k tokensUpdated yesterday
    MobileAuto-check passed
  • Swiftui Expert Skill

    Eslzzyl/Pixiv-SwiftUI

    A skill your agent uses when writing, reviewing, or refactoring SwiftUI code for iOS or macOS, including state management and @Observable data flow, view composition and invalidation/performance…

    111 GitHub starsUsed in 5 repos~3.1k tokens
    MobileAuto-check passed
  • Swiftui Liquid Glass

    harperreed/dotfiles

    Implement, review, or improve SwiftUI features using the iOS 26+ Liquid Glass API.

    334 GitHub starsUsed in 8 repos~941 tokens
    MobileAuto-check passed
  • Update Swiftui APIs

    AvdLee/SwiftUI-Agent-Skill

    Scan Apple's SwiftUI documentation for deprecated APIs and update the SwiftUI Expert Skill with modern replacements.

    3.7k GitHub stars~1.2k tokensUpdated yesterday
    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.

    142 GitHub starsUsed in 5 repos~1.2k tokens
    MobileAuto-check passed
  • Liquid Glass Design

    AstraFoundry/KumoApp

    iOS 26 Liquid Glass design system — dynamic glass material with blur, reflection, and interactive morphing for SwiftUI, UIKit, and WidgetKit.

    290 GitHub starsUsed in 5 repos~2.3k tokens
    MobileAuto-check passed

More from Dimillian/Skills

All 12 skills in this repo
  • macOS Spm App Packaging

    Dimillian/Skills

    Scaffold, build, and package SwiftPM-based macOS apps without an Xcode project.

    4k GitHub starsUsed in 5 repos~1.2k tokens
    Auto-check passed
  • Analyze and optimize React component performance issues (slow renders, re-render thrash, laggy lists, expensive computations).

    4k GitHub starsUsed in 5 repos~1.2k tokens
    Auto-check passed
  • Swiftui View Refactor

    Dimillian/Skills

    Refactor and review SwiftUI view files with strong defaults for small dedicated subviews, MV-over-MVVM data flow, stable view trees, explicit dependency injection, and correct Observation usage.

    4k GitHub starsUsed in 5 repos~2k tokens
    Auto-check passed
  • Swift Concurrency Expert

    Dimillian/Skills

    Swift Concurrency review and remediation for Swift 6.2+. An agent skill from Dimillian/Skills.

    4k GitHub stars~1.1k tokensUpdated 6 mo ago
    Auto-check passed
  • GitHub

    Dimillian/Skills

    Interact with GitHub using the gh CLI. An agent skill from Dimillian/Skills.

    4k GitHub stars~480 tokensUpdated 6 mo ago
    Auto-check passed
  • macOS Menubar Tuist App

    Dimillian/Skills

    Build, refactor, or review macOS menubar apps that use Tuist and SwiftUI.

    4k GitHub stars~1.1k tokensUpdated 6 mo ago
    Auto-check passed

Works with

Categories

Questions about Swiftui UI Patterns

What does Swiftui UI Patterns do?

Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids. Swiftui UI Patterns is an agent skill from Dimillian/Skills. Best practices and example-driven guidance for building SwiftUI views and components, including navigation hierarchies, custom view modifiers, and responsive layouts with stacks and grids.

When should I use Swiftui UI Patterns?

Swiftui UI Patterns fits situations like: refactoring SwiftUI UI; designing tab architecture with TabView; composing screens with VStack/HStack; managing @State.

How do I install Swiftui UI Patterns in Claude Code?

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

How do I install Swiftui UI Patterns in Codex?

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

Can I use Swiftui UI 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 Dimillian/Skills --skill swiftui-ui-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-ui-patterns, .gemini/skills/swiftui-ui-patterns, .github/skills/swiftui-ui-patterns and .opencode/skills/swiftui-ui-patterns in your project.

What does Swiftui UI Patterns need to run?

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

Does Swiftui UI Patterns access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Swiftui UI 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 UI Patterns use?

Swiftui UI 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 UI Patterns use?

About 1.9k tokens (SKILL.md is roughly 7.4k 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 19k tokens, read only when the agent opens those files.

What are the alternatives to Swiftui UI Patterns?

Skills that share tags, products or a category with Swiftui UI Patterns: Swiftui Expert Skill (AvdLee/SwiftUI-Agent-Skill, 3.7k stars), Swiftui Expert Skill (Eslzzyl/Pixiv-SwiftUI, 111 stars), Swiftui Liquid Glass (harperreed/dotfiles, 334 stars) and Update Swiftui APIs (AvdLee/SwiftUI-Agent-Skill, 3.7k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Swiftui UI Patterns?

Dimillian (a GitHub user) maintains it in Dimillian/Skills, which has 3,984 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on March 29, 2026.

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