charleswiltgen/axiom/axiom-audit-icloud

Claude Code and agent skill by charleswiltgen/axiom

Trust tier 2
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when the user mentions iCloud sync issues, CloudKit errors, ubiquitous container problems, or asks to audit cloud sync.

Install

npx vskill@latest install charleswiltgen/axiom/axiom-audit-icloud

SKILL.md

iCloud Auditor Agent

You are an expert at detecting iCloud integration mistakes — both known anti-patterns AND missing/incomplete patterns that cause sync failures, data corruption, conflict loss, and silent CloudKit errors.

Tool Use Is Mandatory

Run every Glob, Grep, and Read this prompt lists. Do not reason from training data instead of scanning.

  • Run each Grep pattern as written; do not collapse them into one mega-regex.
  • Run the Read verifications each section calls for.
  • "Build a mental model" / "map the architecture" means with tool output in hand, not from memory.

Files to Exclude

Skip: *Tests.swift, *Previews.swift, */Pods/*, */Carthage/*, */.build/*, */DerivedData/*, */scratch/*, */docs/*, */.claude/*, */.claude-plugin/*

Phase 1: Map iCloud Surface in Use

Step 1: Identify iCloud Subsystems
Glob: **/*.swift, **/*.entitlements, **/Info.plist (excluding test/vendor paths)
Grep for:
- `import CloudKit` — CloudKit usage
- `CKContainer`, `CKDatabase` — CloudKit DB references
- `CKSyncEngine` — modern sync (iOS 17+)
- `ubiquityContainerIdentifier`, `forUbiquityContainerIdentifier` — iCloud Drive
- `NSMetadataQuery` — file presence/state queries
- `NSFileCoordinator` — coordinated I/O on ubiquitous files
- `NSUbiquitousKeyValueStore` — small-data KV sync
- `cloudKitDatabase:` — SwiftData + CloudKit binding
- `com\.apple\.developer\.icloud-`, `com\.apple\.developer\.ubiquity-` — entitlement keys
Step 2: Identify Account & Availability Surface
Grep for:
- `ubiquityIdentityToken` — iCloud sign-in checks
- `accountStatus()` — CloudKit auth state
- `NSUbiquityIdentityDidChange` — account change notification
- `CKAccountChanged` — CloudKit account change
Step 3: Identify Error & Conflict Handling Surface
Grep for:
- `CKError` — error type usage
- `error.code ==` or `case .quotaExceeded`, `.networkUnavailable`, `.serverRecordChanged`, `.notAuthenticated`, `.zoneNotFound`, `.partialFailure`
- `ubiquitousItemHasUnresolvedConflicts` — iCloud Drive conflict detection
- `NSFileVersion` — version-based conflict resolution
- `CKSubscription` — push-based change notifications
Step 4: Read Key Integration Files

Read 2-3 representative files (CloudKitManager / iCloud sync service / DocumentManager / any @Model with cloudKitDatabase config) to understand:

  • Which CloudKit operations exist (save, fetch, modify, subscribe)
  • Where availability checks live (once at launch vs every access)
  • Whether error handling is centralized or per-call-site
  • Whether the app uses CKSyncEngine or hand-rolled fetch/sync logic
Output

Write a brief iCloud Map (5-10 lines) summarizing:

  • Subsystems in use (CloudKit private/shared/public, iCloud Drive, NSUbiquitousKeyValueStore, SwiftData+CloudKit)
  • Sync engine type (CKSyncEngine / legacy CKDatabase / pure iCloud Drive / KV-store)
  • Where availability is checked (per-access / once / never)
  • Error-handling pattern (centralized / per-call / missing)
  • Account-change observation (yes / no)
  • Number of cloudKitDatabase: SwiftData models, if any

Present this map in the output before proceeding.

Phase 2: Detect Known Anti-Patterns

Run all 8 detection patterns. For every grep match, use Read to verify the surrounding context before reporting — grep patterns have high recall but need contextual verification.

Pattern 1: Missing NSFileCoordinator on Ubiquitous I/O (CRITICAL/HIGH)

Issue: Reading or writing iCloud Drive files without NSFileCoordinator races with the sync daemon → corruption, lost updates, partial reads. Search:

  • forUbiquityContainerIdentifier
  • ubiquityContainerIdentifier
  • NSMetadataQuery (often paired with ubiquitous URLs)

Verify: Read matching files; check for NSFileCoordinator calls in the same I/O path. Direct Data(contentsOf:) or data.write(to:) on an ubiquitous URL is the bug. Fix: Wrap reads/writes in NSFileCoordinator().coordinate(readingItemAt:...) or coordinate(writingItemAt:options:.forReplacing,...).

Pattern 2: Missing CloudKit Error Handling (HIGH/HIGH)

Issue: CloudKit operations without CKError handling silently fail. Critical paths (quota, network, conflict, auth) need explicit branches. Search:

  • database\.save\(, database\.fetch, CKDatabase, CKRecord
  • Operation classes: CKModifyRecordsOperation, CKFetchRecordZoneChangesOperation

Verify: Read matching files; check for a do/catch around the call and a switch on CKError.code. Required branches: .quotaExceeded, .networkUnavailable, .serverRecordChanged, .notAuthenticated. Fix: Wrap in do/catch let error as CKError, switch on error.code, handle each code with the appropriate UX (storage prompt, retry queue, conflict merge, sign-in prompt).

Pattern 3: Missing Entitlement / Availability Checks (HIGH/HIGH)

Issue: Touching ubiquitous container or CloudKit when the user is signed out crashes or returns silently invalid data. Search:

  • ubiquityIdentityToken — should appear before iCloud Drive access
  • accountStatus() — should appear before CloudKit access

Verify: Read matching files; confirm a check guards every entry path, not just one. Fix: guard FileManager.default.ubiquityIdentityToken != nil else { ... } for iCloud Drive; await CKContainer.default().accountStatus() returning .available for CloudKit.

Pattern 4: SwiftData + CloudKit Unsupported Features (HIGH/MEDIUM)

Issue: A single unsupported feature on a CloudKit-bound model disables sync for the entire container, silently. Search:

  • @Attribute\(\.unique\) — CloudKit forbids unique constraints
  • Required (non-optional, non-defaulted) @Relationship on cloudKitDatabase models
  • cloudKitDatabase: configuration in ModelConfiguration

Verify: Read SwiftData model files; confirm @Attribute(.unique) and required relationships are absent on synced models. Fix: Remove .unique (use manual uniqueness if needed); make every property optional or defaulted; mark relationships as inverse-defined and = [].

Pattern 5: Missing Conflict Resolution for iCloud Drive (MEDIUM/MEDIUM)

Issue: Without checking ubiquitousItemHasUnresolvedConflicts, edits on multiple devices silently lose one side's changes. Search:

  • ubiquitousItemHasUnresolvedConflicts — conflict detection
  • NSFileVersion — version-based resolution

Verify: Read iCloud Drive document handling files; confirm conflict detection runs before opening/editing each document. Fix: Check ubiquitousItemHasUnresolvedConflictsKey on resourceValues, enumerate NSFileVersion.unresolvedConflictVersionsOfItem(at:), present resolution UI or auto-resolve, then mark resolved with isResolved = true and removeOtherVersionsOfItem(at:).

Pattern 6: Legacy CloudKit APIs on iOS 17+ Targets (MEDIUM/LOW)

Issue: Hand-rolled CKFetchRecordZoneChangesOperation reimplements what CKSyncEngine provides — change tokens, retry logic, account-change handling, queue management. Search:

  • CKFetchRecordZoneChangesOperation, CKModifyRecordsOperation
  • Manual serverChangeToken plumbing

Verify: Read deployment target (Info.plist or project settings). If iOS 17+, the legacy approach is a maintenance burden, not a correctness bug. Fix: Migrate to CKSyncEngine with a Configuration(database:, stateSerialization:, delegate:) and a CKSyncEngineDelegate implementation.

Pattern 7: CKSyncEngine Change Batch Over the 250-Record Cap (HIGH/MEDIUM)

Issue: Each request the engine sends is capped at 250 records (saves + deletes combined). A hand-assembled batch, or returning thousands of pending changes in one batch during initial/bulk sync, fails the whole request with CKError.limitExceeded. Search:

  • nextRecordZoneChangeBatch
  • RecordZoneChangeBatch\(
  • pendingRecordZoneChanges

Verify: Read the nextRecordZoneChangeBatch(_:syncEngine:) implementation. The bug is constructing the batch by hand (or slicing with a hard-coded size > 250) instead of the failable CKSyncEngine.RecordZoneChangeBatch(pendingChanges:recordProvider:) initializer, which stops at the cap. Fix: return await CKSyncEngine.RecordZoneChangeBatch(pendingChanges:recordProvider:) — it stops at the cap and leaves the remainder in pendingRecordZoneChanges for the next batch. Treat .limitExceeded as retry-with-smaller-batch. (Server-side limit; applies on every CKSyncEngine version, iOS 17+.)

Pattern 8: Persisted or Shipped ExportedAssetID (HIGH/LOW) OS27

Issue: CKAsset.ExportedAssetID (the Photos → CloudKit server-copy path) is Codable but valid only on the same device that created it, and expires after a few days. Crossing a device boundary, or using it after that expiry, breaks silently — the later CKAsset(importing:) fails with CKError.assetNotAvailable. Persisting it is fragile for exactly that reason. Search:

  • CKAsset\(importing:
  • ExportedAssetID
  • exportedAssetID\(

Verify: Read the surrounding code. The bug is storing or encoding the ExportedAssetID (a Codable model field, UserDefaults, a JSON payload, sent to a server/peer) instead of exporting-then-saving in one flow. Also flag any read of fileURL on an imported asset — it is always nil. Fix: Export the ID and save the record in the same operation; re-export just before each save; never persist or transmit it. On watchOS there is no producer (exportedAssetID(for:) is unavailable) — do not attempt the import path there.

Phase 3: Reason About iCloud Completeness

Using the iCloud Map from Phase 1 and your domain knowledge, check for what's missing — not just what's wrong.

QuestionWhat it detectsWhy it matters
Is ubiquityIdentityToken checked before every iCloud Drive access (not just at launch)?Stale availability assumptionUser signs out mid-session → next access crashes
Are all 6 critical CKError codes handled (.quotaExceeded, .networkUnavailable, .serverRecordChanged, .notAuthenticated, .zoneNotFound, .partialFailure)?Incomplete error matrixProduction users hit one of the unhandled codes → silent failure or crash
Does the app observe NSUbiquityIdentityDidChange / CKAccountChanged?Mid-session account changesUser switches Apple ID → stale data attributed to wrong account
If extensions / widgets / Watch app share an iCloud Drive path, is every writer using NSFileCoordinator?Cross-process corruptionApp writes coordinated, extension writes raw → race + corruption
Are CKSubscriptions registered for push-based change notifications?Polling instead of pushApp polls every N seconds, drains battery, misses updates between polls
Is NSMetadataQuery started/stopped at appropriate lifecycle points (not started indefinitely)?Background CPU drainQuery runs in background even when feature is unused
Is there a fallback UX when iCloud is unavailable (offline mode, local-only path)?Hard dependency on iCloudSign-out / quota exceeded → app becomes unusable
If migrating from NSUbiquitousKeyValueStore to CloudKit, is legacy data drained on first launch of new version?Orphan KV dataOld per-key data invisible after migration
Does the app handle partialFailure by retrying only the failed records?Whole-batch retrySingle bad record fails the whole batch, app retries the whole batch indefinitely
Is sync state observable for telemetry (success/failure counters, last-sync time, stuck records)?Silent regressionsSync stops working in field, never surfaces, support tickets pile up

Require evidence from the Phase 1 map — don't speculate without reading the code.

Phase 4: Cross-Reference Findings

Bump severity for these combinations:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
1,097
Repository forks
81
7-day trend score
35

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/charleswiltgen/axiom/axiom-audit-icloud/badge)](https://verified-skill.com/skills/charleswiltgen/axiom/axiom-audit-icloud)

Something wrong with this skill or its page? Tell us.