swiftdata · dpearson2699 — Claude Code skill: SwiftData models, queries
Gives the agent a working reference for SwiftData so persistence code on Swift 6.3 comes out right the first time.
npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a claude-codeWhat swiftdata does
The skill loads a guide the agent reads before touching your data layer. It covers @Model classes, @Attribute options such as .externalStorage and .unique, delete rules on @Relationship, and compound keys declared with #Unique. Separate sections handle @Query in SwiftUI, #Predicate, FetchDescriptor, plus schema versioning with VersionedSchema and SchemaMigrationPlan.
CloudKit gets its own treatment. Before advising on sync, the agent checks that the target has the iCloud capability with CloudKit and the right container, and that Background Modes includes remote notifications. It also flags schema traits that break sync. Model objects stay tied to their context and actor, so the guide has you pass a PersistentIdentifier across actors instead of the instance.
The requirements are iOS 26+ and Swift 6.3. Model inheritance and the newer syntax will not build on older toolchains. For background work there is a @ModelActor section. Batch deletes deserve care: the skill tells you to run the exact predicate against a throwaway copy of the store first, then refetch and check counts, because a wrong #Predicate removes rows you meant to keep.
What it helps with
- declare a model with external storage for images and cascade deletes on a relationship
- filter a SwiftUI list by a search string through
#Predicate - move a store to a new schema version without dropping user data
- turn on CloudKit sync and confirm the schema allows it
- run writes on a background actor without passing model objects between threads
Example prompts for the agent
- Write a
@ModelclassTripwith a name, destination, start and end dates, and a cascade-deleting relationship to accommodation - Build a SwiftUI screen that lists favorite trips via
@Query, sorted bystartDatedescending - Plan a store migration using
VersionedSchemaandSchemaMigrationPlan
How to install swiftdata
1Skills CLI (Vercel)
npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a claude-code2Manually: put the files in place
~/.claude/skills/swiftdata/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/swiftdata/
1Skills CLI (Vercel)
npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a codex2Manually: put the files in place
.agents/skills/swiftdata/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a cursor2Manually: put the files in place
.cursor/skills/swiftdata/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install dpearson2699/swift-ios-skills swiftdata2Manually: put the files in place
.github/skills/swiftdata/SKILL.md1Skills CLI (Vercel)
npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a gemini-cli2Platform CLI
gemini skills install https://github.com/dpearson2699/swift-ios-skills --path skills/swiftdataManually: put the files in place
.devin/skills/swiftdata/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about swiftdata
How do I install swiftdata in Claude Code?
Run npx skills add dpearson2699/swift-ios-skills --skill swiftdata -a claude-code. The skill file lands at ~/.claude/skills/swiftdata/SKILL.md.
What does the swiftdata skill do?
It hands the agent code samples and a review checklist for SwiftData: models, relationships, queries, the container, migrations and CloudKit sync. The agent leans on them when writing or auditing your persistence layer.
Which iOS and Swift versions does it target?
iOS 26+ with Swift 6.3. Model inheritance and the related syntax will not compile on earlier toolchains.
Similar skills
Everything for Mobile →swiftdata by other authors comes first.