Agent skill · software engineering · dpearson2699

core-data

Build, review, or improve Core Data persistence in apps that have not adopted SwiftData. Use when working with NSManagedObject subclasses, NSFetchedResultsController for list-driven UI, NSBatchInsertRequest / NSBatchDeleteRequest / NSBatchUpdateRequest for bulk operations, NSPersistentHistoryChangeRequest for persistent history tracking and multi-target sync, NSStagedMigrationManager for staged schema migrations (iOS 17+), NSCompositeAttributeDescription for composite attributes (iOS 17+), or when integrating Core Data threading with Swift Concurrency. For Core Data + SwiftData coexistence or migration, see the swiftdata skill instead.

Why this skill is useful

Provides specific implementation patterns and best practices for Core Data that the AI wouldn't reliably generate on its own.

What it needs

About 7k tokens when loaded. Last updated 2026-07-31. 973 stars on the source repository.

What this skill does

Core Data Build and maintain data persistence using Core Data for apps that have not adopted SwiftData. Covers stack setup, concurrency, batch operations, NSFetchedResultsController, persistent history tracking, staged migration, and testing. Contents Stack Setup Concurrency and Threading NSFetchedResultsController Batch Operations Persistent History Tracking Staged Migration Composite Attributes SwiftData Boundary Testing Common Mistakes Review Checklist References Stack Setup NSPersistentContainer encapsulates the Core Data stack. Docs: NSPersistentContainer For CloudKit sync, use NSPersistentCloudKitContainer instead. Concurrency and Threading Core Data contexts are bound to queues. The viewContext is on the main queue; background contexts operate on private queues. Docs: NSManagedObjectContext Rules: Always use perform(:) or performAndWait(:) when accessing a context off its own queue. Never pass NSManagedObject instances across context or thread boundaries. Pass NSManagedObjectID instead and re-fetch. Set automaticallyMergesChangesFromParent = true on the viewContext. Swift Concurrency Integration NSManagedObjectContext.perform(:) has an async throws overload (iOS 15+). Avoid marking NSManagedObject subclasses as Sendable. Do not use @unchecked Sendable on managed objects. If you need cross-boundary communication, pass the objectID (which is Sendable) and re-fetch: NSFetchedResultsController Efficiently drives UITableView / UICollectionView from a Core Data fetch request, with built-in change tracking and optional caching. Docs: NSFetchedResultsController Key points: The fetch request must have at least one sort descriptor. Call deleteCache(withName:) before changing the fetch request predicate or sort descriptors, or set cacheName to nil. The diffable snapshot delegate method (didChangeContentWith:) is available iOS 13+ and is preferred over the older per-change callbacks. After a context reset(), call performFetch() again. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills dpearson2699/core-data

View the source on GitHub

Browse the @skills marketplace