audit-swiftui-swiftdata

Audits macOS SwiftUI SwiftData code for correctness defects, API currency, and production conventions.

2|1|Updated Jun 7, 2026
One-click install
npx skills add https://github.com/yigitkonur/plugin-swiftui --skill audit-swiftui-swiftdata-yigitkonur
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: audit-swiftui-swiftdata
Source: https://github.com/yigitkonur/plugin-swiftui/tree/main/plugins/swiftui/skills/audit-swiftui-swiftdata
Command: npx skills add https://github.com/yigitkonur/plugin-swiftui --skill audit-swiftui-swiftdata-yigitkonur

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ast-grep, and includes scripts (resource) and references (resource) components.

What problem does it solve? SwiftData code often compiles cleanly yet crashes at runtime or silently loses data because Swift-language semantics are overridden by the Core Data machinery underneath, and Apple's own samples ship incomplete or non-compiling patterns. This Skill audits a macOS SwiftUI project to detect twelve specific SwiftData defects — from let on relationships to fatalError on ModelContainer — and fixes the one mechanical defect automatically. ## Core Features & Use Cases - Twelve-rule defect index (sd-01 to sd-12): Detects relationship mutability crashes, init-assignment data loss, missing initializers, the positional @Relationship(.cascade) type error, non-optional to-one traps, preview container crashes, off-actor mutation races, and missing save() calls. - Hybrid lint engine: Combines tier-1 grep tells with tier-2 ast-grep structural rules that express patterns grep cannot, emitting unified JSON and SARIF output with a CI gate on hard-fail findings. - Evidence-grounded verification: Cross-checks uncertain findings against a corpus of 1,857 real shipping macOS apps via the swiftui-ctx CLI and Apple documentation via Sosumi before reporting. - Use Case: Point the Skill at an in-progress macOS SwiftUI app using SwiftData; it locates candidates, reads each file in full, reports only 100%-certain findings to swiftui-audits/swiftdata/, and auto-fixes the @Relationship(.cascade) error under a fix-safety protocol. ## Quick Start Audit the SwiftData layer of my macOS SwiftUI project in the current directory and write findings to the swiftui-audits folder.

Frequently Asked Questions about audit-swiftui-swiftdata

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I audit SwiftData code in a macOS SwiftUI project?

Run the shared lint runner with --skill audit-swiftui-swiftdata against your source directory to locate candidates via grep and ast-grep rules. Then read each located file in full, since the engine only locates and never confirms findings.

What SwiftData bugs does this audit detect?

It detects twelve defects: let on relationships, relationships assigned in init, missing @Model initializers, the positional @Relationship(.cascade) type error, non-optional to-one relationships, preview container crashes, fatalError on ModelContainer, unordered relationship arrays, off-actor mutation, missing save() calls, ungated macOS-26 @Model subclasses, and unserialized multi-process containers.

Why does SwiftData code compile but crash at runtime?

SwiftData is a macro facade over Core Data, so Swift semantics like let immutability and non-optional types are silently overridden by the underlying machinery. The compiler stays silent while a let relationship crashes via a KeyPath cast failure or a non-optional to-one relationship nil-unwraps.

Does the audit fix SwiftData issues automatically?

Only one defect is auto-fixed: the positional @Relationship(.cascade) is rewritten to the named @Relationship(deleteRule: .cascade) under a fix-safety protocol. All other findings are flag-only, showing the correct shape for the developer to apply.

Can I use this audit for Core Data or iOS projects?

No, the audit is macOS-only and SwiftUI-only. Raw Core Data with NSManagedObject or NSPersistentContainer is explicitly out of scope and only noted in one line if encountered.

What macOS version does SwiftData require?

Core SwiftData APIs like @Model, @Relationship, @Query, and ModelContext require macOS 14.0 or later. The variadic ModelContainer init and #Index/#Unique need macOS 15, while @Model class inheritance requires macOS 26.