{"enrichment":{"faq":[{"a":"core-data-expert recommends using NSManagedObjectContext with the correct concurrency type (privateQueue or mainQueue) and never accessing managed objects across threads without proper context confinement. For Swift Concurrency, wrap Core Data operations in context.perform or use @MainActor for main-thread contexts. Always fetch objects on the same context where you'll use them, and use objectID for cross-context references instead of passing NSManagedObject instances directly.","q":"How do I fix Core Data threading crash issues?"},{"a":"core-data-expert's recommended setup uses NSPersistentContainer, which handles the coordinator and store automatically. Create it once at app launch, typically in your app delegate or a singleton. For CloudKit sync, use NSPersistentCloudKitContainer instead. Always initialize on the main thread, then perform background operations via newBackgroundContext(). This pattern ensures thread safety and proper resource management from the start.","q":"What is the correct Core Data stack setup for iOS?"},{"a":"core-data-expert advises wrapping all Core Data work in context.perform(schedule:_:) or context.performAndWait(_:) blocks, marking main-thread contexts with @MainActor. For async/await, use context.perform { @MainActor in ... } or create a background context and call its perform method. Ensure NSManagedObject subclasses conform to Sendable where needed, and never pass managed objects between isolation domains\u2014use objectID instead.","q":"How do I use Core Data with Swift Concurrency?"},{"a":"core-data-expert identifies the root cause: batch operations (NSBatchUpdateRequest, NSBatchDeleteRequest) bypass in-memory contexts, so NSFetchedResultsController and observers don't see changes. After a batch operation, either refresh the context with refreshAllObjects() or use persistent history tracking to merge changes back. For production apps, enable NSPersistentHistoryTrackingRequest and process history tokens to keep UI in sync.","q":"What causes Core Data batch operations to not update the UI?"},{"a":"core-data-expert recommends starting with lightweight migration (automatic schema mapping) by creating a new model version in Xcode and letting Core Data infer changes. For complex migrations, use staged migration or custom mapping models. Always increment the model version number and set the current version in the data model inspector. Test migrations on real device data; use persistent store coordinator options to enable automatic migration during container initialization.","q":"How do I set up Core Data migration and resolve versioning errors?"},{"a":"core-data-expert advises replacing NSPersistentContainer with NSPersistentCloudKitContainer and enabling CloudKit capability in Xcode. Set a container identifier matching your iCloud container. Core Data handles sync automatically, but monitor CKQueryOperationMaximumResults and use persistent history tracking for conflict resolution. Test with CloudKit dashboard, handle network errors gracefully, and remember that CloudKit sync requires a valid iCloud account on device.","q":"How do I integrate CloudKit sync with NSPersistentCloudKitContainer?"}],"shadow_tags":["ios-database","concurrency-patterns","data-persistence","cloudkit-sync","migration-strategy","thread-safety","performance-tuning","conflict-resolution","batch-processing","schema-management"],"summary_rewrite":"core-data-expert equips AI coding assistants with battle-tested Core Data patterns drawn from production WeTransfer apps and WWDC best practices. Navigate threading pitfalls, optimize query performance, and handle schema migrations with confidence\u2014all through concise, agent-ready references designed for immediate triage and safe defaults."},"files":[{"bytes":4894,"path":"core-data-expert/SKILL.md","sha256":"74cac8c2a86868a30d41769529ab45124098d89cebd65c2fa310dd52a5ff1b7e","url":"https://skillfed.io/files/AvdLee/Core-Data-Agent-Skill/core-data-expert/4a93c980/SKILL.md"}],"id":"AvdLee/Core-Data-Agent-Skill/core-data-expert","links":{"html":"https://skillfed.io/AvdLee/Core-Data-Agent-Skill/core-data-expert","md":"https://skillfed.io/AvdLee/Core-Data-Agent-Skill/core-data-expert.md","repo":"https://github.com/AvdLee/Core-Data-Agent-Skill"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":15,"language":null,"last_updated":"2026-03-02","license":"MIT","name":"core-data-expert","publisher":"AvdLee","stars":288},"relations":{"similar":[{"id":"dpearson2699/swift-ios-skills/core-data"},{"id":"AvdLee/Swift-Concurrency-Agent-Skill/swift-concurrency"},{"id":"existential-birds/beagle/swift-code-review"},{"id":"rshankras/claude-code-apple-skills/persistence-setup"},{"id":"dpearson2699/swift-ios-skills/swiftdata"},{"id":"dpearson2699/swift-ios-skills/tipkit"},{"id":"CharlesWiltgen/Axiom/axiom-concurrency"},{"id":"kellyvv/PhoneClaw/mlx-swift"},{"id":"sammcj/agentic-coding/swift-development"},{"id":"teeverc/effect-ts/effect-v4"}]},"slug":{"owner":"AvdLee","repo":"Core-Data-Agent-Skill","skill":"core-data-expert"},"version":"4a93c980"}
