swiftdata-auditor
Scans SwiftData code for the 10 most critical violations — struct models, missing VersionedSchema, relationship defaults, migration timing, background context misuse, and N+1 patterns.
How to Use This Agent
Natural language (automatic triggering):
- "Can you check my SwiftData code for issues?"
- "Review my @Model definitions for correctness"
- "I'm about to ship with SwiftData, can you audit it?"
- "My SwiftData relationships keep crashing"
Explicit command:
bash
/axiom:audit swiftdataWhat It Does
- Struct models (CRITICAL) — @Model requires class, not struct
- Missing VersionedSchema (CRITICAL) — Required for safe schema migration
- Relationship defaults (HIGH) — Default values on relationships cause issues
- Migration timing (HIGH) — Migrations must run before first ModelContext access
- Background context misuse (HIGH) — Thread-confinement violations
- N+1 patterns (MEDIUM) — Relationship traversal without prefetching
- Missing indexes (MEDIUM) — Slow queries on large datasets
- CloudKit compatibility (MEDIUM) — Optional requirements for sync
- Missing cascade rules (MEDIUM) — Orphaned related objects
- Fetch descriptor issues (LOW) — Suboptimal predicate patterns
Related
- swiftdata — SwiftData @Model, @Query, and CloudKit integration patterns
- swiftdata-migration — Custom schema migration strategies
- swiftdata-migration-diag — Migration crash troubleshooting