core-data-expert — Claude Code skill: what it does, how to install
Provides Core Data architectural guidance for iOS and macOS, covering stack setup, Swift Concurrency, migrations, and CloudKit sync.
npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a claude-codeWhat core-data-expert does
The skill enforces strict Core Data development rules for your coding agent. It separates UI view contexts from background contexts right from the start. Under its guidance, the agent never passes NSManagedObject instances across contexts, demanding NSManagedObjectID instead.
A built-in triage checklist routes issues directly to markdown guides in references/. The agent pulls rules for NSFetchedResultsController, batch operations, staged migrations on iOS 17+, and NSMergeConflict policies. If you implement batch updates or deletions, it insists on persistent history tracking so your UI actually refreshes.
Papering over actor isolation warnings with @unchecked Sendable will fail the check: the skill enforces real concurrency safety. It also keeps you from breaking live apps by reminding you that CloudKit production schemas are immutable.
What it helps with
- resolve cross-context threading crashes by passing
NSManagedObjectID - set up batch operations with persistent history tracking for UI updates
- configure schema migrations, including staged migrations for iOS 17+
- handle
NSMergeConflictand entity constraint violations - debug CloudKit synchronization with
NSPersistentCloudKitContainer
Example prompts for the agent
- Fix NSPersistentStoreIncompatibleVersionHashError after modifying the Core Data model
- How do I safely pass fetched records to a background actor in Swift Concurrency?
- Batch delete operations are not updating the NSFetchedResultsController UI, how do I configure persistent history tracking?
How to install core-data-expert
1Skills CLI (Vercel)
npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a claude-code2Manually: put the files in place
~/.claude/skills/core-data-expert/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/core-data-expert/
1Skills CLI (Vercel)
npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a codex2Manually: put the files in place
.agents/skills/core-data-expert/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a cursor2Manually: put the files in place
.cursor/skills/core-data-expert/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install AvdLee/Core-Data-Agent-Skill core-data-expert2Manually: put the files in place
.github/skills/core-data-expert/SKILL.md1Skills CLI (Vercel)
npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a gemini-cli2Platform CLI
gemini skills install https://github.com/AvdLee/Core-Data-Agent-Skill --path core-data-expertManually: put the files in place
.devin/skills/core-data-expert/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about core-data-expert
How to install core-data-expert in Claude Code?
Run npx skills add AvdLee/Core-Data-Agent-Skill --skill core-data-expert -a claude-code. Alternatively, add the skill directly to ~/.claude/skills/core-data-expert/SKILL.md.
What does core-data-expert do?
It guides coding agents through building and debugging Core Data stacks on iOS and macOS, handling thread safety, migrations, and CloudKit integration.
How does it handle Swift Concurrency and Sendable warnings?
The skill prevents agents from using @unchecked Sendable workarounds. Instead, it enforces safe context confinement and cross-task communication via NSManagedObjectID.
Source text
SKILL.md · MIT
--- 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 / 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`
© AvdLee · MIT · AvdLee/Core-Data-Agent-Skill