swiftdata-pro — Claude Code skill: SwiftData code review
A skill for writing, reviewing, and improving SwiftData code with modern APIs and best practices. Essential when working with SwiftData-based projects in Swift.
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-codeWhat swiftdata-pro does
swiftdata-pro reviews SwiftData code across five areas: core framework rules, predicate safety and supported operations, CloudKit-specific constraints, indexing opportunities for iOS 18+, and class inheritance patterns for iOS 26+. It loads only relevant reference files — if your project doesn't use CloudKit, that check doesn't run.
The skill identifies genuine issues rather than stylistic quibbles. It checks for missing delete rules on relationships, correct use of @Query inside SwiftUI views, predicates that crash at runtime (like isEmpty == false), and proper project structure. You can ask it to fix code directly or report problems file by file with before-and-after examples.
The skill targets Swift 6.2 and won't suggest Core Data over SwiftData without your permission. It doesn't add third-party frameworks on its own.
What it helps with
- Review SwiftData code for modern API usage and best practices compliance
- Find predicate errors that cause runtime crashes
- Ensure delete rules and relationships are correctly configured
- Optimize indexing for iOS 18+
- Validate CloudKit-specific model constraints
Example prompts for the agent
- Review the code in `DestinationListView.swift` for SwiftData errors
- Use the swiftdata-pro skill to refactor models in this project according to best practices
- Check the predicates in this file — any dangerous patterns lurking?
How to install swiftdata-pro
1Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-code2Manually: put the files in place
~/.claude/skills/swiftdata-pro/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/swiftdata-pro/
1Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a codex2Manually: put the files in place
.agents/skills/swiftdata-pro/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a cursor2Manually: put the files in place
.cursor/skills/swiftdata-pro/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install twostraws/SwiftData-Agent-Skill swiftdata-pro2Manually: put the files in place
.github/skills/swiftdata-pro/SKILL.md1Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a gemini-cli2Platform CLI
gemini skills install https://github.com/twostraws/SwiftData-Agent-Skill --path swiftdata-proManually: put the files in place
.devin/skills/swiftdata-pro/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Similar
Questions about swiftdata-pro
How do I install swiftdata-pro in Claude Code?
Run npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-code, then open ~/.claude/skills/swiftdata-pro/SKILL.md. For Cursor, use npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a cursor with .cursor/skills/swiftdata-pro/SKILL.md.
What does swiftdata-pro do?
It analyzes and improves SwiftData code by checking predicates for unsafe patterns, verifying relationships and delete rules, validating CloudKit-specific constraints, and identifying indexing opportunities for iOS 18+. It finds real errors and shows code examples for each fix.
How does the skill handle CloudKit?
If your project uses CloudKit, swiftdata-pro adds checks for field uniqueness, optionality constraints, and eventual consistency implications. For projects without CloudKit, this validation is skipped.
Source text
SKILL.md · MIT
---
name: swiftdata-pro
description: Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData.
license: MIT
metadata:
author: Paul Hudson
version: "1.0"
---
Write and review SwiftData code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues.
Review process:
1. Check for core SwiftData issues using `references/core-rules.md`.
1. Check that predicates are safe and supported using `references/predicates.md`.
1. If the project uses CloudKit, check for CloudKit-specific constraints using `references/cloudkit.md`.
1. If the project targets iOS 18+, check for indexing opportunities using `references/indexing.md`.
1. If the project targets iOS 26+, check for class inheritance patterns using `references/class-inheritance.md`.
If doing partial work, load only the relevant reference files.
## Core Instructions
- Target Swift 6.2 or later, using modern Swift concurrency.
- The user strongly prefers to use SwiftData across the board. Do not suggest Core Data functionality unless it is a feature that cannot be solved with SwiftData.
- Do not introduce third-party frameworks without asking first.
- Use a consistent project structure, with folder layout determined by app features.
## Output Format
If the user asks for a review, organize findings by file. For each issue:
1. State the file and relevant line(s).
2. Name the rule being violated.
3. Show a brief before/after code fix.
Skip files with no issues. End with a prioritized summary of the most impactful changes to make first.
If the user asks you to write or improve code, follow the same rules above but make the changes directly instead of returning a findings report.
Example output:
### Destination.swift
**Line 8: Add an explicit delete rule for relationships.**
```swift
// Before
var sights: [Sight]
// After
@Relationship(deleteRule: .cascade, inverse: \Sight.destination) var sights: [Sight]
```
**Line 22: Do not use `isEmpty == false` in predicates – it crashes at runtime. Use `!` instead.**
```swift
// Before
#Predicate<Destination> { $0.sights.isEmpty == false }
// After
#Predicate<Destination> { !$0.sights.isEmpty }
```
### DestinationListView.swift
**Line 5: `@Query` must only be used inside SwiftUI views.**
```swift
// Before
class DestinationStore {
@Query var destinations: [Destination]
}
// After
class DestinationStore {
var modelContext: ModelContext
func fetchDestinations() throws -> [Destination] {
try modelContext.fetch(FetchDescriptor<Destination>())
}
}
```
### Summary
1. **Data loss (high):** Missing delete rule on line 8 of Destination.swift means sights will be orphaned when a destination is deleted.
2. **Crash (high):** `isEmpty == false` on line 22 will crash at runtime – use `!isEmpty` instead.
3. **Incorrect behavior (high):** `@Query` on line 5 of DestinationListView.swift only works inside SwiftUI views.
End of example.
## References
- `references/core-rules.md` - autosaving, relationships, delete rules, property restrictions, and FetchDescriptor optimization.
- `references/predicates.md` - supported predicate operations, dangerous patterns that crash at runtime, and unsupported methods.
- `references/cloudkit.md` - CloudKit-specific constraints including uniqueness, optionality, and eventual consistency.
- `references/indexing.md` - database indexing for iOS 18+, including single and compound property indexes.
- `references/class-inheritance.md` - model subclassing for iOS 26+, including @available requirements, schema setup, and predicate filtering.
© Paul Hudson · MIT · twostraws/SwiftData-Agent-Skill