core-data

Configure Core Data stacks with NSPersistentContainer and background contexts.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill core-data
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: core-data
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/.claude-plugin/plugins/axiom/skills/core-data
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill core-data

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Core Data patterns and concurrency guidance for when to use Core Data versus SwiftData, plus how to set up a robust Core Data stack.

Core Features & Use Cases

  • Modern stack setup, including persistent containers and optional CloudKit integration.
  • Concurrency strategies to avoid thread-confinement issues.
  • Migration considerations and debugging.

Quick Start

Set up a basic Core Data stack with NSPersistentContainer and a background context.

Frequently Asked Questions about core-data

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Should I use Core Data or SwiftData for my iOS app?

Core Data remains the robust choice for complex persistence needs, especially with CloudKit syncing, concurrency demands, or iOS 15 support. SwiftData suits simpler data models on iOS 17+. Choose Core Data if you need advanced relationship modeling, migration control, or multi-user sync.

How do I set up a Core Data stack to avoid threading crashes?

Initialize NSPersistentContainer, configure background contexts with proper concurrency types (privateQueueConcurrencyType for workers), and use perform() blocks to access data on the correct thread. This prevents thread-confinement violations that cause crashes in multi-threaded scenarios.

What's the best way to handle Core Data migrations without crashing?

Enable automatic migrations via lightweight schema versioning when safe, configure merge policies for conflict resolution, and test migrations across your target iOS versions. Plan data transformations incrementally to avoid migration failures in production.

Can I sync Core Data with CloudKit?

Yes, use NSPersistentCloudKitContainer instead of NSPersistentContainer to enable CloudKit sync. It handles schema mirroring and remote change merging automatically, reducing boilerplate for multi-device synchronization.

How do I model one-to-many and many-to-many relationships in Core Data?

Define relationships in your data model using NSRelationshipDescription with cardinality settings (to-one or to-many) and inverse relationships for consistency. Many-to-many relationships require a join entity or use ordered NSSet properties for optimization.

Why does my Core Data app have race conditions with background saves?

Background contexts must be configured with privateQueueConcurrencyType and all fetches or updates must occur within perform() or performAndWait() blocks. Improper context hierarchy or direct main-thread access to background data causes data corruption and crashes.