swiftdatalisted
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