From swiftui
Guides SwiftUI state management with rules for @Observable classes, local state, bindings, and SwiftData constraints.
How this command is triggered — by the user, by Claude, or both
Slash command
/swiftui:dataswiftui-review/references/The summary Claude sees in its command listing — used to decide when to auto-load this command
# Data flow, shared state, and property wrappers It is important that SwiftUI body code and logic code be kept separate in order to make code easier to read, write, and maintain. That usually means placing code into methods rather than inline in the `body` property, but often also means carving functionality out into separate `@Observable` classes. These rules help ensure code is efficient and works well in the long term. ## Shared state - `@Observable` classes must be marked `@MainActor` unless the project has Main Actor default actor isolation. Flag any `@Observable` class missing th...
It is important that SwiftUI body code and logic code be kept separate in order to make code easier to read, write, and maintain. That usually means placing code into methods rather than inline in the body property, but often also means carving functionality out into separate @Observable classes.
These rules help ensure code is efficient and works well in the long term.
@Observable classes must be marked @MainActor unless the project has Main Actor default actor isolation. Flag any @Observable class missing this annotation.@Observable classes with @State (for ownership) and @Bindable / @Environment (for passing).ObservableObject, @Published, @StateObject, @ObservedObject, or @EnvironmentObject unless they are unavoidable, or if they exist in legacy/integration contexts when changing architecture would be complicated.@State should be marked private and only owned by the view that created it.CIContext, it can be stored using @State even though it is not an observable object. This effectively uses @State as a cache – storing something persistently, but not doing any change tracking on it since it's not an observable object.Binding(get:set:) in view body code. It is much cleaner and simpler to use a binding provided by @State, @Binding or similar, then use onChange() to trigger any effects.TextField, bind the TextField to a numeric value such as Int or Double, then use its format initializer like this: TextField("Enter your score", value: $score, format: .number). Apply either .keyboardType(.numberPad) (for integers) or .keyboardType(.decimalPad) (for floating-point numbers) as appropriate. Using the modifier alone is not sufficient.Identifiable rather than using id: \.someProperty in SwiftUI code.@AppStorage inside an @Observable class, even if marked @ObservationIgnored – it will not trigger view updates when a change happens.@Attribute(.unique).5plugins reuse this command
First indexed Mar 13, 2026
npx claudepluginhub rootial/dotclaude --plugin swiftui/dataGuides SwiftUI state management with rules for @Observable classes, local state, bindings, and SwiftData constraints.
/create-viewGenerates a SwiftUI view with proper MVVM architecture, state management, accessibility, dark mode, and preview configurations.
/convertConverts a Claude-generated HTML design into a SwiftUI View file in the active Xcode workspace, with visual diff iteration.
/add-viewmodelCreates an Android ViewModel with sealed UI state, StateFlow, Hilt injection, and coroutine-based data loading for proper state management.
/dataGenerates domain-specific example datasets and uploads them to a Weaviate collection. Supports academic, finance, ecommerce, medical, and customer_support domains.
/dataProcesses and transforms data using jq, pandas, or SQL based on a natural language task description and optional tool specification.