swiftdata-pro

Write, review, and improve SwiftData code using modern APIs and best practices. Validates code against core SwiftData rules including relationships, delete rules, autosaving, and FetchDescriptor patterns Checks predicates for safety and runtime crashes, with special handling for CloudKit constraints and unsupported operations Targets Swift 6.2+ with modern concurrency; recommends indexing strategies for iOS 18+ and class inheritance patterns for iOS 26+ Reports only genuine issues without nitpicking; organizes findings by file with before/after code examples and prioritized impact summary

INSTALLATION
npx skills add https://github.com/twostraws/swiftdata-agent-skill --skill swiftdata-pro
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$29

Output Format

If the user asks for a review, organize findings by file. For each issue:

  • State the file and relevant line(s).
  • Name the rule being violated.
  • 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.

// 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.**

// 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.**

// Before

class DestinationStore {

    @Query var destinations: [Destination]

}

// After

class DestinationStore {

    var modelContext: ModelContext

    func fetchDestinations() throws -> [Destination] {

        try modelContext.fetch(FetchDescriptor<Destination>())

    }

}

Summary

  • Data loss (high): Missing delete rule on line 8 of Destination.swift means sights will be orphaned when a destination is deleted.
  • Crash (high): isEmpty == false on line 22 will crash at runtime – use !isEmpty instead.
  • 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.
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card