neversight/learn-skills.dev/axiom-core-data
Claude Code and agent skill by neversight/learn-skills.dev
- community
Checking that the SKILL.md file is still in the repository.
Use when choosing Core Data vs SwiftData, setting up the Core Data stack, modeling relationships, or implementing concurrency patterns - prevents thread-confinement errors and migration crashes
Install
npx vskill@latest install neversight/learn-skills.dev/axiom-core-dataSKILL.md
The same SKILL.md was published earlier as neversight/learn-skills.dev/axiom-core-data.
Core Data
Overview
Core principle: Core Data is a mature object graph and persistence framework. Use it when needing features SwiftData doesn't support, or when targeting older iOS versions.
When to use Core Data vs SwiftData:
- SwiftData (iOS 17+) — New apps, simpler API, Swift-native
- Core Data — iOS 16 and earlier, advanced features, existing codebases
Quick Decision Tree
Red Flags
If ANY of these appear, STOP:
- ❌ "Access managed objects on any thread" — Thread-confinement violation
- ❌ "Skip migration testing on real device" — Simulator hides schema issues
- ❌ "Use a singleton context everywhere" — Leads to concurrency crashes
- ❌ "Force lightweight migration always" — Complex changes need mapping models
- ❌ "Fetch in view body" — Use @FetchRequest or observe in view model
Core Data Stack Setup
Modern Stack (iOS 10+)
CloudKit Integration
Concurrency Patterns
The Golden Rule
NEVER pass NSManagedObject across threads. Pass objectID instead.
Background Processing
Async/Await (iOS 15+)
Relationship Modeling
One-to-Many
Many-to-Many
Delete Rules
| Rule | Behavior | Use Case | |
|---|---|---|---|
| Nullify | Set relationship to nil | Optional relationships | |
| Cascade | Delete related objects | Owned children (User → Posts) | |
| Deny | Prevent deletion if related objects exist | Protect referenced data | |
| No Action | Do nothing (manual cleanup required) | Rarely appropriate |
Fetching Patterns
SwiftUI Integration
Batch Fetching (Avoid N+1)
Batch Size for Large Datasets
Schema Migration
Lightweight Migration (Automatic)
Handled automatically for:
- Adding optional attributes
- Removing attributes
- Renaming (with renaming identifier)
- Adding relationships with optional or default value
When Mapping Model Is Needed
- Changing attribute types
- Splitting/merging entities
- Complex relationship changes
- Data transformation during migration
Migration Testing Checklist
MANDATORY before shipping:
- ✓ Test on REAL DEVICE (simulator deletes DB on rebuild)
- ✓ Install old version, create data
- ✓ Install new version over it
- ✓ Verify all data accessible
- ✓ Check migration performance (large datasets)
Anti-Patterns
1. Singleton Context for Everything
2. Fetching in View Body
3. Ignoring Merge Policy
Performance Tips
- Use fetchBatchSize for large result sets
- Prefetch relationships that will be accessed
- Use background contexts for imports/exports
- Batch save — don't save after each insert
- Use fetchLimit when only first N results are needed
- Profile with SQL debug:
-com.apple.CoreData.SQLDebug 1
Pressure Scenarios
Scenario 1: "SwiftData is simpler, let's migrate now"
Situation: New iOS 17 features available, temptation to migrate mid-project.
Risk: Migration is complex. Mixed Core Data + SwiftData has sharp edges.
Response: "Complete current milestone first. Migration needs dedicated time and testing."
Scenario 2: "Skip migration testing, simulator works"
Situation: Schema change tested only in simulator.
Risk: Simulator deletes database on rebuild. Real devices keep persistent data and crash.
Response: "MANDATORY: Test on real device with real data. 15 minutes now prevents production crash."
tvOS
CoreData + CloudKit is dangerous on tvOS. CloudKit metadata causes significant space inflation in the local store, and tvOS has no persistent local storage — the system deletes Caches (including Application Support) at any time. The inflated store plus random deletion is a worst-case combination.
Recommendation: Use SQLiteData with CloudKit SyncEngine instead for tvOS data persistence. See axiom-tvos for full tvOS storage constraints.
Related Skills
axiom-core-data-diag— Debugging migrations, thread errors, N+1 queriesaxiom-swiftdata— Modern alternative for iOS 17+axiom-database-migration— Safe schema evolution patternsaxiom-swift-concurrency— Async/await patterns for Core Data
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdata/skills-md/megastep/codex-skills/axiom-core-data/SKILL.md
Popularity
- Repository stars
- 218
- Repository forks
- 38
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/neversight/learn-skills.dev/axiom-core-data)