← ClaudeAtlas

swiftdatalisted

Route SwiftData implementation tasks to the correct Knowledge Contracts -- declaring persistent model classes with @Model/@Attribute/@Relationship/@Transient, creating and injecting a ModelContainer/ModelConfiguration via .modelContainer, ModelContext CRUD (insert/delete/save/autosave/undo), fetching with @Query or FetchDescriptor+context.fetch(_:), and @Relationship(deleteRule:) referential integrity. Use when writing @Model class RemoteImage { ... }, @Attribute(.unique), @Relationship(deleteRule:inverse:), @Transient, ModelContainer(for:configurations:), ModelConfiguration(isStoredInMemoryOnly:), .modelContainer(for:)/.modelContainer(_:), @Environment(\.modelContext), context.insert(_:)/delete(_:)/save(), context.autosaveEnabled, context.undoManager, @Query(filter:sort:order:),
caglarbaranbora/Apple-Agent-Kit · ★ 1 · Data & Documents · score 70
Install: claude install-skill caglarbaranbora/Apple-Agent-Kit
# SwiftData — Foundations Skill ## Purpose Route SwiftData implementation tasks to the minimum required SwiftData Knowledge Contracts. v1 scope is declaring `@Model` classes and their attributes/relationships, setting up and injecting a `ModelContainer`, performing CRUD through a `ModelContext`, fetching with `@Query` or `FetchDescriptor`, and delete-rule/referential-integrity behavior on relationships -- not CloudKit sync, not schema migration, not Core Data interop, and not the `#Index`/`#Unique` macros beyond a basic mention. ## Routing Load only the contracts relevant to the task. All paths relative to knowledge/swiftdata/. - Annotating a class with `@Model`; customizing a property with `@Attribute` (e.g. `.unique`) or `@Transient`; declaring a `@Relationship` property and its `inverse:`; or asking what SwiftData auto-synthesizes (`Identifiable`/`Hashable`/`Observable`, not `Codable`) -> model-definition.md - Setting up `.modelContainer(for:)`/`.modelContainer(_:)`; configuring `ModelConfiguration` (`isStoredInMemoryOnly`, `allowsSave`); creating a `ModelContainer(for:configurations:)` manually for previews/tests/non-SwiftUI code; or wiring `@Environment(\.modelContext)` -> model-container-setup.md - Calling `context.insert(_:)`/`delete(_:)`/`save()`; deciding whether `autosaveEnabled` makes an explicit `save()` unnecessary; choosing `mainContext` vs. a manually created secondary `ModelContext`; or enabling undo via `context.undoManager` -> model-context-crud.m