Agent skill · AI & Agents

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.

rshankrasgithub.com/rshankrasGitHub ↗
claude-coderead-onlyMIT
Install
npx skills add rshankras/claude-code-apple-skills --skill inheritance --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 11 KB
Bundled scripts: none
Allowed tools: ReadGlobGrep
Path: skills/swiftdata/inheritance/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 589
Language: Swift

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# 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

What's inside
Steps it walks through
  1. When This Skill Activates
  2. Decision Tree
  3. When to Use Inheritance
  4. When to Avoid Inheritance
  5. API Patterns
  6. Base Model Declaration
  7. Subclass Declaration
  8. Relationships Across the Hierarchy
  9. ModelContainer Configuration
  10. Querying Hierarchies
  11. Deep Query (All Subclasses)
  12. Type Filtering with Predicate
  13. Subclass Property Filtering
  14. Enum-Based Filter Switching in UI
More from claude-code-apple-skills
All skills →
About this skill
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.

Keep going