/apple-dev:refactor-to-no-viewmodelfrom apple-dev
Migrate 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.
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.
A step-by-step plan for taking a SwiftUI codebase off MVVM and onto modern Observation. The goal is fewer files, fewer wrappers, and views that own their own local state.
Use this skill when you encounter any of the following in a SwiftUI project targeting iOS 17, iPadOS 17, macOS 14, or newer:
*ViewModel classes paired one-to-one with views.ObservableObject conformance with @Published properties.@StateObject, @ObservedObject, or @EnvironmentObject..environmentObject(...) at the root.If none of those appear, the code is already modern and this skill does not apply.
Views declare local state with @State, model the screen as a ViewState enum, switch on it in the body, and pull shared services from @Environment. Services are @Observable classes injected at the scene with .environment(service). Async work happens in .task and .task(id:), never in .onAppear.
@Observable to the class, drop ObservableObject conformance, remove every @Published. In consuming views, change @StateObject to @State and @EnvironmentObject to @Environment(Service.self). Plain let references inside child views need no wrapper at all.ViewState enum with @State. When the only consumer of a ViewModel is its paired view, inline the state machine. Replace @Published var isLoading, @Published var items, and @Published var error with a single enum ViewState { case loading, loaded(T), error(Error) } and one @State private var viewState: ViewState = .loading.@Observable class injected via .environment(...) at the scene and read via @Environment(Service.self). Do not invent a ViewModel as the middle layer.ObservableObject types to @Observable. Touch only the service file and the scene injection point.@Environment(Service.self). The compiler errors at the call sites are the worklist.*ViewModel, remove the file. Do not delete in step 1; the compiler will guide you in step 4.@Observable inside @Observable; SwiftUI's observation tracking breaks. Inject siblings at the scene instead.@State on a class needs @Observable on the class. @State on a struct works as-is.ObservableObject and @Observable on one type during migration; pick one and finish the file before moving on.async/await and AsyncStream; a half-migrated mix where @Published feeds an async function (or vice versa) is the worst of both worlds.references/before-after-snippets.md: three side-by-side migrations (view-local ViewModel, shared service, Combine pipeline) with abstract names and labeled before/after blocks.references/migration-order.md: a practical sequencing guide for a medium codebase: how to identify migration units, what order to convert them, how to keep the project compiling, how to verify each step.What SKILL.md sets; muted values are Claude Code's defaults
8 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`.Other plugins' skills for the same job
npx claudepluginhub joaquincampo/my-plugins --plugin apple-dev