swiftdata

Document SwiftData APIs for persistent models, contexts, and queries.

299|16|Updated Feb 19, 2026
One-click install
npx skills add https://github.com/Prisma-Labs-Dev/apple-skills --skill swiftdata-prisma-labs-dev
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftdata
Source: https://github.com/Prisma-Labs-Dev/apple-skills/tree/main/skills/swiftdata
Command: npx skills add https://github.com/Prisma-Labs-Dev/apple-skills --skill swiftdata-prisma-labs-dev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the complexity of managing persistent data in iOS applications by providing instant access to SwiftData API references, macro definitions, and best practices for model lifecycle management.

Core Features & Use Cases

  • Model Definition: Quickly look up syntax for @Model, @Attribute, and @Relationship macros to define your data schema.
  • Context Management: Understand how to use ModelContext for CRUD operations, autosave, and transaction handling.
  • Querying: Learn how to implement the @Query macro for efficient, reactive data fetching in SwiftUI views.

Quick Start

Ask the agent to explain how to define a new persistent model using the Model macro and the required property wrappers.

Frequently Asked Questions about swiftdata

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

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

Define SwiftData persistent models using the @Model macro, and use @Attribute and @Relationship macros to configure schema details and data relationships within your iOS applications.

How does the @Query macro work for fetching data in SwiftUI?

The @Query macro enables efficient, reactive data fetching in SwiftUI views by automatically observing your SwiftData model context and updating the UI when persistent data changes.

What is the best way to manage CRUD operations and transactions with ModelContext?

Manage CRUD operations and transaction handling in SwiftData by utilizing ModelContext, which controls autosave behavior and orchestrates the lifecycle of your persistent data objects.

Does SwiftData support schema migration for existing iOS app data?

SwiftData supports schema migration by adhering to Apple's recommended patterns, allowing you to update your persistent models and manage data relationships safely across application versions.

How do I handle concurrency and data relationships in a SwiftData application?

Handle SwiftData concurrency and data relationships by following Apple's recommended patterns for model lifecycle management, ensuring safe concurrent access to your persistent model contexts.