/apple-dev-skills:cloudkit-schema-source-of-truthfrom apple-dev-skills
Manages CloudKit schema as a committed `.ckdb` source of truth using `xcrun cktool` for export, validation, and import against Development, with Production promotion as a manual Console-only gate.
Ships in apple-dev-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
CloudKit has no migration-file system like a SQL database. The schema lives in Apple's
CloudKit Dashboard/Console, and xcrun cktool (Apple's official CLI, ships with Xcode) can
export, validate, and import it — but only against the Development environment.
Production promotion is a manual, irreversible Console action. This skill makes the
Development side of that workflow scriptable and commit-trackable while keeping the
Production gate correctly user-owned.
.ckdb file is committed to the repo, or why a field the app writes is missing
from Production data.Owns: the .ckdb-as-source-of-truth workflow, cktool invocations against Development, and
the Production promotion gate. Does not own: the Swift-side persistence/service code that
reads and writes CloudKit records → swift-dependency-injection for how that seam is
injected and faked in tests; secret storage for the management token itself →
apple-public-repo-security / build-time-secret-injection.
Two credentials, kept in a gitignored env file (e.g. secrets/.env, with a committed
.env.example template):
The container identifier itself (e.g. iCloud.com.example.myapp) is not secret and can be
hardcoded in tooling.
cktool for this session (positional arg — see gotcha 1 below)..ckdb against the live container before importing.cktool's keychain store when done (via a shell trap ... EXIT around steps 1–4, so it's purged even if a step fails midway).Runnable as ${CLAUDE_SKILL_DIR}/scripts/ck-schema-dev.sh (the scripts/ folder next to this SKILL.md) — run it by that path or copy it into your repo's scripts/; see that file for the exact cktool invocations and flags.
export) or
the committed cloudkit/<app>.ckdb (validate / import).export overwrites cloudkit/<app>.ckdb — review the diff, then commit it as
the schema source of truth. import mutates the named container's live schema..ckdb files are not secrets — they contain schema definitions only, no data or tokens
— so they're committed like any other source file, distinct from the token itself.cktool cannot push schema to Production. import-schema --environment production
rejects with an "endpoint not applicable in this environment" style error, and there is no
promote subcommand. The Development → Production promotion happens only in the CloudKit
Console:
import-schema --environment development above).CloudKit Production record types and fields are add-only by Apple's own rule — once
deployed they can't be deleted or renamed, only added to. Indexes are different: they can be
added and removed in Production (WWDC21 "Automate CloudKit tests with cktool and declarative
schema"). Restricting the promotion path to the
Console keeps it naturally user-owned: automation prepares and validates the .ckdb and the
Development deploy; a human clicks the actual Production button.
export / validate / import --environment development are all reversible and safe to run
repeatedly without asking anyone.
save-token takes the token as a positional argument, not piped stdin. Non-interactive
stdin piping fails with Error: Interaction was required while running in non-interactive mode (CKTOOL_NO_PROMPT=1 or not running in an interactive terminal). (verified locally,
cktool 1.0.23001). Brief command-line argv exposure of the token is the tradeoff; purge it
from the keychain store immediately after (see the trap note above).validate-schema requires --environment explicitly — omitting it is a hard error, not
a default.import-schema only ever targets Development. Don't assume a script that "runs
import-schema --environment production" has ever actually been exercised — smoke-test any
such tooling against real credentials before trusting it; a plausible-looking Production
import path that was never live-tested can sit broken for a long time undetected.CKError for the unknown field when the app tries to save it — this only looks silent if
the app's own save-completion handling swallows or ignores that error instead of surfacing
it. Audit method: export-schema --environment production to a scratch file and diff
its field set against every field the code actually writes, and confirm every CloudKit save
call actually surfaces its error instead of discarding it.QUERYABLE SEARCHABLE SORTABLE. A hand-authored
.ckdb should declare the minimal index set the app's actual queries need instead
(e.g. only the one field a specific equality query filters on, as QUERYABLE) — every index
adds query/storage cost and noise to the .ckdb diff, so start minimal and add indexes as
real queries need them.import-schema is a declarative import, so a .ckdb can be hand-authored from scratch —
no Dashboard clicking, no live seed build required. Use one export's output as the syntax
template (it includes the system "___*" fields and the GRANT block a hand-written file
also needs).For other cktool subcommands/flags not required for the core loop above (e.g. import-schema --validate, export-schema --output-file <path>), run xcrun cktool help / xcrun cktool <subcommand> --help — the offline, primary source, more current than any WWDC talk. One flag
worth knowing without opening a shell: reset-schema resets a container's Development
environment to match Production and deletes all Development data — a "start clean and
re-seed" tool, not part of the routine loop.
export: re-running always overwrites cloudkit/<app>.ckdb with the current Development
schema — treat the file as generated + reviewed, not hand-edited, whenever a live export is
the intended source.import: CloudKit's import is declarative — re-applying the same unchanged .ckdb is a
no-op.Treating one .ckdb per app as the schema source of truth gives CloudKit the same
review-before-merge discipline a SQL migration file gets, despite CloudKit having no native
migration mechanism. Restricting the token to Development-only tooling, and Production to a
Console click, matches Apple's own irreversibility constraint (add-only fields) to a
correspondingly irreversible, deliberately manual approval step.
.ckdb per container (not per
app) and make the ownership of shared record types explicit in its surrounding docs, so two
apps don't independently "fix" the same field in diverging ways.import-schema --environment production works because it's syntactically
accepted-looking — it is Development-only; Production is Console-only.CKError
for the unknown field, which looks like a silent failure only if that error is discarded.cktool's keychain store after a session — purge it
even on script failure via a trap..ckdb opportunistically without re-validating against the live
Development container before importing..ckdb (marking every field QUERYABLE SEARCHABLE SORTABLE out of caution) — every extra index adds query/storage cost and noise to the
.ckdb diff; declare only what the app's queries need and add more later.CKError that many apps never surface anywhere visible, so
the failure mode is only caught by an explicit audit, not by normal testing..ckdb is committed under version control; the management token is not.export was run after a Development-seeding build, not against a partially-provisioned container.validate-schema was run with an explicit --environment before any import.cktool's keychain store, even on failure paths.import-schema can target Production — the Console step is documented as the only path..ckdb declares only the indexes the app's actual queries need.swift-dependency-injection — how CloudKit access is injected and faked, keeping schema concerns out of call sites.swift-testing-baseline — gate live CloudKit/Game Center access behind a test-only suppression seam; constructing a live container or auth handler inside a test blocks the unentitled SwiftPM runner indefinitely (its "unentitled runner" section covers this landmine — this skill's schema is only ever tested against, never through a live container in CI).apple-public-repo-security — why the management token is a stricter secret class than a build-time public identifier.build-time-secret-injection — the general env-file-based secret pattern this workflow's token handling follows.references/official-docs.md.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wei18/apple-dev-skills --plugin apple-dev-skills28 skills in this plugin
/ai-translated-localizationLocalization scope and AI-translation execution for Apple-platform Apps on `Localizable.xcstrings` — default locale set, source / primary language rule, per-locale review gotchas, completeness gates. Use when deciding which locales to ship at project setup; when adding or refreshing user-facing strings (UI keys, Game Center, App Store metadata) in non-source locales; when `extractionState: stale` entries or untranslated placeholder markers appear; or when asked "how many locales", "how do translations enter git". Does NOT cover RTL layout or ASC upload mechanics → asc-api-automation./apple-platform-targetsDefault minimum deployment target for Apple-platform Swift Apps — iOS 26 / macOS 26 on the Xcode 26 toolchain (Swift 6 language mode) — and how to deviate down (iOS 18 / 17) or up. Use when starting a new Apple-platform project, writing the Package.swift `platforms:` list, deciding whether an API newer than the floor is worth bumping for or a client requirement forces dropping below it, or when asked "what should the minimum iOS / macOS version be". Entry point of the bootstrap chain; does NOT own language mode → swift6-concurrency, or module layout → swiftpm-modularization./apple-public-repo-securityUse when a repo goes public or open-sources, when a CloudKit server-to-server PEM, ASC API `.p8`, APNs key, signing `.p12`, or provisioning profile first enters the pipeline, or when asked how to prevent or respond to a secret leak (gitleaks, lefthook, GitHub Secret Scanning, `git filter-repo`, rotate-first). Also for Apple upstream telemetry disclosure (MetricKit, Game Center, sysdiagnose). Repo-hygiene baseline only; ship-in-binary identifiers (AdMob IDs via xcconfig) and CLI keys in `secrets/.env` are build-time-secret-injection; ASC API usage is asc-api-automation./apple-three-piece-analyticsChoose analytics and metrics sources for a solo / small-team Apple app and decide whether a third-party tracking SDK is justified. Use when picking an analytics SDK; when asked "should I add Firebase / Mixpanel / Amplitude / TelemetryDeck"; when asked what App Store Connect Analytics, MetricKit (`MXMetricPayload`) or Game Center can measure without an SDK; when the analytics choice drives `PrivacyInfo.xcprivacy` or forces ATT. Does NOT own MetricKit perf wiring (ios-performance-engineering), App Review privacy-label parity (app-store-review-rejections), or sink code (telemetry-facade-pattern)./app-store-review-rejectionsUse when preparing an App Store submission, reading an App Review rejection or Resolution Center message citing a guideline number (2.1, 2.3.x, 3.1.1, 4.3, 5.1.1, 5.1.2), or a privacy-manifest upload email (ITMS-91061 / ITMS-91056, missing required-reason API), or auditing an ads + Remove-Ads IAP + CloudKit + Game Center app for the rejection classes it realistically hits: the ATT-vs-AdMob trap, privacy-label parity with `PrivacyInfo.xcprivacy`, Restore Purchases, screenshot metadata, export compliance. Maps each class to a pre-submit fix. Not the submission mechanics (asc-api-automation) nor StoreKit implementation (storekit2-iap-defaults)./asc-api-automationUse when automating App Store Connect from a script or CI via the ASC REST API (`api.appstoreconnect.apple.com`) — ASC API `.p8` key / JWT auth, TestFlight `betaGroups` / `betaBuildLocalizations`, `appStoreVersions` / `releaseType`, `reviewSubmissions`, `salesReports`, `analyticsReportRequests` — or asked "automate TestFlight / submission / release notes", "should I use fastlane", or debugging 401 NOT_AUTHORIZED / 429 RATE_LIMIT_EXCEEDED, or asked which ASC steps have no API and must be clicked by hand. API side only: build & upload → xcode-cloud-single-track-ci / local-archive-export-upload; `.p8` storage → build-time-secret-injection.Other plugins' skills for the same job