PluginBench
Skill
Review
Audit score 70

core-data-expert

avdlee/core-data-agent-skill

Expert Core Data guidance for iOS/macOS: stack setup, migrations, threading, CloudKit sync, and production performance.

What is core-data-expert?

Provides production-oriented guidance for building correct and performant Core Data stacks on iOS and macOS. Use this skill when setting up Core Data, debugging threading/merge conflicts, optimizing performance, handling migrations, or integrating CloudKit sync.

  • Diagnose Core Data crashes and threading issues with context confinement rules
  • Design stack setup with appropriate merge policies and context configurations
  • Guide fetch request optimization, NSFetchedResultsController patterns, and batch operations
  • Advise on Swift Concurrency integration (async/await, actors, Sendable) with Core Data
  • Handle schema migrations (lightweight, staged, deferred) across iOS versions
  • Debug persistent history tracking and batch operation UI update failures

How to install core-data-expert

npx skills add https://github.com/avdlee/core-data-agent-skill --skill core-data-expert
Claude Code
Cursor
Windsurf
Cline

How to use core-data-expert

  1. 1.Clarify your goal: stack setup, bugfix, migration, performance, or CloudKit integration
  2. 2.Provide platform, deployment target, store type, and whether CloudKit is enabled
  3. 3.Share the exact error message, stack trace, or describe the behavior you're debugging
  4. 4.Reference the appropriate guide from the routing map based on your issue type
  5. 5.Follow the verification checklist when implementing changes to validate correctness

Use cases

Good for
  • Setting up a new Core Data stack with proper threading and merge policies
  • Fixing crashes from passing NSManagedObject instances across contexts
  • Implementing batch insert/update/delete operations with UI synchronization
  • Migrating Core Data models between app versions without data loss
  • Integrating CloudKit sync into an existing Core Data app
Who it's for
  • iOS/macOS developers building or maintaining Core Data apps
  • Engineers debugging Core Data threading crashes or merge conflicts
  • Teams implementing CloudKit synchronization
  • Developers optimizing Core Data performance and memory usage
  • Engineers migrating Core Data schemas across app versions

core-data-expert FAQ

When should I pass NSManagedObjectID instead of NSManagedObject across contexts?

Always pass NSManagedObjectID when communicating between contexts or across async boundaries. NSManagedObject instances are confined to their creation context and cannot be safely used in other contexts, which causes threading exceptions.

How do I fix batch operations that don't update the UI?

Enable persistent history tracking and implement a merge pipeline to observe and apply changes from batch operations. See references/persistent-history.md and references/batch-operations.md for implementation patterns.

What's the difference between lightweight and staged migrations?

Lightweight migrations are automatic for simple changes (adding attributes, renaming entities). Staged migrations (iOS 17+) break complex changes into multiple steps. Use staged migration for complex transformations; deferred migration for data transformation logic.

How do I integrate CloudKit sync without breaking my existing Core Data app?

Use NSPersistentCloudKitContainer, enable persistent history tracking, and remember that the Production schema is immutable once deployed. Test thoroughly in Development schema first.

What's the best way to handle merge conflicts in Core Data?

Configure appropriate merge policies (e.g., mergeByPropertyObjectTrumpMergePolicy) at stack setup, define constraints in your model, and implement conflict resolution strategies. See references/stack-setup.md and references/model-configuration.md.

Full instructions (SKILL.md)

Source of truth, from avdlee/core-data-agent-skill.


name: core-data-expert description: 'Expert Core Data guidance (iOS/macOS): stack setup, fetch requests & NSFetchedResultsController, saving/merge conflicts, threading & Swift Concurrency, batch operations & persistent history, migrations, performance, and NSPersistentCloudKitContainer/CloudKit sync.'

Core Data Expert

Fast, production-oriented guidance for building correct, performant Core Data stacks and fixing common crashes.

Agent behavior contract (follow these rules)

  1. Determine OS/deployment target when advice depends on availability (iOS 14+/17+ features, etc.).
  2. Identify the context type before proposing fixes: view context (UI) vs background context (heavy work).
  3. Recommend NSManagedObjectID for cross-context/cross-task communication; never pass NSManagedObject instances across contexts.
  4. Prefer lightweight migration when possible; use staged migration (iOS 17+) for complex changes.
  5. When recommending batch operations, verify persistent history tracking is enabled (often required for UI updates).
  6. For CloudKit integration, remind developers that Production schema is immutable.
  7. Reference WWDC/external resources sparingly; prefer this skill’s references/.

First 60 seconds (triage template)

  • Clarify the goal: setup, bugfix, migration, performance, CloudKit?
  • Collect minimal facts:
    • platform + deployment target
    • store type (SQLite / in-memory) and whether CloudKit is enabled
    • context involved (view vs background) and whether Swift Concurrency is in use
    • exact error message + stack trace/logs
  • Branch immediately:
    • threading/crash → focus on context confinement + NSManagedObjectID handoff
    • migration error → identify model versions + migration strategy
    • batch ops not updating UI → persistent history tracking + merge pipeline

Routing map (pick the right reference fast)

  • Stack setup / merge policies / contextsreferences/stack-setup.md
  • Saving patternsreferences/saving.md
  • Fetch requests / list updates / aggregatesreferences/fetch-requests.md
  • Traditional threading (perform/performAndWait, object IDs)references/threading.md
  • Swift Concurrency (async/await, actors, Sendable, DAOs)references/concurrency.md
  • Batch insert/delete/updatereferences/batch-operations.md
  • Persistent history tracking + “batch ops not updating UI”references/persistent-history.md
  • Model configuration (constraints, validation, derived/composite, transformables)references/model-configuration.md
  • Schema migration (lightweight/staged/deferred)references/migration.md
  • CloudKit integration & debuggingreferences/cloudkit-integration.md
  • Performance profiling & memoryreferences/performance.md
  • Testing patternsreferences/testing.md
  • Terminologyreferences/glossary.md

Common errors → next best move

  • “Failed to find a unique match for an NSEntityDescription”references/testing.md (shared NSManagedObjectModel)
  • NSPersistentStoreIncompatibleVersionHashErrorreferences/migration.md (versioning + migration)
  • Cross-context/threading exceptions (e.g. delete/update from wrong context) → references/threading.md and/or references/concurrency.md (use NSManagedObjectID)
  • Sendable / actor-isolation warnings around Core Datareferences/concurrency.md (don’t “paper over” with @unchecked Sendable)
  • NSMergeConflict / constraint violationsreferences/model-configuration.md + references/stack-setup.md (constraints + merge policy)
  • Batch operations not updating UIreferences/persistent-history.md + references/batch-operations.md
  • CloudKit schema/sync issuesreferences/cloudkit-integration.md
  • Memory grows during fetchreferences/performance.md + references/fetch-requests.md

Verification checklist (when changing Core Data code)

  • Confirm the context matches the work (UI vs background).
  • Ensure NSManagedObject instances never cross contexts; pass NSManagedObjectID instead.
  • If using batch ops, confirm persistent history tracking + merge pipeline.
  • If using constraints, confirm merge policy and conflict resolution strategy.
  • If performance-related, profile with Instruments and validate fetch batching/limits.

Reference files

  • references/_index.md (navigation)
  • references/stack-setup.md
  • references/saving.md
  • references/fetch-requests.md
  • references/threading.md
  • references/concurrency.md
  • references/batch-operations.md
  • references/persistent-history.md
  • references/model-configuration.md
  • references/migration.md
  • references/cloudkit-integration.md
  • references/performance.md
  • references/testing.md
  • references/glossary.md