swiftdata-inheritance
SwiftData class inheritance patterns for hierarchical models with type-based querying, polymorphic relationships, and when to choose inheritance vs enums. Use when designing SwiftData model hierarchies.
npx skills add rshankras/claude-code-apple-skills --skill inheritance --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# SwiftData Class Inheritance 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. ## When This Skill Activates - User is designing a SwiftData model hierarchy with shared base properties - User asks about `@Model` on subclasses or how inheritance works in SwiftData - User needs to query across a type hierarchy (all trips vs only business trips) - User is deciding between inheritance, enums, or protocols for model variants - User has issues with polymorphic relationships or type casting in SwiftData - User is migrating a Core Data inheritance hierarchy to SwiftData ## Decision Tree ``` Do 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 --> Inherit
- When This Skill Activates
- Decision Tree
- When to Use Inheritance
- When to Avoid Inheritance
- API Patterns
- Base Model Declaration
- Subclass Declaration
- Relationships Across the Hierarchy
- ModelContainer Configuration
- Querying Hierarchies
- Deep Query (All Subclasses)
- Type Filtering with Predicate
- Subclass Property Filtering
- Enum-Based Filter Switching in UI
What does the swiftdata-inheritance skill do?
SwiftData class inheritance patterns for hierarchical models with type-based querying, polymorphic relationships, and when to choose inheritance vs enums. Use when designing SwiftData model hierarchies.
How do I install it?
Run `npx skills add rshankras/claude-code-apple-skills --skill inheritance --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From rshankras/claude-code-apple-skills, a repository with 589 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
