# Cloudkit Sync

Generate CloudKit sync infrastructure using CKSyncEngine with conflict resolution...

- Repository: https://github.com/rshankras/claude-code-apple-skills (846 stars)
- Category: DevOps
- License: MIT
- Last updated: 2026-07-24
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add rshankras/claude-code-apple-skills --skill cloudkit-sync -g -a claude-code -y`
Codex: `npx skills add rshankras/claude-code-apple-skills --skill cloudkit-sync -g -a codex -y`
Cursor: `npx skills add rshankras/claude-code-apple-skills --skill cloudkit-sync -g -a cursor -y`
Gemini CLI: `npx skills add rshankras/claude-code-apple-skills --skill cloudkit-sync -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add rshankras/claude-code-apple-skills`

## Description

Generate CloudKit sync infrastructure using CKSyncEngine with conflict resolution, sharing, and account monitoring. Use when adding iCloud sync to an iOS/macOS app.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# CloudKit Sync Generator

Generate production-ready CloudKit sync infrastructure using `CKSyncEngine` (iOS 17+ / macOS 14+), the modern replacement for manual `CKOperation` chains.

## When This Skill Activates

Use this skill when the user:
- Asks to "add iCloud sync" or "sync data across devices"
- Mentions "CloudKit", "CKSyncEngine", or "cloud sync"
- Wants to "share data between users" via iCloud
- Asks about "conflict resolution" for synced data
- Mentions "CKRecord", "CKShare", or "CKRecordZone"

## Pre-Generation Checks

### 1. Project Context Detection

Before generating, ALWAYS check:

```bash
# Check deployment target (CKSyncEngine requires iOS 17+ / macOS 14+)
grep -r "platform" Package.swift 2>/dev/null || true
grep -r "IPHONEOS_DEPLOYMENT_TARGET\|MACOSX_DEPLOYMENT_TARGET" --include="*.pbxproj" | head -3

# Find existing CloudKit implementations
rg -l "CKSyncEngine\|CKContainer\|CKRecord\|CKOperation" --type swift | head -10

# Check for existing entitlements
find . -name "*.entitlements" -exec cat {} \; 2>/dev/null | grep -i "icloud"

# Check existing persistence layer
rg -l "@Model\|NSManagedObject\|PersistentModel" --type swift | head -5

# Check for existing sync infrastructure
rg "CKSyncEngineDelegate\|CKSubscription\|CKFetchRecordZoneChanges" --type swift | head -5
```

### 2. Compatibility Verification

**CKSyncEngine requires:**
- iOS 17.0+ / macOS 14.0+ / watchOS 10.0+ / tvOS 17.0+
- CloudKit entitlement
- Active iCloud account on device

If deployment target is below iOS 17 / macOS 14, warn the user that CKSyncEngine is not available and suggest either raising the target or using the older CKOperation approach (which this generator does not cover).

### 3. Conflict Detection

If existing CloudKit code is found:
- Ask: Replace existing implementation, extend it, or migrate to CKSyncEngine?

## Configuration Questions

Ask user via AskUserQuestion:

The rest: https://github.com/rshankras/claude-code-apple-skills/blob/HEAD/skills/generators/cloudkit-sync/SKILL.md
