Agent skill · software engineering · dpearson2699
swiftdata
Implement, review, or improve data persistence using SwiftData. Use when defining @Model classes with @Attribute, @Relationship, @Transient, #Unique, or #Index; when querying with @Query, #Predicate, FetchDescriptor, or SortDescriptor; when configuring ModelContainer and ModelContext for SwiftUI or background work with @ModelActor; when planning schema migrations with VersionedSchema and SchemaMigrationPlan; when setting up CloudKit sync with ModelConfiguration; or when coexisting with or migrating from Core Data.
Why this skill is useful
Adds executable scripts and detailed patterns for implementing data persistence with SwiftData that are not widely documented.
What it needs
Requires swift installed locally. About 7k tokens when loaded. Last updated 2026-07-31. 973 stars on the source repository.
What this skill does
SwiftData Persist, query, and manage structured data in iOS 26+ apps using SwiftData with Swift 6.3. Contents Model Definition ModelContainer Setup CloudKit Sync CRUD Operations @Query in SwiftUI #Predicate FetchDescriptor Schema Versioning and Migration Core Data Coexistence Boundary Concurrency (@ModelActor) SwiftUI Integration Common Mistakes Review Checklist References Model Definition Apply @Model to a class (not struct). It synthesizes PersistentModel conformance. Model instances remain context/actor-bound; pass their PersistentIdentifier, not the instance, across actors. @Attribute options: .externalStorage, .unique, .spotlight, .allowsCloudEncryption, .preserveValueOnDeletion, .ephemeral, .transformable(by:). Rename: @Attribute(originalName: "oldname"). @Relationship: deleteRule: .cascade/.nullify(default)/.deny/.noAction. Specify inverse: for reliable behavior. Unidirectional (iOS 18+): inverse: nil. #Unique (iOS 18+): #Unique<Person>([\.firstName, \.lastName]) -- compound uniqueness. Inheritance (iOS 26+): @Model class BusinessTrip: Trip { var company: String }. Supported types: Bool, Int/UInt variants, Float, Double, String, Date, Data, URL, UUID, Decimal, Array, Dictionary, Set, Codable enums, Codable structs and other compatible Codable value types, and relationships to @Model classes. ModelContainer Setup CloudKit Sync ModelConfiguration(..., cloudKitDatabase:) opts a SwiftData store into automatic CloudKit sync, but app entitlements still gate sync. For any SwiftData CloudKit setup or schema-review task, include a separate Capabilities verdict before schema findings: Capabilities: Xcode target has the iCloud capability with CloudKit enabled and the intended container selected, plus Background Modes > Remote notifications. Without these entitlements, automatic sync is not fully configured even if cloudKitDatabase is set. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills dpearson2699/swiftdata