agentleFS
fal3fal3/claude-skills-collection/skills/swiftui-programming-skill/SKILL.md

SwiftUI Programming Skill

Skill18 starsChanged 56 days agoMITView on GitHub

Use when work involves SwiftUI view composition, state and Observation ownership, navigation, adaptive layout, toolbars, forms, SF Symbols, accessibility, previews, or SwiftUI-specific performance. Do not use for UIKit/AppKit-only work, general Swift language questions, or architecture and performance work that does not involve SwiftUI.

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. About 0 are common, 10 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add accessibility and Dynamic Type while composing the view.

    line 29
  2. Very specific:

    Use @State for view-owned value state.

    line 35
  3. Very specific:

    Use @Environment for dependencies intentionally shared through a subtree.

    line 38
  4. Very specific:

    Keep UI-observed mutable models on @MainActor unless their isolation is deliberately designed otherwise.

    line 39
  5. Distinctive:

    Do not copy derived state into another mutable property.

    line 40
  6. Very specific:

    Prefer flexible frames, stacks, grids, ViewThatFits, and size classes.

    line 67
  7. Distinctive:

    Use semantic colors and text styles.

    line 69
  8. Distinctive:

    Treat iPad multitasking, macOS window resizing, tvOS focus, watchOS glanceability, and visionOS volumes as distinct capabilities.

    line 70
  9. Very specific:

    Prefer NavigationStack at its supported minimum.

    line 75
  10. Distinctive:

    Keep destination construction consistent: every destination receives the selected value it requires.

    line 76
  11. Very specific:

    Use semantic toolbar placements such as .primaryAction, .confirmationAction, and .cancellationAction where they express intent across …

    line 77
  12. Distinctive:

    Do not use iOS-only placements or modifiers in an ungated all-platform view.

    line 78
  13. Very specific:

    Prefer Button, Toggle, TextField, Label, and other semantic controls.

    line 84
  14. Distinctive:

    Keep separate interactive controls as separate accessibility elements.

    line 86
  15. Very specific:

    Use semantic fonts (.body, .headline) or @ScaledMetric.

    line 87
  16. Very specific:

    Use SwiftUI's .equatable() or EquatableView only after measurement and only when equality fully represents visible output.

    line 96
  17. Distinctive:

    Verify each symbol exists for the deployment target and choose a fallback for newer symbols.

    line 101
  18. Distinctive:

    Use rendering modes and symbol effects only at their documented availability.

    line 102
  19. Distinctive:

    When a requested example spans architecture, accessibility, performance, or platform-specific behavior, keep this skill focused on the …

    line 111

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SwiftUI Programming Skill

Build SwiftUI interfaces that are correct for the user's declared platforms and deployment targets. Ask for those targets when an API choice depends on them; never assume the newest SDK is deployable.

Supported baseline

The primary examples use Xcode 15, Swift 5.9, and iOS/iPadOS 17 or macOS 14. SwiftUI itself supports older systems, but newer APIs need explicit availability handling:

NeedPreferred APIMinimumCompatibility path
Stack navigationNavigationStackiOS 16, macOS 13, tvOS 16, watchOS 9NavigationView remains valid for earlier targets
Observation@ObservableiOS 17, macOS 14, tvOS 17, watchOS 10ObservableObject and @StateObject remain supported
Toolbars.toolbariOS 14, macOS 11, tvOS 14, watchOS 7Put controls in the view hierarchy on earlier targets
Modern change handlingzero- or two-parameter onChangeiOS 17, macOS 14, tvOS 17, watchOS 10Use the one-parameter overload on earlier targets

APIs from the OS 27 development cycle are beta material relative to the stable Xcode 26.6 toolchain. Discuss them only when explicitly requested, label them beta, and provide stable fallbacks plus #available gates.

Workflow

  1. Record Swift, Xcode, and every platform minimum.
  2. Choose semantic system controls before custom controls.
  3. Define state ownership and a stable identity model.
  4. Choose navigation and layout from capabilities, not device-name guesses.
  5. Add accessibility and Dynamic Type while composing the view.
  6. Compile at the oldest supported targets; test large accessibility sizes and relevant input methods.
  7. Profile before adding performance-specific wrappers or caches.

State and Observation

  • Use @State for view-owned value state.
  • For a view-owned @Observable reference, store it in @State so SwiftUI owns its lifetime.
  • Pass an injected observable model as a plain property when the view only reads it. Create @Bindable locally when the view needs bindings.
  • Use @Environment for dependencies intentionally shared through a subtree.
  • Keep UI-observed mutable models on @MainActor unless their isolation is deliberately designed otherwise.
  • Do not copy derived state into another mutable property. Prefer a computed property.
import Observation
import SwiftUI

@MainActor
@Observable
final class ProfileModel {
    var displayName = ""
}

struct ProfileEditor: View {
    @State private var model = ProfileModel()

    var body: some View {
        @Bindable var model = model
        TextField("Display name", text: $model.displayName)
    }
}

For iOS 16 and earlier, use ObservableObject with @StateObject for view ownership and @ObservedObject for injection. That is a compatibility decision, not an anti-pattern.

Composition and layout

  • Extract subviews around meaningful responsibility, reuse, or independent state—not to force a presumed redraw boundary.
  • Prefer flexible frames, stacks, grids, ViewThatFits, and size classes. Use GeometryReader only when the child genuinely needs the proposed size.
  • Respect safe areas unless the visual treatment deliberately extends under system UI.
  • Use semantic colors and text styles; avoid fixed text heights and one-line truncation for user content.
  • Treat iPad multitasking, macOS window resizing, tvOS focus, watchOS glanceability, and visionOS volumes as distinct capabilities.

Navigation and toolbars

  • Model destinations with stable, Hashable route data when navigation is state-driven.
  • Prefer NavigationStack at its supported minimum. Use NavigationSplitView for genuinely multi-column interfaces, with a compact fallback.
  • Keep destination construction consistent: every destination receives the selected value it requires.
  • Use semantic toolbar placements such as .primaryAction, .confirmationAction, and .cancellationAction where they express intent across platforms.
  • Do not use iOS-only placements or modifiers in an ungated all-platform view.

See the complete toolbar example and prompt scenarios.

Accessibility and Dynamic Type

  • Prefer Button, Toggle, TextField, Label, and other semantic controls.
  • Label icon-only controls with their purpose. Hints describe the result of an action, not the gesture.
  • Keep separate interactive controls as separate accessibility elements.
  • Use semantic fonts (.body, .headline) or @ScaledMetric; do not claim that a fixed .system(size:) font scales.
  • Preserve alternatives to color, adequate interactive sizes and spacing, Reduce Motion, and Differentiate Without Color.

Performance

  • First measure with Instruments on a release build and representative hardware.
  • Give collection elements stable IDs. Never use array offsets as identity for mutable collections.
  • List already creates rows lazily. Use ScrollView plus LazyVStack for layout/interaction behavior that List cannot provide, not as a blanket speed upgrade.
  • A parent body evaluation does not mean every descendant is redrawn on screen. Keep body inexpensive, but do not promise that extracting a view creates an independent render boundary.
  • Use SwiftUI's .equatable() or EquatableView only after measurement and only when equality fully represents visible output.
  • Cancel asynchronous work when its owning view disappears or its input changes. .task(id:) is usually the clearest view-lifetime tool.

SF Symbols

  • Verify each symbol exists for the deployment target and choose a fallback for newer symbols.
  • Use rendering modes and symbol effects only at their documented availability.
  • Give decorative symbols no separate accessibility focus; label icon-only controls at the control level.

Copy-ready examples

  • State-driven toggle
  • Navigation and semantic toolbar actions
  • Example prompts

When a requested example spans architecture, accessibility, performance, or platform-specific behavior, keep this skill focused on the SwiftUI layer and route the other concerns to their dedicated guidance.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.