/apple-dev:swiftui-doctrinefrom apple-dev
Apply modern SwiftUI conventions on Apple platforms (iOS, iPadOS, macOS, visionOS). Triggers on SwiftUI views, `@Observable` services, `NavigationStack`, Swift `async/await`, and Apple-platform project work. Enforces no-ViewModel, modular SwiftPM.
Ships in apple-dev. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The always-on baseline for writing or reviewing SwiftUI on iOS 17+, iPadOS, macOS, and visionOS. Use it as the default lens whenever Swift, SwiftUI, or Apple-platform code appears in scope.
Any task that creates, edits, or reviews SwiftUI views, @Observable services, navigation stacks, Swift Concurrency, or Apple-platform project structure. If the task is a specific recipe (push notifications, Liquid Glass, etc.), pivot to the matching sibling skill listed at the bottom; the doctrine still applies as the baseline.
View struct is already the binding between state and UI; an extra *ViewModel layer fights the framework and creates a second source of truth.@Observable, not ObservableObject. Swift Observation is the default for shared state on iOS 17+. ObservableObject and @Published are legacy Combine-era and out of new code.@Observable inside @Observable. Nesting breaks observation tracking. Initialize services at the scene or view level and inject them as siblings via .environment(...).enum ViewState { case loading, loaded(T), error(Error) } and switch on it. The Bool isLoading + [T] items + Error? error triple is a special-case trap.@Binding only for parent-child two-way flow, to @Observable only when several unrelated views share the same source of truth.async/await, not Combine. Structured concurrency is the default for one-shot calls and AsyncStream for reactive flows. Do not bridge async to Combine. Do not invent @Published pipelines..task, not .onAppear. .task is lifecycle-aware: it starts on appear, cancels on disappear, and re-runs on id change. .onAppear { Task { ... } } is a fire-and-forget callback with no cancellation story.Packages/ directory split by domain: Models, Network, Env (or AppState), DesignSystem, and one package per feature. UI packages depend on logic packages, never the reverse.@Test and #expect. Use ViewInspector when a Preview is not enough. Test @Observable services directly. Every view ships at least one #Preview.switch case grows past a few lines, extract a focused subview, a ViewModifier, or a ButtonStyle.@Environment; no service locator, no DI container, no .shared singletons.The highest-signal failure modes. If you see one of these symptoms, jump to the cause.
@Observable service mutates. Cause: the service is stored as a property of another @Observable. Fix: hoist to the scene and inject siblings via .environment(_:)..onAppear { Task { ... } } is fire-and-forget. Fix: use .task (or .task(id:) for input-driven reloads); both cancel on disappear.Bool isLoading + [T] items + Error? error trio with no enforced exclusivity. Fix: model as enum ViewState { case loading, loaded(T), error(Error) } and switch in body.xcodebuild after every non-trivial edit; treat the build as the first quality gate.View's body), creating sibling instances. Fix: own the service with @State at the scene exactly once.*ViewModel class added to a new feature).ObservableObject and @Published in new code.@StateObject, @ObservedObject, @EnvironmentObject in new code (use @State plus @Environment with @Observable).async/await and AsyncStream).references/state-and-async-patterns.md: worked examples for @Observable injection, the view-state enum, .task(id:), and AsyncStream-driven reactive state.references/anti-patterns.md: the full ban list with one-line rationale for each.references/claude-md-template.md: a copy-pasteable project CLAUDE.md that encodes the doctrine, with placeholders for build commands and optional sections.The doctrine is the baseline. For these specific tasks, also use the matching sibling skill (it builds on top of the rules above, does not replace them):
foundation-models-integration.add-approuter.refactor-to-no-viewmodel.modular-package-skeleton.ios26-liquid-glass-adoption.swiftui-push-proxy.xcodebuildmcp-build-loop.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub joaquincampo/my-plugins --plugin apple-dev8 skills in this plugin
/add-approuterAdopt AppRouter (github.com/dimillian/AppRouter) for type-safe SwiftUI navigation with sheets and deep linking. Use when starting an app's nav layer or replacing ad-hoc `NavigationStack` path management. SimpleRouter or tab Router./foundation-models-integrationAdd Apple's on-device Foundation Models (Apple Intelligence) to a SwiftUI app: streaming, `@Generable` structured output, `Tool` protocol, availability checks. iOS / iPadOS / macOS / visionOS 26+. Triggers on `SystemLanguageModel`, `LanguageModelSession`, `@Generable`./ios26-liquid-glass-adoptionAdopt iOS 26 / iPadOS 26 / macOS 26 SwiftUI APIs: Liquid Glass, modernized toolbars and tab bars, matched transitions, scroll position. Triggers: `glassEffect`, `buttonStyle(.glass)`, `ToolbarSpacer`, `matchedTransitionSource`, `tabBarMinimizeBehavior`./modular-package-skeletonScaffold a new iOS, iPadOS, macOS, or visionOS app with the canonical modular SwiftPM layout (Models, Network, Env, DesignSystem, per-feature UI packages). Use when starting a new SwiftUI app or restructuring a monolithic Xcode project into Swift Packages./refactor-to-no-viewmodelMigrate legacy SwiftUI code from ObservableObject + @Published + ViewModel patterns to @Observable + @Environment + view-state enums. Use when modernizing an iOS or macOS codebase, removing ViewModel layers, or replacing Combine with async/await./swiftui-push-proxyBuild E2E-encrypted iOS push for services that speak Web Push (not APNS-native): relay proxy + RFC 8291 aesgcm decryption on device, keys in shared keychain. Triggers on Web Push, APNS, RFC 8291, `UNNotificationServiceExtension`, federated push.