.claude/skills/swiftdata-expert/SKILL.md
Expert guidance on SwiftData: @Model, ModelContainer, ModelContext, FetchDescriptor, relationships, @ModelActor concurrency, CloudKit sync, migrations (VersionedSchema, SchemaMigrationPlan), and caching strategies. Use when defining models, querying data, setting up persistence, debugging SwiftData issues, planning migrations, or reviewing SwiftData code.
npx skillsauth add adamayoung/popcorn swiftdata-expertInstall 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 for authoritative guidance on SwiftData (iOS 17+/macOS 14+). Covers model definition, container/context management, querying, relationships, concurrency with @ModelActor, CloudKit integration, schema migrations, and caching patterns. Assumes Swift 6.2 strict concurrency.
@Model on classes — never hand-write PersistentModel conformance.@ModelActor for background data access — never pass ModelContext across actor boundaries.PersistentIdentifier (not model instances) across actors — resolve on the target actor's context.cloudKitDatabase configuration before applying constraints — @Attribute(.unique) and .deny delete rules are forbidden with CloudKit.static let (not static var) for VersionedSchema and SchemaMigrationPlan protocol properties — the protocols require only { get }.VersionedSchema + SchemaMigrationPlan — user data must never be silently deleted.FetchDescriptor with #Predicate for all queries — never use raw NSPredicate or string-based predicates.@Attribute(.externalStorage) for large binary data — never store images or files inline in SQLite.docs/SWIFTDATA.md for project-specific patterns before writing any SwiftData code.models.md + attributes.mdquerying.mdrelationships.mdconcurrency.mdmigrations.mdcloudkit.mdcontainers.mdModelContext passed across actors -> use @ModelActor with its own context.@Attribute(.unique) on a CloudKit model -> remove it; CloudKit cannot enforce uniqueness.static var on VersionedSchema triggers concurrency warning -> change to static let.nonisolated(unsafe) on schema properties -> unnecessary, use static let instead.-wal and -shm files after database deletion -> clean up all three SQLite files.@Transient property without default value -> must provide default (SwiftData needs it for fetch materialisation).@Attribute(originalName:) after rename -> data will be lost; use originalName for lightweight migration.@Model is applied to all persistence classes.@Attribute(.unique), no .deny delete rules, and all-optional relationships.cloudKitDatabase: .none in ModelConfiguration.@ModelActor is used for all background data access (not raw ModelContext).VersionedSchema and SchemaMigrationPlan use static let (not static var).ModelContainerFactory.makeLocalModelContainer (delete-and-recreate).ModelContainerFactory.makeCloudKitModelContainer with a migration plan.@Transient non-optional properties have default values.FetchDescriptor uses typed #Predicate (not string-based predicates).references/_index.md — navigation index with quick links by problemreferences/models.md — @Model, property types, @Transient, PersistentModelreferences/attributes.md — @Attribute options (.unique, .externalStorage, .transformable, originalName)references/relationships.md — @Relationship, delete rules, inverse relationships, cardinalityreferences/querying.md — FetchDescriptor, #Predicate, SortDescriptor, @Query, batch operationsreferences/containers.md — ModelContainer, ModelConfiguration, ModelContext, container factory patternsreferences/concurrency.md — @ModelActor, PersistentIdentifier, thread safety, Swift 6references/cloudkit.md — CloudKit sync, constraints, schema limitations, configurationreferences/migrations.md — VersionedSchema, SchemaMigrationPlan, MigrationStage, lightweight vs customdata-ai
Add properties to an existing domain model from TMDb
testing
Run all unit tests
testing
Run UI tests
testing
Run snapshot tests