swift_data

Define SwiftData models with @Model and perform CRUD operations.

2|2|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/onmyway133/skills --skill swift-data-onmyway133
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift_data
Source: https://github.com/onmyway133/skills/tree/main/skills/swift-data
Command: npx skills add https://github.com/onmyway133/skills --skill swift-data-onmyway133

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the process of managing data persistence in Swift applications, enabling developers to efficiently store, retrieve, and synchronize data across devices.

Core Features & Use Cases

  • Model Definition: Define persistent data models using the @Model macro.
  • Data Operations: Perform Create, Read, Update, and Delete (CRUD) operations seamlessly.
  • CloudKit Sync: Enable automatic data synchronization across iCloud.
  • Use Case: You are building a note-taking app and need to store user notes locally and sync them to iCloud. This Skill provides the patterns to define your Note model, set up the ModelContainer, and ensure data is saved and synced correctly.

Quick Start

Use the swift_data skill to define a new @Model class for a 'Book' with 'title' and 'author' properties.

Frequently Asked Questions about swift_data

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

FAQPage Schema
How do I define a data model in SwiftData?

SwiftData defines persistent data models using the @Model macro. You apply this macro to your Swift class to automatically enable persistence for its properties, allowing the framework to manage your data storage.

How do I sync SwiftData with iCloud?

SwiftData integrates with CloudKit to enable automatic data synchronization across iCloud. You configure your ModelContainer to support cloud-based storage, ensuring local data is continuously synced to user devices.

How do I perform CRUD operations in SwiftData?

SwiftData handles CRUD operations by managing model instances within the ModelContainer context. You insert objects to create, fetch descriptors to read, mutate properties to update, and delete to remove data.

How does SwiftData handle relationship management?

SwiftData manages relationships by referencing other @Model classes within your model definitions. You configure relationship properties to establish connections, while the framework maintains data integrity during CRUD operations.

What are the migration strategies for SwiftData?

SwiftData supports migration strategies to handle evolving data schemas across app versions. You implement migration plans to version your models, ensuring robust data preservation when updating application structures.

Can I use SwiftData with SwiftUI?

SwiftData works seamlessly with SwiftUI to manage data persistence in iOS applications. You provide the ModelContainer to your SwiftUI views, enabling automatic UI updates when underlying data models change.