core-data-expert
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—all through concise, agent-ready references designed for immediate triage and safe defaults.
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.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-03-02
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.
Use it when
- core-data-expert's recommended setup uses NSPersistentContainer, which handles the coordinator and store automatically.
- core-data-expert advises wrapping all Core Data work in context.perform(schedule:_:) or context.performAndWait(_:) blocks.
Verify before relying
Read SKILL.md below before installing (16 files). Open directory: indexed for reading, not audited.
Install
AvdLee/Core-Data-Agent-Skill/core-data-expert
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I fix Core Data threading crash issues?
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.
What is the correct Core Data stack setup for iOS?
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.
How do I use Core Data with Swift Concurrency?
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—use objectID instead.
What causes Core Data batch operations to not update the UI?
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.
How do I set up Core Data migration and resolve versioning errors?
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.
How do I integrate CloudKit sync with NSPersistentCloudKitContainer?
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.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Core Data Expert
Fast, production-oriented guidance for building correct, performant Core Data stacks and fixing common crashes.
Agent behavior contract (follow these rules)
- Determine OS/deployment target when advice depends on availability (iOS 14+/17+ features, etc.).
- Identify the context type before proposing fixes: view context (UI) vs background context (heavy work).
- Recommend
NSManagedObjectIDfor cross-context/cross-task communication; never passNSManagedObjectinstances across contexts. - Prefer lightweight migration when possible; use staged migration (iOS 17+) for complex changes.
- When recommending batch operations, verify persistent history tracking is enabled (often required for UI updates).
- For CloudKit integration, remind developers that Production schema is immutable.
- Reference WWDC/external resources
(truncated - see the full file via the links below)
File tree — 15 files
core-data-expert/SKILL.md
core-data-expert/references/_index.md
core-data-expert/references/batch-operations.md
core-data-expert/references/cloudkit-integration.md
core-data-expert/references/concurrency.md
core-data-expert/references/fetch-requests.md
core-data-expert/references/glossary.md
core-data-expert/references/migration.md
core-data-expert/references/model-configuration.md
core-data-expert/references/performance.md
core-data-expert/references/persistent-history.md
core-data-expert/references/project-audit.md
core-data-expert/references/saving.md
core-data-expert/references/stack-setup.md
core-data-expert/references/testing.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Fix Core Data threading crashes and context confinement issues”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Core Data is Apple's object-oriented database framework for managing persistent storage in iOS applications. This skill covers the essential concepts, architecture, and implementation patterns you need to build robust data layers. Explore how to model entities, perform queries, and optimize performance in your apps.
This skill helps developers resolve Swift concurrency compiler diagnostics, data-race warnings, and isolation boundary issues. It provides structured guidance for refactoring callback-based code to async/await patterns and supports Swift 6 migration across tasks, actors, @MainActor, Sendable conformance, and thread-safety concerns. The skill emphasizes smallest-safe-change fixes grounded in project settings and isolation context.
Get specialized guidance on building robust SwiftData architectures for Swift projects. This skill covers schema design, safe concurrency patterns, migration strategies, and CloudKit synchronization—all tailored for AI coding assistants working with SwiftData-first applications.
This skill systematically audits Swift source files for concurrency hazards, including unsafe async/await patterns, actor reentrancy, Sendable conformance gaps, and memory leaks from retain cycles. It establishes Swift language version context upfront, reads full enclosing symbols rather than diffs alone, and applies targeted checklists for error handling, force unwraps, and closure capture semantics before reporting findings.
This skill guides you through establishing a robust data persistence layer for Apple platform apps. Whether you're choosing between SwiftData and CoreData or implementing either framework, it provides structured setup patterns and best practices tailored to iOS, macOS, and other Apple platforms. Get your app's storage foundation right from the start.
Swiftdata is a skill that enables agent integration with Swiftdata services. Use this skill to connect your agent to Swiftdata and unlock data handling capabilities within your workflows.
More skills axiom-concurrency (MIT)