---
title: "core-data-expert by avdlee · skilld"
canonical_url: "https://skilld.dev/gh/avdlee/core-data-agent-skill"
meta:
  description: "Expert Core Data guidance (iOS/macOS): stack setup, fetch requests & NSFetchedResultsController, saving/merge conflicts, threading & Swift Concurrency, batch… From avdlee/core-data-agent-skill."
  "og:description": "Expert Core Data guidance (iOS/macOS): stack setup, fetch requests & NSFetchedResultsController, saving/merge conflicts, threading & Swift Concurrency, batch… From avdlee/core-data-agent-skill."
  "og:title": "core-data-expert by avdlee"
  "twitter:description": "Expert Core Data guidance (iOS/macOS): stack setup, fetch requests & NSFetchedResultsController, saving/merge conflicts, threading & Swift Concurrency, batch… From avdlee/core-data-agent-skill."
  "twitter:title": "core-data-expert by avdlee"
---

`

[All skills](https://skilld.dev/skills)

[![avdlee avatar](https://skilld.dev/_img/avatar?url=https%3A%2F%2Fgithub.com%2Favdlee.png%3Fsize%3D96)](https://skilld.dev/gh/avdlee)

# **/core-data-expert**

[@1f62be1](https://github.com/AvdLee/Core-Data-Agent-Skill/commit/1f62be18e2baf403ccd345c1ddd8b8f8eed6cf70 "Your agent reads SKILL.md at commit 1f62be1")

by [Antoine van der Lee](https://skilld.dev/gh/avdlee)· [avdlee](https://skilld.dev/gh/avdlee)/ [core-data-agent-skill](https://skilld.dev/gh/avdlee/core-data-agent-skill)·313 stars

 16

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.

- 16 files
- 167.8 KB
- Updated 8 months ago
- [GitHub](https://github.com/AvdLee/Core-Data-Agent-Skill/blob/1f62be18e2baf403ccd345c1ddd8b8f8eed6cf70/core-data-expert/SKILL.md "View SKILL.md on GitHub")
- [1 warning](#third-party-checks "Third-party checks: 1 warning · 5 checks · Risk SAFE")

## SKILL.md

4.8 KB

**≈71** tokens always: the name and description. **≈1.1k** when used: this file. **≈42k** more on demand in 15 files.

## 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 / contexts** → `references/stack-setup.md`
- **Saving patterns** → `references/saving.md`
- **Fetch requests / list updates / aggregates** → `references/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/update** → `references/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 & debugging** → `references/cloudkit-integration.md`
- **Performance profiling & memory** → `references/performance.md`
- **Testing patterns** → `references/testing.md`
- **Terminology** → `references/glossary.md`

### Common errors → next best move

- **“Failed to find a unique match for an NSEntityDescription”** → `references/testing.md` (shared `NSManagedObjectModel`)
- **`NSPersistentStoreIncompatibleVersionHashError`** → `references/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 Data** → `references/concurrency.md` (don’t “paper over” with `@unchecked Sendable`)
- **`NSMergeConflict` / constraint violations** → `references/model-configuration.md` + `references/stack-setup.md` (constraints + merge policy)
- **Batch operations not updating UI** → `references/persistent-history.md` + `references/batch-operations.md`
- **CloudKit schema/sync issues** → `references/cloudkit-integration.md`
- **Memory grows during fetch** → `references/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`

Source: [SKILL.md on GitHub](https://github.com/AvdLee/Core-Data-Agent-Skill/blob/1f62be18e2baf403ccd345c1ddd8b8f8eed6cf70/core-data-expert/SKILL.md)

## Third-party checks

<details>

<summary>1 warning17d5 checks · Risk SAFE</summary>



- Gen Agent Trust Hub17d

  The skill is a comprehensive technical guide for Apple's Core Data framework, providing expert guidance on stack setup, concurrency, performance, and CloudKit integration. It consists of instructional markdown files and code snippets that adhere to industry best practices. No malicious patterns or security vulnerabilities were detected.
- Socket17d

  No alerts
- Snyk17d

  Risk: LOW · No issues
- Runlayer7mo

  16/16 files flagged
- ZeroLeaks5mo

  Score: 93/100 · 2 sections analyzed

</details>

## Provenance

[Signed by skilld at 1f62be1.](https://github.com/AvdLee/Core-Data-Agent-Skill/commit/1f62be18e2baf403ccd345c1ddd8b8f8eed6cf70 "1f62be18e2baf403ccd345c1ddd8b8f8eed6cf70") This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 8 months ago

## README badge

![README badge for avdlee/core-data-agent-skill](https://skilld.dev/b/avdlee/core-data-agent-skill?theme=light&label=0)

## Related skills

-
-
-
-
-
-