swiftdata-inheritance

swiftdata-inheritance is a skill for Claude Code from rshankras/claude-code-apple-skills. It costs 40 tokens per session (2,480 once invoked), scanned A, original, MIT.

SwiftData inheritance guidance explains how related model classes can share fields while representing different types. SwiftData is Apple's framework for storing and querying app data.

In plain words
What is it for?
Use it to design model hierarchies, query base types or specific subclasses, model polymorphic relationships, and migrate an inheritance structure from Core Data.
Why use it?
It helps you choose between class inheritance, enums, and protocols, and avoid mistakes with type-based queries, relationships, and schema changes.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument.

Part of the apple-skills plugin — 182 skills shipped together , and of apple-skills

Good fit Use it to design model hierarchies, query base types or specific subclasses, model polymorphic relationships, and migrate an inheritance structure from Core Data.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rshankras/claude-code-apple-skills/inheritance
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rshankras/claude-code-apple-skills --skill inheritance
Clone the repo
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills

Made for: Claude Code.

Or install apple-skills, the plugin that ships this one along with the rest of its 182 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for swiftdata-inheritance

README.md
[![agentmods](https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/inheritance/github.svg)](https://agentmods.dev/skills/rshankras/claude-code-apple-skills/inheritance)
Your own site
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/inheritance"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/inheritance/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for swiftdata-inheritance

Your own site · 80×15
<a href="https://agentmods.dev/skills/rshankras/claude-code-apple-skills/inheritance"><img src="https://agentmods.dev/badge/skills/rshankras/claude-code-apple-skills/inheritance.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,480 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00040 $0.02480
Opus 5.5 $0.00016 $0.00992
Sonnet 5.5 $0.00008 $0.00496
Haiku 4.5 $0.00004 $0.00248

Measured 1mo ago against content hash 8bbb1000ce4e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

swiftdata-inheritance scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/swiftdata/inheritance/SKILL.md · 351 lines

How it starts

The opening of the file, as written. The whole thing — 351 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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 --> 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

When to Use Inheritance

  • There is a meaningful IS-A relationship (a BusinessTrip fundamentally IS a Trip)
  • Subclasses add substantial unique stored properties
  • You need deep queries (fetch all Trip instances regardless of subtype) and shallow queries (fetch only BusinessTrip)
  • Polymorphic relationships are required (a [Trip] array holding mixed subtypes)

When to Avoid Inheritance

Read the full file on GitHub · 351 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 351 lines · 40 tokens per session scan A 8bbb1000ce4e

Subscribe to this mod's changes

swiftdata-inheritance is a skill published in the GitHub repository rshankras/claude-code-apple-skills (927 stars, last pushed 26d ago), licensed MIT. It adds 40 tokens to every session and 2,480 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-05.

Related

swiftdata-inheritance compared with skills from other repositories

swiftdata-inheritance next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
swiftdata-inheritancershankras/claude-code-apple-skillsSkill92726d agoMITA40Claude Code
migration-patternssoftspark/ai-toolkitSkill1802d agoApache-2.0A41Claude Code
1c-db-listDesko77/claude-code-skills-1cSkill103yesterdayMITA47Claude Code
flux-schematonone-ai/tononeSkill85todayMITA55Claude Code
flux-recontonone-ai/tononeSkill85todayMITA48Claude Code
spring-sessionclaude-dev-suite/claude-dev-suiteSkill514d agoMITA90Claude Code
spring-data-jpaclaude-dev-suite/claude-dev-suiteSkill514d agoMITA128Claude Code