swiftdata-pro

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

70|4|Updated Jul 22, 2025
One-click install
npx skills add https://github.com/AlexW00/Zettel --skill swiftdata-pro-alexw00
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: swiftdata-pro
Source: https://github.com/AlexW00/Zettel/tree/main/.agents/skills/swiftdata-pro
Command: npx skills add https://github.com/AlexW00/Zettel --skill swiftdata-pro-alexw00

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? SwiftData code often compiles but crashes at runtime due to unsupported predicates, missing delete rules, or incorrect relationship definitions. This Skill catches those genuine issues when writing or reviewing SwiftData code, without nitpicking or inventing problems. ## Core Features & Use Cases - Code Review: Audits SwiftData models, predicates, and queries against core rules covering autosaving, relationships, delete rules, and FetchDescriptor optimization, then reports findings organized by file with before/after fixes. - Predicate Safety Checks: Detects dangerous predicate patterns that compile but crash at runtime, such as isEmpty == false, regular expressions, and unsupported methods like hasPrefix(). - Platform-Specific Guidance: Applies CloudKit constraints, iOS 18+ indexing, and iOS 26+ class inheritance rules only when relevant to the project's deployment targets. - Use Case: Ask for a review of your SwiftData models before shipping, and receive a prioritized report flagging data-loss risks, runtime crashes, and incorrect @Query usage with concrete fixes. ## Quick Start Use swiftdata-pro to review the SwiftData models and queries in my project and report any issues.

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 SwiftData review that checks core rules covering autosaving, relationship delete rules, property restrictions, and FetchDescriptor optimization. Findings are organized by file with the violated rule and a before/after code fix, ending in 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 of 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. All properties must have default values or be optional, and all relationships must be optional.

Does SwiftData support model class inheritance?▼

Yes, starting with iOS 26 and coordinated releases, SwiftData supports model subclassing. Child classes must be marked `@available` for the 26 release, both parent and child need `@Model`, and all classes must be listed in the schema.