swiftdata-pro

Writes and reviews SwiftData code against modern API rules and best practices.

1|Updated Aug 9, 2026
One-click install
npx skills add https://github.com/OMIXEC/all-in-one-swift-skills --skill swiftdata-pro-omixec
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swiftdata-pro
Source: https://github.com/OMIXEC/all-in-one-swift-skills/tree/main/skills/swiftdata-pro
Command: npx skills add https://github.com/OMIXEC/all-in-one-swift-skills --skill swiftdata-pro-omixec

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? SwiftData code often contains subtle bugs that compile cleanly but crash at runtime, such as unsafe predicates, missing delete rules, or misuse of @Query outside SwiftUI views. This Skill catches those genuine issues and writes correct, modern SwiftData code from the start. ## Core Features & Use Cases - Code Review: Audits SwiftData models, predicates, and queries against core rules covering relationships, delete rules, autosaving, and FetchDescriptor optimization, then reports findings organized by file with before/after fixes. - Predicate Safety Checks: Detects dangerous predicate patterns like isEmpty == false, regular expressions, and unsupported methods that crash at runtime. - Platform-Specific Guidance: Applies CloudKit constraints, iOS 18+ indexing, and iOS 26+ class inheritance rules only when relevant to the project. - Use Case: Ask for a review of a SwiftUI app's data layer and receive a prioritized report flagging a missing cascade delete rule that would orphan records and a predicate that would crash in production. ## Quick Start Review the SwiftData models and queries in this project and report any correctness or modern API issues with fixes.

Frequently Asked Questions about swiftdata-pro

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

FAQPage Schema
How do I review SwiftData code for common mistakes?▼

Run a review that checks core rules covering relationships, delete rules, autosaving, and FetchDescriptor usage. Findings are organized by file with the violated rule named and a before/after code fix, ending with a prioritized summary.

Why does my SwiftData predicate crash at runtime?▼

Some predicates compile cleanly but fail at runtime, such as using `isEmpty == false` instead of `!isEmpty`, regular expressions, computed properties, or @Transient properties. Predicates must rely only on data actually stored in the model.

Can I use @Query outside SwiftUI views?▼

No, @Query is designed to work only inside SwiftUI views and will not operate correctly elsewhere. In other classes, use a ModelContext with FetchDescriptor to fetch data manually.

Does SwiftData with CloudKit support unique constraints?▼

No, @Attribute(.unique) and #Unique are not supported in CloudKit and cause local data to fail too. CloudKit models also require all properties to have defaults or be optional, and all relationships must be optional.

How do I add indexes to SwiftData models in iOS 18?▼

Use the #Index macro inside your @Model class, listing key paths for single properties or compound groups, such as #Index<Article>([\.type], [\.type, \.author]). Indexes speed up reads but add a small write cost.

When should I avoid SwiftData model class inheritance?▼

Only add model subclassing on iOS 26+ when it provides a real benefit; protocols are often simpler. Deep subclassing complicates migrations, and child classes must be explicitly marked @available even when iOS 26 is the deployment target.