coredata-swift6-pro
Skill5 starsChanged 11 days agoMITView on GitHub
Reviews Core Data code for Swift 6 strict concurrency compliance, modern context usage, and SPM compatibility. Use when reading, writing, or reviewing Core Data code under Swift 6.
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- app-intents-proSkill
- instruments-profiling-proSkill
- motion-design-proSkill
- store-compliance-proSkill
- swift-accessibility-proSkill
- swift-adaptive-layout-proSkill
- swift-concurrency-proSkill
- swiftdata-proSkill
- swift-design-system-proSkill
- swift-docc-proSkill
- swift-error-handling-proSkill
- swift-logging-proSkill
- swift-memory-storage-proSkill
- swift-modularization-proSkill
- swift-package-proSkill
- swift-testing-proSkill
- swiftui-proSkill
- xcode-security-proSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Check background context usage with perform/performAndWait using references/background-contexts.md.
- Very specific: line 16
Verify SPM compatibility for .xcdatamodeld bundling using references/spm-limitations.md.
- Very specific: line 17
Check for modern persistent container patterns and fetch result types using references/modern-patterns.md.
- Distinctive: line 20
If doing a partial review, load only the relevant reference files.
- Very specific: line 28
All background context work goes through context.perform { } (async) or context.performAndWait { } (sync).
- Very specific: line 30
Use NSPersistentContainer (or NSPersistentCloudKitContainer), not the deprecated NSPersistentStoreCoordinator directly.
- Very specific: line 31
Prefer .viewContext.automaticallyMergesChangesFromParent = true so background changes propagate.
- Very specific: line 99
SPM compatibility (high): Test container relies on Bundle.module for .momd — must build model programmatically.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Review Core Data code for Swift 6 concurrency correctness, modern API usage, and SPM compatibility. Report only genuine problems - do not nitpick or invent issues.
Review process:
- Validate
viewContextaccess is@MainActor-isolated usingreferences/main-actor.md. - Check background context usage with
perform/performAndWaitusingreferences/background-contexts.md. - Verify SPM compatibility for
.xcdatamodeldbundling usingreferences/spm-limitations.md. - Check for modern persistent container patterns and fetch result types using
references/modern-patterns.md. - Flag direct cross-context object passing (must pass
NSManagedObjectIDinstead).
If doing a partial review, load only the relevant reference files.
Core Instructions
- Target Swift 6 with strict concurrency. Core Data + Swift 6 has specific rules that must be followed.
viewContextis bound to the main queue — all synchronous access must be@MainActoror wrapped inMainActor.run.NSManagedObjectsubclasses are NOTSendable. Never pass them across isolation boundaries — useNSManagedObjectIDinstead.- All background context work goes through
context.perform { }(async) orcontext.performAndWait { }(sync). - For SPM packages,
.xcdatamodeldcannot be compiled to.momdbyswift build— only Xcode can. Tests run viaswift testmust buildNSManagedObjectModelprogrammatically. - Use
NSPersistentContainer(orNSPersistentCloudKitContainer), not the deprecatedNSPersistentStoreCoordinatordirectly. - Prefer
.viewContext.automaticallyMergesChangesFromParent = trueso background changes propagate. - For tests, use
NSInMemoryStoreTypeso each test has an isolated store.
Output Format
Organize findings by file. For each issue:
- State the file and relevant line(s).
- Name the rule being violated.
- Show a brief before/after code fix.
Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.
Example output:
CoreStorage/Tests/EntityStoreTests.swift
Line 23: Sync viewContext test missing @MainActor — will fail under Swift 6 strict concurrency.
// Before
@Test func createUpdateDeleteObject() throws {
let store = EntityStore(...)
try store.create(...)
}
// After
@MainActor @Test func createUpdateDeleteObject() throws {
let store = EntityStore(...)
try store.create(...)
}Line 45: Background context work missing perform { } block.
// Before
let bgContext = container.newBackgroundContext()
let object = MyObject(context: bgContext)
object.value = "foo"
try bgContext.save()
// After
let bgContext = container.newBackgroundContext()
try await bgContext.perform {
let object = MyObject(context: bgContext)
object.value = "foo"
try bgContext.save()
}CoreStorage/Tests/Utilities/KeyValue.swift
Line 14: Test relies on Bundle.module for .momd — will fail under swift test.
// Before
self.init(storeName: "MyModel", in: .module)
// After
let model = makeKeyValueManagedObjectModel()
self.init(storeName: "MyModel", managedObjectModel: model)Summary
- Concurrency (high): 4 sync
viewContexttests missing@MainActorannotation. - SPM compatibility (high): Test container relies on
Bundle.modulefor.momd— must build model programmatically. - Concurrency (medium): Background context work outside
perform { }block on line 45.
End of example.
References
references/main-actor.md—viewContextmain-queue binding,@MainActortest patterns, isolation rules.references/background-contexts.md—perform/performAndWait,newBackgroundContext, async wrappers, merge policies.references/spm-limitations.md—.xcdatamodeldcompilation,Bundle.moduleissues, programmaticNSManagedObjectModel.references/modern-patterns.md—NSPersistentContainer, fetch results, Codable transformers, CloudKit container.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

