Install any skill in seconds. Free to start, no credit card required.
Get Started Free →rshankras/swiftdata-inheritance
SwiftData class inheritance patterns for hierarchical models with type-based querying, polymorphic relationships, and when to choose inheritance vs enums.
Passed 21 of 22 test cases with the skill, and 15 of 22 without it.
and 5 more in the full report
6 fixed15 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 6 test cases the skill fixed. Same model, same prompt, with and without the skill.
I have a base `@Model class Account` and subclasses `@Model class SavingsAccount` and `@Model class CheckingAccount`. I want a `#Predicate` for fetching only `SavingsAccount` instances from a `FetchDescriptor<Account>`. How do I write this predicate?
| Checked | Without skill | With skill |
|---|---|---|
| The `#Predicate` uses `is SavingsAccount` or type casting (`as? SavingsAccount`) to filter records. | Missed | Passed |
The instructions your model reads when the skill loads.
Guide for implementing class inheritance in SwiftData models. Covers when to use inheritance versus enums or protocols, how to annotate subclasses, query across hierarchies, and avoid common pitfalls with schema migrations and relationship modeling.
@Model on subclasses or how inheritance works in SwiftDataDo your model variants share a common identity and most properties?
|
+-- YES: Clear IS-A relationship (BusinessTrip IS-A Trip)
| |
| +-- Subclasses add significant unique properties or behavior?
| | +-- YES --> Use class inheritance (this skill)
| | +-- NO, just 1-2 distinguishing fields --> Use enum property on base model
| |
| +-- Need to query "all trips" AND "only business trips"?
| +-- YES --> Inheritance gives you both for free
| +-- Only one type at a time --> Enum filter is simpler
|
+-- NO: Models share only a few properties
| +-- Use protocol conformance (no SwiftData inheritance needed)
|
+-- UNCERTAIN: Could go either way
+-- Prefer enum on base model (simpler schema, easier migrations)
+-- Promote to inheritance later if variants diverge significantly
BusinessTrip fundamentally IS a Trip)test cases passed, vs 15 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.