Skip to content
Back to skills

Swiftdata Code Review

ASecurity

Reviews SwiftData code for model design, queries, concurrency, and migrations. Use when reviewing .swift files with import SwiftData, @Model, @Query, @ModelActor, or VersionedSchema.

  • 92 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added February 8, 2026
developmentswiftcode-review

Security analysis

A100/100

Pro scans all 5 files and shows the line behind each finding

Scanned November 26, 2026

npx -y skills add existential-birds/beagle --skill swiftdata-code-review --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swiftdata Code Review?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swiftdata Code Review
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/existential-birds-swiftdata-code-review/badge)](https://www.skillsdirectory.com/skills/existential-birds-swiftdata-code-review)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swiftdata-code-review
description: "Reviews SwiftData code for model design, queries, concurrency, and migrations. Use when reviewing .swift files with import SwiftData, @Model, @Query, @ModelActor, or VersionedSchema."
---

# SwiftData Code Review

## Quick Reference

| Issue Type | Reference |
|------------|-----------|
| `@Model`, `@Attribute`, `#Unique`, `@Relationship`, delete rules | [references/model-design.md](references/model-design.md) |
| `@Query`, `#Predicate`, `FetchDescriptor`, `#Index` | [references/queries.md](references/queries.md) |
| `@ModelActor`, `ModelContext`, background operations, DTOs | [references/concurrency.md](references/concurrency.md) |
| `VersionedSchema`, `MigrationStage`, lightweight/custom | [references/migrations.md](references/migrations.md) |

## Hard gates (before reporting findings)

Run in order; do not assert an issue until the gate for that issue passes.

1. **Scope — pass when:** You have the target `.swift` path(s) and confirmed SwiftData surface in scope (e.g. `import SwiftData`, `@Model`, `@Query`, `@ModelActor`, `VersionedSchema`, or migration types). If none apply, stop or narrow scope with one sentence.
2. **Reference — pass when:** For each checklist area you evaluate (models, queries, concurrency, migrations), you opened the matching `references/*.md` from the Quick Reference table **or** wrote `N/A: no <area> in this review` with a one-line reason.
3. **Evidence & protocol — pass when:** Every finding satisfies `review-verification-protocol` ([review-verification-protocol](../review-verification-protocol/SKILL.md)) and uses the `[FILE:LINE] ISSUE_TITLE` header (line range allowed) from the file you read; no finding without a cite.
4. **Report — pass when:** Findings list cites first (or inline) using `[FILE:LINE] ISSUE_TITLE`, then severity or checklist grouping—no uncited assertions.

## Review Checklist

- [ ] Models marked `final` on iOS 17–18 (or when inheritance is not intended; iOS 26+ supports `@Model` subclassing)
- [ ] `@Relationship` decorator on ONE side only (not both)
- [ ] Delete rules explicitly set (not relying on default `.nullify`)
- [ ] Relationships initialized to empty arrays (`= []`), not default model objects
- [ ] No `@Attribute(.unique)` or `#Unique` (iOS 18+) if CloudKit sync is enabled
- [ ] Batch operations used for bulk inserts (`append(contentsOf:)`)
- [ ] `@Query` not loading thousands of items on main thread
- [ ] External values in predicates captured in local variables (including inside `init()`)
- [ ] Scalar comparisons in predicates (not object references)
- [ ] `@ModelActor` used for background operations (created off `@MainActor`)
- [ ] `PersistentIdentifier` or `Sendable` DTOs used to pass data between actors (never `@Model` instances)
- [ ] `VersionedSchema` defined for each shipped version and `MigrationPlan` passed to `ModelContainer`

## When to Load References

- Reviewing `@Model`, `#Unique`, or relationships -> [references/model-design.md](references/model-design.md)
- Reviewing `@Query`, `#Predicate`, or `#Index` -> [references/queries.md](references/queries.md)
- Reviewing `@ModelActor` or background work -> [references/concurrency.md](references/concurrency.md)
- Reviewing schema changes or migrations -> [references/migrations.md](references/migrations.md)

## Review Questions

1. Could this relationship assignment cause NULL foreign keys?
2. Is `@Relationship` on both sides creating circular references?
3. Could this `@Query` block the main thread with large datasets?
4. Are `@Model` objects being passed across actor boundaries instead of `PersistentIdentifier` or `Sendable` DTOs?
5. Would schema changes require a `VersionedSchema` and `SchemaMigrationPlan`?

Files in this skill

  • SKILL.md2 KB
  • references/concurrency.md4.3 KB
  • references/migrations.md4.8 KB
  • references/model-design.md3.3 KB
  • references/queries.md3.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.