From core-data-pro
Provides correct patterns for Core Data: safe threading, efficient fetching, batch operations, and migrations. Useful for fixing crashes and performance issues in existing Core Data stacks.
How this skill is triggered — by the user, by Claude, or both
Slash command
/core-data-pro:core-data-proThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use Core Data correctly: safe contexts, efficient fetches, clean migrations. (For new
Use Core Data correctly: safe contexts, efficient fetches, clean migrations. (For new
apps, also consider SwiftData — see swiftdata-pro.)
Trigger: /core-data-pro.
NSManagedObjects belong to their context — don't pass them across threads, pass IDs.let container = NSPersistentContainer(name: "Model")
container.loadPersistentStores { _, error in
if let error { fatalError("Store load failed: \(error)") }
}
container.viewContext.automaticallyMergesChangesFromParent = true
❌ Background work on the view context (crashes / corruption)
DispatchQueue.global().async {
let obj = Item(context: container.viewContext) // wrong queue
}
✅ Background context with perform
container.performBackgroundTask { context in
let obj = Item(context: context)
obj.title = "New"
try? context.save() // merges into viewContext automatically
}
Pass object IDs across contexts, not objects:
let id = obj.objectID
container.performBackgroundTask { ctx in
let bgObj = ctx.object(with: id)
}
❌ Fetch everything, filter in Swift
let all = try context.fetch(Item.fetchRequest())
let recent = all.filter { $0.date > cutoff } // loads the whole table
✅ Predicate + sort + limit in the request
let req = Item.fetchRequest()
req.predicate = NSPredicate(format: "date > %@", cutoff as NSDate)
req.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
req.fetchLimit = 50
let recent = try context.fetch(req)
Use fetchBatchSize for large lists; NSFetchedResultsController (UIKit) or
@FetchRequest (SwiftUI) for table/list binding.
For bulk delete/update, skip loading objects into memory:
let delete = NSBatchDeleteRequest(fetchRequest: Item.fetchRequest())
try context.execute(delete)
// then merge changes into viewContext
shouldInferMappingModelAutomatically = true.NSEntityMigrationPolicy. Never edit a
shipped model version in place; add a new version.perform).NSManagedObjects across threads instead of objectID.NSPredicate.fetchLimit/fetchBatchSize on large fetches.NSBatchDeleteRequest.Per issue: file:line, rule, before/after. Lead with threading violations (crash risk) and migration hazards.
Searches MemPalace before answering questions about past work, people, projects, or prior decisions. Returns verbatim stored content instead of guessing from model memory.
Guides Payload CMS config (payload.config.ts), collections, fields, hooks, access control, APIs. Debugs validation errors, security, relationships, queries, transactions, hook behavior.
Implements vector databases with Pinecone, Weaviate, Qdrant, Milvus, pgvector for semantic search, RAG, recommendations, and similarity systems. Optimizes embeddings, indexing, and hybrid search.
npx claudepluginhub laxrajpurohit/swift-skills-pro --plugin core-data-pro