Core Data issues manifest as production crashes from schema mismatches, mysterious concurrency errors, performance degradation under load, and data corruption from unsafe migrations. Core principle 85% of Core Data problems stem from misunderstanding thread-confinement, schema migration requirements, and relationship query patternsβnot Core Data defects.
Confirm successful installation by checking the skill directory location:
.cursor/skills/axiom-core-data-diag
Restart Cursor to activate axiom-core-data-diag. Access via /axiom-core-data-diag in your agent's command palette.
β
Security Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Core Data issues manifest as production crashes from schema mismatches, mysterious concurrency errors, performance degradation under load, and data corruption from unsafe migrations. Core principle 85% of Core Data problems stem from misunderstanding thread-confinement, schema migration requirements, and relationship query patternsβnot Core Data defects.
Red Flags β Suspect Core Data Issue
If you see ANY of these, suspect a Core Data misunderstanding, not framework breakage:
Crash on production launch: "Unresolvable fault" after schema change
Thread-confinement error: "Accessing NSManagedObject on a different thread"
App suddenly slow after adding a UserβPosts relationship
SwiftData app needs complex features; considering mixing Core Data alongside
Schema migration works in simulator but crashes on production
β FORBIDDEN "Core Data is broken, we need a different database"
Core Data handles trillions of records in production apps
Schema mismatches and thread errors are always developer code, not framework
Do not rationalize away the issueβdiagnose it
Critical distinction Simulator deletes the database on each rebuild, hiding schema mismatch issues. Real devices keep persistent databases and crash immediately on schema mismatch. MANDATORY: Test migrations on real device with real data before shipping.
Mandatory First Steps
ALWAYS run these FIRST (before changing code):
// 1. Identify the crash/issue type// Screenshot the crash message and note:// - "Unresolvable fault" = schema mismatch// - "different thread" = thread-confinement// - Slow performance = N+1 queries or fetch size issues// - Data corruption = unsafe migration// Record: "Crash type: [exact message]"// 2. Check if it's schema mismatch// Compare these:let coordinator = persistentStoreCoordinator
let model = coordinator.managedObjectModel
let store = coordinator.persistentStores.first
// Get actual store schema version:do{let metadata =tryNSPersistentStoreCoordinator.metadataForPersistentStore( ofType:NSSQLiteStoreType, at: storeURL, options:nil)print("Store version identifier: \(metadata[NSStoreModelVersionIdentifiersKey]??"unknown")")// Get app's current model version:print("App model version: \(model.versionIdentifiers)")// If different = schema mismatch}catch{print("Schema check error: \(error)")}// Record: "Store version vs. app model: match or mismatch?"// 3. Check thread-confinement for concurrency errors// For any NSManagedObject access:print("Main thread? \(Thread.isMainThread)")print("Context concurrency type: \(context.concurrencyType.rawValue)")print("Accessing from: \(Thread.current)")// Record: "Thread mismatch? Yes/no"// 4. Profile relationship access for N+1 problems// In Xcode, run with arguments:// -com.apple.CoreData.SQLDebug 1// Check Console for SQL queries:// SELECT * FROM USERS; (1 query)// SELECT * FROM POSTS WHERE user_id = 1; (1 query per user = N+1!)// Record: "N+1 found? Yes/no, how many extra queries"// 5. Check SwiftData vs. Core Data confusionif#available(iOS 17.0,*){// If using SwiftData @Model + Core Data simultaneously:// Error: "Store is locked" or "EXC_BAD_ACCESS"// = trying to access same database from both layersprint("Using both SwiftData and Core Data on same store?")}// Record: "Mixing SwiftData + Core Data? Yes/no"
What this tells you
Schema mismatch β Proceed to Pattern 1 (lightweight migration decision)
Thread-confinement error β Proceed to Pattern 2 (async/await concurrency)
N+1 queries β Proceed to Pattern 3 (relationship prefetching)
SwiftData + Core Data conflict β Proceed to Pattern 4 (bridging)
Slow after migration β Proceed to Pattern 5 (testing safety)
MANDATORY INTERPRETATION
Before changing ANY code, identify ONE of these:
If crash is "Unresolvable fault" AND store/model versions differ β Schema mismatch (not user error)
If crash mentions "different thread" AND you're using DispatchQueue β Thread-confinement (not thread-safe design)
If performance degrades with relationship access β N+1 queries (check SQL log)
If SwiftData and Core Data code exist together β Conflicting data layers (architectural issue)
If migration test passes but production fails β Edge case in real data (testing gap)
If diagnostics are contradictory or unclear
STOP. Do NOT proceed to patterns yet
Add print statements to every NSManagedObject access (thread check)
Add -com.apple.CoreData.SQLDebug 1 and count SQL queries
Establish baseline: what's actually happening vs. what you assumed
Decision Tree
Core Data problem suspected?
ββ Crash: "Unresolvable fault"?
β ββ YES β Schema mismatch (store β app model)
β ββ Add new required field? β Pattern 1a (lightweight migration)
β ββ Remove field, rename, or change type? β Pattern 1b (heavy migration)
β ββ Don't know how to fix? β Pattern 1c (testing safety)
β
ββ Crash: "different thread"?
β ββ YES β Thread-confinement violated
β ββ Using DispatchQueue for background work? β Pattern 2a (async context)
β ββ Mixing Core Data with async/await? β Pattern 2b (structured concurrency)
β ββ SwiftUI @FetchRequest causing issues? β Pattern 2c (@FetchRequest safety)
β
ββ Performance: App became slow?
β ββ YES β Likely N+1 queries
β ββ Accessing user.posts in loop? β Pattern 3a (prefetching)
β ββ Large result set? β Pattern 3b (batch sizing)
β ββ Just added relationships? β Pattern 3c (relationship tuning)
β
ββ Using both SwiftData and Core Data?
β ββ YES β Data layer conflict
β ββ Need Core Data features SwiftData lacks? β Pattern 4a (drop to Core Data)
β ββ Already committed to SwiftData? β Pattern 4b (stay in SwiftData)
β ββ Unsure which to use? β Pattern 4c (decision framework)
β
ββ Migration works locally but crashes in production?
ββ YES β Testing gap
ββ Didn't test with real data? β Pattern 5a (production testing)
ββ Schema change affects large dataset? β Pattern 5b (migration safety)
ββ Need verification before shipping? β Pattern 5c (pre-deployment checklist)
Common Patterns
Pattern Selection Rules (MANDATORY)
Apply ONE pattern at a time, starting with diagnostics
Always start with Mandatory First Steps β Identify the actual problem
Run decision tree β Narrow to specific pattern
Apply ONE pattern β Don't combine patterns
Test on real device β Simulator hides issues
Verify with migration test β Before deploying
FORBIDDEN
β Changing code without diagnostics
β Skipping real device testing
β Using simulator success as proof of migration safety
β Mixing multiple migration patterns
β Deploying migrations without pre-deployment verification
PRINCIPLE Core Data can automatically migrate simple schemas (additive changes) without data loss if done correctly.
β SAFE Lightweight Migrations
Adding new optional field: @NSManaged var nickname: String?
Adding new required field WITH default: Create attribute with default value
Renaming entity or attribute: Use mapping model with automatic mapping
Removing unused field: Just delete from model (data stays on disk, ignored)
β WRONG (Crashes production)
// BAD: Adding required field without migration@NSManagedvar userID:String// Required, no default// BAD: Assuming simulator = production// Works in simulator (deletes DB), crashes on real device// BAD: Modifying field type@NSManagedvar createdAt:Date// Was String, now Date// Core Data can't automatically convert
β CORRECT (Safe lightweight migration)
// 1. In Xcode: Editor β Add Model Version// Creates new .xcdatamodel version file// 2. In new version, add required field WITH default:@NSManagedvar userID:String=UUID().uuidString
// 3. Mark as current model version:// File Inspector β Versioned Core Data Model// Check "Current Model Version"// 4. Test:// Simulate old version: delete app, copy old database, run with new code// Real app loads β migration succeeded// 5. Deploy when confident
When this works
Adding optional fields (always safe)
Adding required fields WITH default values
Removing fields
Renaming entities/attributes with mapping model
When this FAILS (don't try lightweight)
Changing field type (String β Int)
Making optional field required (data has nulls, can't convert)
Complex relationship changes
Custom data transformations needed
Time cost 5-10 minutes for lightweight migration setup
Pattern 1b: Heavy Migration (Complex Schema Changes)
PRINCIPLE When lightweight migration won't work, use NSEntityMigrationPolicy for custom transformation logic.
Use when
Changing field types (String β Date)
Making optional required (need to populate existing nulls)
Complex relationship restructuring
Custom data transformations (e.g., split "firstName lastName" into separate fields)
βΊAccess to product documentation and roadmap tools (Jira, Notion, etc.)
βΊUnderstanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
βΊStakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Steps
1Install product management skill
2Start with user story generation for known feature
3Progress to competitive analysis: research 2-3 competitors
4Use for roadmap prioritization: apply RICE/ICE scoring
5Draft stakeholder communications and refine based on feedback
6Build template library for recurring PM tasks
7Share effective prompts with product team
Common Pitfalls
β Not validating competitive researchβverify facts before sharing
β Accepting user stories without involving engineering team
β Over-relying on frameworks without qualitative judgment
β Not customizing outputs to company culture and communication style
β Skipping stakeholder validation of generated requirements
Best Practices
β Do
+Validate research and competitive analysis with real data
+Collaborate with engineering when generating technical requirements
+Customize frameworks and templates to your company context
+Use skill for first drafts, refine with stakeholder input
+Document successful prompt patterns for PM tasks
+Combine AI efficiency with human judgment and intuition
β Don't
βDon't publish competitive analysis without fact-checking
βDon't finalize user stories without engineering review
βDon't make prioritization decisions solely on AI scoring
βDon't skip customer validation of generated requirements
βDon't ignore company-specific context and culture
π‘ Pro Tips
β Provide context: company goals, constraints, customer feedback
β Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
β Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
β Use skill for 70% generation + 30% customization to company needs
When to Use This
β Use when
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
β Avoid when
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path
1Basic: user stories, feature specs, status updates