cloudkit
Implement, review, or improve CloudKit and iCloud sync in iOS/macOS apps. Use when working with CKContainer, CKRecord, CKQuery, CKSubscription, CKSyncEngine, CKShare, NSUbiquitousKeyValueStore, or iCloud Drive file coordination; when syncing SwiftData models via ModelConfiguration with cloudKitDatabase; when handling CKError codes for conflict resolution, network failures, or quota limits; or when checking iCloud account status before performing sync operations.
npx skills add dpearson2699/swift-ios-skills --skill cloudkit --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Guides developers to implement, review, or improve CloudKit and iCloud synchronization in iOS/macOS apps. It includes setup for CKContainer and databases, CRUD operations for CKRecord, querying with CKQuery, subscriptions, CKSyncEngine usage (iOS 17+), SwiftData integration via ModelConfiguration, NSUbiquitousKeyValueStore, iCloud Drive file coordination, account status checks, and error handling with CKError mapping. It also prescribes conflict resolution strategies and outlines common mistakes and a review checklist.
How it works
- Load appropriate database scope and verify capability, container, account status, schema, and environment before writing records.
- Persist local changes as durable items, enqueue them, and rely on subscriptions or CKSyncEngine to drive remote syncing rather than polling.
- Persist change tokens or sync-engine state after successful operations.
- Test offline edits, partial failures, rate limiting, token expiry, conflicts, account loss, zone deletion, and relaunch scenarios.
- On failure, classify CKError, restore affected items, apply documented retry/reset/merge actions, and rerun the same scenario.
- Use CKSyncEngine for automatic syncing of custom model data; persist stateSerialization to resume correctly.
- When using SwiftData, assess model compatibility and perform schema rollout steps across development and production promotions.
- Handle CKError codes with specific strategies: network failures retry, serverRecordChanged conflict resolution, rate limits retry with delay, quota notifications, and partialFailure per-item inspection.
- Implement conflict resolution by merging client/server/ancestor changes when server records indicate changes.
When to use it
- When configuring CloudKit for iCloud sync across containers and databases.
- When performing CKRecord CRUD, CKQuery, and CKSubscription setup.
- When utilizing CKSyncEngine (iOS 17+) for model data synchronization.
- When integrating CloudKit with SwiftData via ModelConfiguration.
- When using NSUbiquitousKeyValueStore or iCloud Drive file coordination.
- When checking iCloud account status before performing sync operations.
- When handling CKError codes and implementing conflict resolution workflows.
What it can touch
- CKContainer, CKDatabase (public/private/shared), CKRecord, CKQuery, CKSubscription, CKSyncEngine, CKRecordZone, CKRecordZoneSubscription, CKError.
- SwiftData ModelConfiguration and ModelContainer for cloudKitDatabase integration.
- NSUbiquitousKeyValueStore and FileManager ubiquity APIs.
- iCloud account status retrieval via CKContainer.accountStatus().
Caveats
- License is NOASSERTION.
- Requires CloudKit capability and remote notifications for certain features.
- Automatic CKSyncEngine timing is indeterminate and does not guarantee immediate sync.
- Conflict resolution relies on three-way merge logic for serverRecordChanged errors; exact merge behavior is implementation-specific.
- Partial failures require per-item handling and may involve complex retry strategies.
# CloudKit Sync data across devices using CloudKit, iCloud key-value storage, and iCloud Drive. Covers container setup, record CRUD, queries, subscriptions, CKSyncEngine, SwiftData integration, conflict resolution, and error handling. ## Contents - [Container and Database Setup](#container-and-database-setup) - [Workflow](#workflow) - [CKRecord CRUD](#ckrecord-crud) - [CKQuery](#ckquery) - [CKSubscription](#cksubscription) - [CKSyncEngine (iOS 17+)](#cksyncengine-ios-17) - [SwiftData + CloudKit](#swiftdata--cloudkit) - [NSUbiquitousKeyValueStore](#nsubiquitouskeyvaluestore) - [iCloud Drive File Sync](#icloud-drive-file-sync) - [Account Status and Error Handling](#account-status-and-error-handling) - [Conflict Resolution](#conflict-resolution) - [Common Mistakes](#common-mistakes) - [Review Checklist](#review-checklist) - [References](#references) ## Workflow 1. Choose the database scope and sync owner; verify capability, container, account status, schema, and environment before writing records. 2. Make a local change durable, enqueue it, then let subscriptions or `CKSyncEngine` drive remote work rather than polling. 3. Persist change tokens or sync-engine state after successful app
- Contents
- Workflow
- Container and Database Setup
- CKRecord CRUD
- Custom Record Zones
- CKQuery
- CKSubscription
- CKSyncEngine (iOS 17+)
- SwiftData + CloudKit
- NSUbiquitousKeyValueStore
- iCloud Drive File Sync
- Account Status and Error Handling
- CKError Handling
- Conflict Resolution
What does the cloudkit skill do?
Implement, review, or improve CloudKit and iCloud sync in iOS/macOS apps. Use when working with CKContainer, CKRecord, CKQuery, CKSubscription, CKSyncEngine, CKShare, NSUbiquitousKeyValueStore, or iCloud Drive file coordination; when syncing SwiftData models via ModelConfiguration with cloudKitDatabase; when handling CKError codes for conflict resolution, network failures, or quota limits; or when checking iCloud account status before performing sync operations.
How do I install it?
Run `npx skills add dpearson2699/swift-ios-skills --skill cloudkit --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From dpearson2699/swift-ios-skills, a repository with 963 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.