Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-code
Open on GitHub

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

2Manually: put the files in place

~/.claude/skills/swiftdata-pro/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/swiftdata-pro/

Similar

mcp-security-audit official github Audits MCP server configurations for exposed secrets, shell injection, mutable package references, and unapproved servers. Use it before changing .mcp.json. GitHub Copilot 1,100installs arize-trace official arize Export Arize traces and spans by ID, then inspect them to investigate errors or LLM app behavior. Use it when you need to examine trace data already collected. GitHub Copilot 1,100installs dart-use-path-package flutter Teaches the agent to handle Dart file paths via package:path, avoiding string operations that break on Windows. Claude Code CX Codex Cursor +1 5,900installs lint-and-validate sickn33 Runs configured linters and type checkers after code changes, telling actual failures apart from tools that never ran. Claude Code CX Codex Cursor +1 1,300installs architect-review sickn33 Turns the agent into an architecture reviewer: it weighs design decisions, names the risks and tradeoffs, and asks for a validation plan. Claude Code CX Codex Cursor +1 1,300installs vulnerability-scanner sickn33 Guides AI agents through vulnerability assessments using OWASP 2025 standards and attack surface mapping. Useful during pre-release security reviews. Claude Code CX Codex Cursor +1 1,300installs improve-codebase-architecture Matt Pocock This skill scans a codebase for architectural friction, then builds a visual HTML report with refactoring candidates. Use it before a deeper architecture review. Claude Code 1,163,035installs tdd Matt Pocock Guides the red-green TDD loop: ensures tests are written first, keep them at public interfaces, and avoid coupling to implementation details. Claude Code 1,141,062installs

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

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor