swiftdata

Provide SwiftData persistence patterns for @Model, @Query, and ModelContainer configuration.

1|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/makgunay/claude-swift-skills --skill swiftdata-makgunay
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swiftdata
Source: https://github.com/makgunay/claude-swift-skills/tree/main/swiftdata
Command: npx skills add https://github.com/makgunay/claude-swift-skills --skill swiftdata-makgunay

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides comprehensive guidance and patterns for implementing robust data persistence in macOS and iOS applications using SwiftData, preventing common LLM errors and ensuring correct API usage.

Core Features & Use Cases

  • Model Definition: Learn to define @Model classes, including relationships with delete rules and @Attribute options.
  • Querying: Master @Query and #Predicate for efficient data retrieval, including filtering with type-based predicates and handling inheritance.
  • Configuration & Migrations: Understand ModelContainer and ModelContext setup, and strategies for schema migrations.
  • Use Case: Implement a complex data model for a note-taking app, ensuring all relationships are correctly defined and queries efficiently retrieve specific types of notes with their associated data.

Quick Start

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

Frequently Asked Questions about swiftdata

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

FAQPage Schema
How do I define data models in SwiftData for iOS and macOS apps?

SwiftData data models are defined using the @Model class macro. You can specify properties, configure relationships with delete rules, and apply @Attribute options to customize persistence behavior for your iOS and macOS applications.

How do I query and filter data using SwiftData?

SwiftData querying uses @Query and #Predicate for efficient data retrieval. You can filter results with type-based predicates, handle class inheritance, and manage polymorphic relationships to fetch specific data subsets.

Does SwiftData support schema migrations and ModelContainer configuration?

SwiftData supports schema migrations through ModelContainer and ModelContext configuration. You can set up your persistence stack and implement migration strategies to handle evolving data models across app versions.

Why is my LLM generating incorrect Core Data syntax instead of SwiftData APIs?

LLMs often generate incorrect Core Data syntax or invent non-existent SwiftData APIs due to training data overlap. Using dedicated SwiftData patterns for @Model, @Query, and ModelContext ensures correct API usage and prevents these common errors.

Can I use class inheritance and polymorphic relationships with SwiftData persistence?

SwiftData persistence supports class inheritance and polymorphic relationships. You can define hierarchical @Model structures and use type-based predicates to query specific subclasses within your data model.