Back to Skills

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 wh

957stars48forksUpdated 8/3/2026

Security Assessment

Safe(96/100)
Security Score96/100

About core-data

core-data is a focused engineering reference for building, reviewing, and improving Core Data persistence in iOS apps that have not adopted SwiftData. It addresses the recurring difficulty of getting Core Data right — correct stack setup, safe concurrency, efficient list UIs, and non-trivial migrations — by consolidating current best practice with runnable Swift examples and links to Apple documentation. It explicitly scopes itself to Core Data and routes Core Data + SwiftData coexistence or migration questions to a separate swiftdata skill.

The SKILL.md covers stack setup with NSPersistentContainer (and NSPersistentCloudKitContainer for CloudKit sync), concurrency and threading rules (using perform/performAndWait, never passing NSManagedObject across boundaries, passing NSManagedObjectID instead), Swift Concurrency integration via the async perform overload, and NSFetchedResultsController driving table/collection views with diffable snapshots. Additional sections and reference files address batch operations (NSBatchInsert/Delete/UpdateRequest), persistent history tracking, staged migration (NSStagedMigrationManager, iOS 17+), composite attributes (iOS 17+), testing, common mistakes, and a review checklist. Bundled references include staged-migration.md and persistent-history.md, plus an evals file.

It is aimed at iOS/Swift developers maintaining or extending established Core Data codebases, and at reviewers checking persistence code for correctness. Use cases include setting up a fresh stack, integrating Core Data with Swift Concurrency, wiring list-driven UI with change tracking, performing bulk writes, and executing staged schema migrations on iOS 17+.

FAQ

When should I use this instead of the SwiftData skill?

Use it for apps that have not adopted SwiftData. For Core Data and SwiftData coexistence or migrating between them, the skill directs you to the separate swiftdata skill.

What Core Data topics does it cover?

Stack setup, concurrency and threading, NSFetchedResultsController, batch operations, persistent history tracking, staged migration, composite attributes, testing, common mistakes, and a review checklist.

Are there version requirements?

Some features are version-gated: the async perform overload targets iOS 15+, while staged migration (NSStagedMigrationManager) and composite attributes (NSCompositeAttributeDescription) require iOS 17+.

How does it handle Core Data threading safety?

It prescribes always using perform/performAndWait off a context's queue, never passing NSManagedObject across context or thread boundaries (pass the Sendable NSManagedObjectID and re-fetch), and avoiding @unchecked Sendable on managed objects.

Does it include reference material beyond the main guide?

Yes — it ships reference files for staged migration and persistent history tracking, plus an evals file for testing the skill.

All Files

4 files
SKILL.md16.2 KB
View
evals/evals.json3.4 KB
View
references/staged-migration.md2.2 KB
View
references/persistent-history.md1.9 KB
View

Install core-data

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill