swiftdata
Expert guidance for designing, writing, reviewing, and debugging SwiftData persistence in Swift and SwiftUI apps.
Skill by ducko-im
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ducko-im-swiftdata
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: data, writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/swiftdata
What's inside
- Skill name
swiftdata- Description
- Expert guidance for designing, writing, reviewing, and debugging SwiftData persistence in Swift and SwiftUI apps. Use when working with @Model schemas, @Relationship/@Attribute rules, @Query or FetchDescriptor data access, ModelContainer/ModelContext configuration, SchemaMigrationPlan/history APIs, ModelActor concurrency isolation, CloudKit sync, or Core Data adoption/coexistence.
- License
- MIT
- Instructions
- 254 lines in SKILL.md · view on GitHub
Before installing
- Instructions call the network
Files (16)
- SKILL.md
- class-inheritance.md · references/
- cloudkit-sync.md · references/
- cloudkit.md · references/
- concurrency-and-actors.md · references/
- core-data-adoption.md · references/
- core-rules.md · references/
- implementation-playbooks.md · references/
- indexing.md · references/
- migrations-and-history.md · references/
- model-context-and-lifecycle.md · references/
- modeling-and-schema.md · references/
- predicates.md · references/
- querying-and-fetching.md · references/
- relationships-and-inheritance.md · references/
- troubleshooting-and-updates.md · references/
SKILL.md (first lines)
Write and review SwiftData code for correctness, modern API usage, data integrity, migration safety, sync correctness, and predictable concurrency behavior. Report only genuine problems — do not nitpick or invent issues.
Review process:
1. Check for core SwiftData issues using [references/core-rules.md](references/core-rules.md).
2. Check `@Model` shape, attributes, and uniqueness using [references/modeling-and-schema.md](references/modeling-and-schema.md).
3. Check context lifecycle, inserts, saves, and undo using [references/model-context-and-lifecycle.md](references/model-context-and-lifecycle.md).
4. Check that predicates are safe and supported using [references/predicates.md](references/predicates.md).
5. Check filtering/sorting/query patterns using [references/querying-and-fetching.md](references/querying-and-fetching.md).
6. Check relationships and (iOS 26+) inheritance using [references/relationships-and-inheritance.md](references/relationships-and-inheritance.md) and [references/class-inheritance.md](references/class-inheritance.md).
7. If schema changes are in scope, check migration safety using [references/migrations-and-history.md](references/migrations-and-history.md).
8. If the project uses CloudKit, check CloudKit constraints using [references/cloudkit.md](references/cloudkit.md) and sync behavior using [references/cloudkit-sync.md](references/cloudkit-sync.md).
9. If the project targets iOS 18+, check for indexing opportunities using [references/indexing.md](references/indexing.md).
10. If any work runs off the main actor, check isolation using [references/concurrency-and-actors.md](references/concurrency-and-actors.md).
11. If coexisting with Core Data, check adoption strategy using [references/core-data-adoption.md](references/core-data-adoption.md).
12. For diagnostics and API availability checks, use [references/troubleshooting-and-updates.md](references/troubleshooting-and-updates.md).
13. For end-to-end execution examples, use [references/implementation-playbooks.md](references/implementation-playbooks.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 SwiftData. 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.
- Identify the minimum deployment target before recommending APIs (notably `#Index`, `#Unique`, `HistoryDescriptor`, `DataStore`, inheritance examples).
- Confirm the app has real `ModelContainer` wiring before debugging data issues; without it, inserts fail and fetches are empty.
- Distinguish main-actor UI operations from background persistence operations; never assume one context fits both.
- Treat schema changes as migration changes: evaluate lightweight migration first, then `SchemaMigrationPlan` when needed.
- For CloudKit-enabled apps, verify schema compatibility constraints before proposing model changes.
- Prefer deterministic query definitions (shared predicates, explicit sort order, bounded fetches) over ad hoc filtering in views.
- Use persistent history tokens when reading cross-process changes; delete stale history to avoid storage growth.
- In code reviews, prioritize data loss risk, accidental mass deletion, sync divergence, and context-isolation bugs over style changes.
## Project Intake (Before Advising)
- Deployment targets for iOS, iPadOS, macOS, watchOS, and visionOS.
- Container setup: `.modelContainer(...)` modifier or manual `ModelContainer(...)`.
- Autosave expectations and whether explicit `save()` is required.
- Undo enablement (`isUndoEnabled`) and whether operations occur on `mainContext` or custom contexts.
- CloudKit capabilities and chosen container strategy (`automatic`, `.private(...)`, `.none`).
- App group storage requirements.
- Core Data coexistence in scope.
- Whether schema changes must be backward-compatible with existing user data.
Quick analysis commands:
- Container setup: `rg "modelContainer\(|ModelContainer\(" -n`
- Model definitions: `rg "^@Model|#Unique|#Index|@Relationship|@Attribute|@Transient" -n`
- Context usage: `rg "modelContext|mainContext|ModelContext\(" -n`
- Migrations and history: `rg "SchemaMigrationPlan|VersionedSchema|MigrationStage|fetchHistory|deleteHistory|historyToken" -n`
- CloudKit and app groups: `rg "cloudKitDatabase|iCloud|CloudKit|groupContainer|AppGroup|NSPersistentCloudKitContainer" -n`
## Triage-First Playbook
Common problems → next best move:
- **Insert fails or fetch is always empty** → confirm `.modelContainer(...)` is attached at app or window root and the model type is included.
- **Duplicate rows after network refresh** → add `@Attribute(.unique)` or `#Unique` constraints and rely on insert-upsert behavior.
- **Unexpected data loss during delete** → audit delete rules (`.cascade` vs `.nullify`) and check for unbounded `delete(model:where:)`.
- **Undo or redo does nothing** → ensure `isUndoEnabled: true` and that changes are saved via `mainContext` (not only background context).
- **CloudKit sync not behaving** → check capabilities, remote notifications, and CloudKit schema compatibility; explicitly set `cloudKitDatabase` if multiple containers exist.
- **Widget or App Intent changes not reflected** → use persistent history (`fetchHistory`) with token + author filtering.
- **`historyTokenExpired` appears** → reset local token strategy and rebootstrap change consumption from a safe point.
- **Query results expensive or unstable** → use shared predicate builders, explicit sorting, and bounded `FetchDescriptor` settings.
## Anti-Patterns (Reject by Default)
- Building persistence logic before validating container wiring.
- Performing broad deletes without predicate review and confirmation.
- Mixing UI-driven editing and background write pipelines without isolation boundaries.
- Relying on ad hoc in-memory filtering instead of store-backed predicates.
- Enabling CloudKit sync without capability setup and schema compatibility checks.
- Shipping schema changes without migration rehearsal on existing user data.
- Consuming history without token persistence and cleanup policy.
- Using `isEmpty == false` in `#Predicate` (runtime crash) — use `!` instead.
- Placing `@Query` anywhere other than a SwiftUI view.
## Core Patterns
### App-level container wiring (SwiftUI)
```swift
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
.modelContainer(for: [Trip.self, Accommodation.self])
}
}
```
### Manual container configuration
```swift
let config = ModelConfiguration(isStoredInMemoryOnly: false)
let container = try ModelContainer(
for: Trip.self,
Accommodation.self,
configurations: config
)
```
### Dynamic query in a view initializer
```swift
struct TripListView: View {
@Query private var trips: [Trip]
init(searchText: String) {
let predicate = #Predicate<Trip> {From ducko-im/ducko, MIT.
More from ducko-im/ducko
- 0.629score
swift-testing
ducko-im
Expert guidance on Swift Testing for writing, reviewing, migrating, and debugging tests.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
accessibility
ducko-im
Apply platform accessibility best practices to SwiftUI, UIKit, and AppKit code.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
macos-ui-testing
ducko-im
Background-safe macOS app UI testing using Peekaboo CLI and osascript.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swiftui
ducko-im
Write, review, or improve SwiftUI code across state management, view composition, performance, modern APIs, navigation, animation, accessibility, Liquid Glass…
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swiftui-performance-audit
ducko-im
Audit and improve SwiftUI runtime performance from code review and architecture.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
writing-for-interfaces
ducko-im
Use when someone asks to write, rewrite, review, or improve text that appears inside a product or interface.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
macos-spm-app-packaging
ducko-im
Scaffold, build, and package SwiftPM-based macOS apps without an Xcode project.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
release
ducko-im
Cut a Ducko release: update CHANGELOG.md on main, then push the X.Y.Z tag that triggers the release.yml CI workflow (build, sign, notarize, DMG, Sparkle…
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swift-concurrency
ducko-im
Expert guidance on Swift Concurrency correctness, modern API usage, and async/await pitfalls in Swift 6.2+.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swift-language
ducko-im
Write, review, or improve Swift APIs and value-display formatting.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swift-security
ducko-im
Use when working with iOS/macOS Keychain Services (SecItem queries, kSecClass, OSStatus errors), biometric authentication (LAContext, Face ID, Touch ID)…
SkillAFreshness: A★ 7Claude Code +9 - 0.625score
lume-vm
ducko-im
Run Ducko UI work inside a disposable Lume macOS VM instead of on the host desktop: start and stop the VM, run commands in its logged-in GUI session…
SkillAFreshness: A★ 7Claude Code +9
Signals
- Stars
- 7
- Forks
- 0
- Open issues
- 4
- Last commit (this folder)
- Oct 23, 2026 (5 days ago)
- Last release
- Oct 23, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/ducko-im/ducko
- Website
- ducko.im
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from ducko-im
- 0.629score
swift-security
ducko-im
Use when working with iOS/macOS Keychain Services (SecItem queries, kSecClass, OSStatus errors), biometric authentication (LAContext, Face ID, Touch ID)…
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swift-language
ducko-im
Write, review, or improve Swift APIs and value-display formatting.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swift-concurrency
ducko-im
Expert guidance on Swift Concurrency correctness, modern API usage, and async/await pitfalls in Swift 6.2+.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
macos-spm-app-packaging
ducko-im
Scaffold, build, and package SwiftPM-based macOS apps without an Xcode project.
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
release
ducko-im
Cut a Ducko release: update CHANGELOG.md on main, then push the X.Y.Z tag that triggers the release.yml CI workflow (build, sign, notarize, DMG, Sparkle…
SkillAFreshness: A★ 7Claude Code +9 - 0.629score
swiftui
ducko-im
Write, review, or improve SwiftUI code across state management, view composition, performance, modern APIs, navigation, animation, accessibility, Liquid Glass…
SkillAFreshness: A★ 7Claude Code +9
Cite this page
swiftdata skill. Agent Mart. https://agentmart.dev/skills/ducko-im-swiftdata (last updated 2026-10-24)