swiftdata-expert-skill/SKILL.md
Expert guidance for designing, implementing, migrating, and debugging SwiftData persistence in Swift and SwiftUI apps. Use when working with @Model schemas, @Relationship/@Attribute rules, Query or FetchDescriptor data access, ModelContainer/ModelContext configuration, CloudKit sync, SchemaMigrationPlan/history APIs, ModelActor concurrency isolation, or Core Data to SwiftData adoption/coexistence.
npx skillsauth add abanoub-ashraf/manus-skills-import swiftdata-expert-skillInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill to build, review, and harden SwiftData persistence architecture with Apple-documented patterns from iOS 17 through current updates. Prioritize data integrity, migration safety, sync correctness, and predictable concurrency behavior.
#Index, #Unique, HistoryDescriptor, DataStore, inheritance examples).ModelContainer wiring before debugging data issues; without it, inserts fail and fetches are empty.SchemaMigrationPlan when needed.rg "modelContainer\\(|ModelContainer\\(" -nrg "^@Model|#Unique|#Index|@Relationship|@Attribute|@Transient" -nrg "modelContext|mainContext|ModelContext\\(" -nrg "SchemaMigrationPlan|VersionedSchema|MigrationStage|fetchHistory|deleteHistory|historyToken" -nrg "cloudKitDatabase|iCloud|CloudKit|groupContainer|AppGroup|NSPersistentCloudKitContainer" -n.modelContainer(...) modifier or manual ModelContainer(...).save() is required.isUndoEnabled) and whether operations occur on mainContext or custom contexts.automatic, .private(...), .none).references/modeling-and-schema.md.references/model-context-and-lifecycle.md.references/querying-and-fetching.md.references/relationships-and-inheritance.md.references/migrations-and-history.md.references/cloudkit-sync.md.references/core-data-adoption.md.references/concurrency-and-actors.md.references/troubleshooting-and-updates.md.references/implementation-playbooks.md..modelContainer(...) is attached at app or window root and the model type is included.@Attribute(.unique) or #Unique constraints and rely on insert-upsert behavior..cascade vs .nullify) and check for unbounded delete(model:where:).isUndoEnabled: true and that changes are saved via mainContext (not only background context).cloudKitDatabase if multiple containers exist.fetchHistory) with token + author filtering.historyTokenExpired appears:
FetchDescriptor settings.@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
.modelContainer(for: [Trip.self, Accommodation.self])
}
}
let config = ModelConfiguration(isStoredInMemoryOnly: false)
let container = try ModelContainer(
for: Trip.self,
Accommodation.self,
configurations: config
)
struct TripListView: View {
@Query private var trips: [Trip]
init(searchText: String) {
let predicate = #Predicate<Trip> {
searchText.isEmpty || $0.name.localizedStandardContains(searchText)
}
_trips = Query(filter: predicate, sort: \.startDate, order: .forward)
}
var body: some View { List(trips) { Text($0.name) } }
}
do {
try modelContext.delete(
model: Trip.self,
where: #Predicate { $0.endDate < .now },
includeSubclasses: true
)
try modelContext.save()
} catch {
// Handle delete and save failures.
}
references/modeling-and-schema.mdreferences/model-context-and-lifecycle.mdreferences/querying-and-fetching.mdreferences/relationships-and-inheritance.mdreferences/migrations-and-history.mdreferences/cloudkit-sync.mdreferences/core-data-adoption.mdreferences/concurrency-and-actors.mdreferences/troubleshooting-and-updates.mdreferences/implementation-playbooks.mdfetchLimit, offsets, identifier-only fetches) for scalability.ModelConfiguration for environment-specific behavior (in-memory tests, CloudKit, app groups, read-only stores).cascade, nullify, and others).development
Design principles for building polished, native-feeling SwiftUI apps and widgets. Use this skill when creating or modifying SwiftUI views, iOS widgets (WidgetKit), or any native Apple UI. Ensures proper spacing, typography, colors, and widget implementations that look and feel like quality apps rather than AI-generated slop.
data-ai
Design and implement SwiftUI views, components, and app architecture. Use when creating new SwiftUI views, implementing MVVM/TCA patterns, managing state with @Observable, @State, @Binding, or @Environment, designing navigation flows, or structuring iOS app architecture. Triggers on SwiftUI, view model, state management, navigation, coordinator pattern.
development
Implement, review, or improve SwiftUI animations and transitions. Use when adding implicit or explicit animations with withAnimation, configuring spring animations (.smooth, .snappy, .bouncy), building phase or keyframe animations with PhaseAnimator/KeyframeAnimator, creating hero transitions with matchedGeometryEffect or matchedTransitionSource, adding SF Symbol effects (bounce, pulse, variableColor, breathe, rotate, wiggle), implementing custom Transition or CustomAnimation types, or ensuring animations respect accessibilityReduceMotion.
testing
Audit SwiftUI views for accessibility (iOS + macOS) with patch-ready fixes