cloudkit

Implement CloudKit synchronization for iOS and macOS apps with CKRecord, CKQuery, and CKSyncEngine.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/KumarAdi8/AgentKit --skill cloudkit-kumaradi8
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudkit
Source: https://github.com/KumarAdi8/AgentKit/tree/main/skills/cloudkit
Command: npx skills add https://github.com/KumarAdi8/AgentKit --skill cloudkit-kumaradi8

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Simplifies implementing robust, cross-device data synchronization using CloudKit and iCloud services so apps can keep user data consistent, recover from errors, and support sharing and background sync.

Core Features & Use Cases

  • Container and database setup for public, private, and shared scopes and custom record zones for atomic commits.
  • CKRecord CRUD, CKQuery patterns, CKSubscription push-based updates, CKSyncEngine orchestration, and SwiftData ModelConfiguration integration.
  • Error handling and conflict resolution including CKError strategies, change token management, retry-after handling, and three-way merges for serverRecordChanged scenarios.
  • NSUbiquitousKeyValueStore and iCloud Drive document coordination for key-value sync and file-based workflows, plus guidance for CKAsset, encrypted values, and CloudKit Dashboard operations.

Quick Start

Set up CloudKit private-database sync for a SwiftData Note model, persist CKSyncEngine state and change tokens, and implement three-way merge handling for serverRecordChanged errors.

Frequently Asked Questions about cloudkit

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

FAQPage Schema
How do I handle CloudKit serverRecordChanged errors during iOS sync?

Handle CloudKit serverRecordChanged errors by implementing a three-way merge strategy that compares local, server, and modified record versions to resolve conflicts. This ensures cross-device data consistency and prevents silent sync failures during iCloud updates.

Can I use CKSyncEngine with SwiftData ModelConfiguration for iCloud sync?

CKSyncEngine integrates with SwiftData ModelConfiguration to orchestrate iCloud sync for iOS and macOS apps. You can set up private-database sync, persist change tokens, and manage state to keep user data consistent across devices automatically.

What is the best way to persist CKSyncEngine state and change tokens?

Persisting CKSyncEngine state and change tokens locally is essential for reliable CloudKit synchronization, allowing your app to resume sync operations from the last known state. This prevents redundant data fetches and ensures conflict resolution continuity across app restarts.

How do I set up CloudKit subscriptions for background push notifications?

Set up CKSubscription with custom record zones in the private or shared database scope to enable push-based background updates. This requires proper container and database configuration to ensure atomic commits and reliable iCloud data delivery.

Why does my CloudKit sync fail with quota or account status errors?

CloudKit sync failures from quota limits or unavailable account status require checking iCloud account availability and honoring retryAfterSeconds parameters in CKError responses. Implementing proper error handling prevents data loss when hitting rate limits or account restrictions.

Does NSUbiquitousKeyValueStore work with iCloud Drive file coordination?

NSUbiquitousKeyValueStore and iCloud Drive document coordination work together to support key-value sync and file-based workflows. This combination enables lightweight data syncing alongside CKAsset handling and encrypted values within your app's operations.