swiftdata

Model SwiftData persistence with @Model, @Query, and CloudKit sync.

1.1k|81|Updated Nov 30, 2025
One-click install
npx skills add https://github.com/CharlesWiltgen/Axiom --skill swiftdata
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftdata
Source: https://github.com/CharlesWiltgen/Axiom/tree/main/.claude-plugin/plugins/axiom/skills/swiftdata
Command: npx skills add https://github.com/CharlesWiltgen/Axiom --skill swiftdata

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Apple's native persistence framework with @Model, @Query, and CloudKit sync; designed for SwiftUI with reference-type models.

Core Features & Use Cases

  • @Model classes and declarative @Query for reactive UI updates.
  • CloudKit sync, relationships, and concurrency with Swift 6.
  • Migrations and cross-framework guidance.

Quick Start

Define a @Model class, use @Query to fetch in a SwiftUI view, and enable CloudKit sync.

Frequently Asked Questions about swiftdata

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up data persistence in SwiftUI with native iOS frameworks?

SwiftData provides native persistence for SwiftUI apps using @Model classes and @Query for reactive data fetching. Define a @Model class, use @Query in your SwiftUI view to fetch data declaratively, and SwiftData automatically handles CRUD operations and UI updates without manual state management.

Can I sync my app's data to CloudKit automatically?

Yes, SwiftData supports CloudKit sync for reference-type models. Enable CloudKit in your app configuration, define relationships with @Relationship, and SwiftData handles synchronization across devices while maintaining concurrency safety with Swift 6 and @MainActor.

What's the best way to define relationships between SwiftData models?

Use @Relationship to define reference-type relationships between @Model classes. SwiftData manages the connections, handles cascade behavior, and maintains data consistency across related objects in your queries and CloudKit sync.

How do I handle data migrations when my SwiftData schema changes?

SwiftData provides migration facilitation tools to manage schema evolution. Plan migrations by versioning your @Model definitions, updating @Attribute properties and relationships, and SwiftData handles the data transformation across app versions.

Do I need any special setup to use SwiftData with Swift 6 concurrency?

SwiftData integrates with Swift 6 modern concurrency and @MainActor for thread-safe operations. Use @Query on the main thread for reactive updates, and SwiftData ensures your data access patterns comply with Swift's concurrency model automatically.

Can I enforce unique constraints on SwiftData model properties?

Yes, use @Attribute with unique key configuration in your @Model definitions to enforce uniqueness constraints. SwiftData validates these constraints during CRUD operations and CloudKit sync, preventing duplicate data.