agentleFS
bastosbastos/skills/apple-cktool/SKILL.md

apple-cktool

Skill7 starsChanged 10 months agoMITView on GitHub

Operates Apple's Xcode-bundled `cktool` command-line utility for CloudKit development automation on macOS. Use when Codex needs to run, script, explain, or troubleshoot `xcrun cktool`; manage `.ckdb` schemas with export, validate, import, or reset; discover CloudKit teams; create, query, or delete test records; configure management or user tokens in Keychain or CI; or prepare CloudKit-backed integration tests. For equivalent typed JavaScript or TypeScript automation, use `apple-cktool-js` with this skill.

The file

Show its rules and text

We split this skill into the rules it gives an agent

29 rules. About 0 are common, 10 are distinctive, and 19 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 19

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use the stateless cktool CLI distributed with Xcode to manage CloudKit schemas and test data from macOS.

    line 8
  2. Very specific:

    Use both skills when a repository exposes a simple local cktool path and a portable CKTool JS CI path.

    line 19
  3. Distinctive:

    Inspect the local tool: Run:

    line 23
  4. Very specific:

    Treat local help as authoritative for the installed Xcode.

    line 33
  5. Very specific:

    Select the token class: Use a management token for team/container discovery and schema operations.

    line 37
  6. Distinctive:

    Confirm destructive scope: Before a destructive operation, state the exact container, environment, database, zone, record type or record …

    line 41
  7. Distinctive:

    Execute without exposing credentials: Prefer interactive Keychain storage for local work and environment injection from a secret manager …

    line 43
  8. Distinctive:

    Verify the result: Check the exit status, capture structured JSON when the command returns it, re-export a changed schema, or re-query …

    line 45
  9. Very specific:

    Default to development. Treat any production record mutation as high impact.

    line 49
  10. Distinctive:

    Do not assume schema import to production is a normal deployment path merely because a local parser accepts an environment value.

    line 52
  11. Very specific:

    Run validate-schema before import-schema.

    line 53
  12. Very specific:

    Run delete-records with its default --dry-run true first.

    line 54
  13. Very specific:

    Prefer --fields-file or --fields-stdin over large inline JSON.

    line 55
  14. Very specific:

    Do not use command-line --token in shared shells, process listings, CI logs, or recorded terminal sessions.

    line 56
  15. Very specific:

    Keep .ckdb schema files in version control when the repository uses declarative CloudKit schema management.

    line 72
  16. Distinctive:

    After import, export again and compare the effective schema when exact server state matters.

    line 90
  17. Distinctive:

    Use this only when deleting all development data is intended.

    line 100
  18. Very specific:

    Read references/records-and-filters.md before composing field JSON, filters, sorts, assets, pagination, or deletions.

    line 119
  19. Very specific:

    Do not change the dry run to false until the returned count and target are verified.

    line 147
  20. Very specific:

    If xcrun cannot find cktool, inspect xcode-select -p, verify Xcode 13 or newer is installed, and select the intended Xcode developer …

    line 151
  21. Distinctive:

    If authentication fails, verify the operation uses the correct token class and check token expiration or revocation.

    line 152
  22. Distinctive:

    If a query fails, inspect record type spelling, field types, zone, database, and Queryable/Sortable indexes.

    line 153
  23. Distinctive:

    If JSON parsing fails, move inline fields to a file and validate the JSON separately.

    line 154
  24. Very specific:

    If the CLI reports usage error 64, re-read xcrun cktool help <subcommand> for the installed version.

    line 155
  25. Very specific:

    If CloudKit rejects a schema, run validate-schema, inspect the .ckdb diff, and verify the environment/container pair.

    line 156
  26. Very specific:

    Read references/command-reference.md for the complete command surface, required flags, exit codes, and examples.

    line 160
  27. Very specific:

    Read references/records-and-filters.md for field JSON, assets, filters, sorts, indexes, pagination, and safe deletion.

    line 161
  28. Very specific:

    Read references/authentication-and-automation.md for token precedence, Keychain, environment variables, Xcode test setup, and CI patterns.

    line 162
  29. Very specific:

    Read references/sources.md for Apple documentation, WWDC sessions, samples, and the verification snapshot.

    line 163

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Apple cktool

Use the stateless cktool CLI distributed with Xcode to manage CloudKit schemas and test data from macOS. Keep the target explicit and default all development automation to the development environment.

Choose the right companion

NeedUse
Shell commands, Xcode schemes, or a macOS runnerThis skill
TypeScript, Node.js, browser tooling, or non-macOS CIapple-cktool-js
A shell wrapper around a few stable commandsThis skill
Reusable branching logic, typed models, updates, or richer error handlingapple-cktool-js

Use both skills when a repository exposes a simple local cktool path and a portable CKTool JS CI path. Keep the same team, container, environment, schema file, and safety policy across both implementations.

Follow the operating workflow

  1. Inspect the local tool. Run:

    xcode-select -p
    xcrun --find cktool
    xcrun cktool --version
    xcrun cktool --help
    xcrun cktool help <subcommand>

    Treat local help as authoritative for the installed Xcode. Use man cktool for field formats, token precedence, and examples. Do not assume flags from a different Xcode release.

  2. Resolve the complete target. Record the team ID, container ID, environment, database type, zone, record type, and schema path that apply. Do not infer a production target from an app bundle identifier. Use get-teams when the team ID is unknown.
  3. Select the token class. Use a management token for team/container discovery and schema operations. Use a user token for record operations on behalf of an iCloud user. Read references/authentication-and-automation.md before configuring tokens or CI.
  4. Prepare a reversible command. Export before schema changes, validate before import, query before a single-record deletion, and use the default dry run before bulk deletion. Treat reset, import, creation, and deletion as remote mutations.
  5. Confirm destructive scope. Before a destructive operation, state the exact container, environment, database, zone, record type or record name, and expected effect. Require explicit user authorization for production writes, schema reset, or permanent deletion unless that exact operation is already the user's request.
  6. Execute without exposing credentials. Prefer interactive Keychain storage for local work and environment injection from a secret manager for CI. Never print, paste into logs, commit, or pass a token in a command when a safer mechanism is available.
  7. Verify the result. Check the exit status, capture structured JSON when the command returns it, re-export a changed schema, or re-query affected records. Report the resolved target and outcome, with tokens redacted.

Apply safety invariants

  • Default to development. Treat any production record mutation as high impact.
  • Remember that reset-schema resets the development schema to production and deletes all development data.
  • Remember that exporting a schema backs up schema text, not record data.
  • Do not assume schema import to production is a normal deployment path merely because a local parser accepts an environment value. Apple's documented workflow imports into development and deploys schema to production through the supported CloudKit workflow.
  • Run validate-schema before import-schema; use import-schema --validate only when one combined step is appropriate.
  • Run delete-records with its default --dry-run true first. Use --dry-run false --yes only after reviewing the match count and filters.
  • Prefer --fields-file or --fields-stdin over large inline JSON. This reduces quoting errors and accidental shell expansion.
  • Do not use command-line --token in shared shells, process listings, CI logs, or recorded terminal sessions.
  • Preserve pagination. If query-records returns continuationToken, continue until the requested scope is complete and stop on a repeated token.
  • Expect indexed-query requirements. A queried or sorted field must have the appropriate CloudKit index; an unfiltered query may require ___recordID to be Queryable.

Use common schema recipes

Export a baseline

xcrun cktool export-schema \
  --team-id "$TEAM_ID" \
  --container-id "$CONTAINER_ID" \
  --environment development \
  --output-file Schema.ckdb

Keep .ckdb schema files in version control when the repository uses declarative CloudKit schema management. Review the diff before importing.

Validate, then import

xcrun cktool validate-schema \
  --team-id "$TEAM_ID" \
  --container-id "$CONTAINER_ID" \
  --environment development \
  --file Schema.ckdb

xcrun cktool import-schema \
  --team-id "$TEAM_ID" \
  --container-id "$CONTAINER_ID" \
  --environment development \
  --file Schema.ckdb

After import, export again and compare the effective schema when exact server state matters.

Reset test state

xcrun cktool reset-schema \
  --team-id "$TEAM_ID" \
  --container-id "$CONTAINER_ID"

Use this only when deleting all development data is intended. Reapply the tested schema and seed data in a deterministic order before integration tests.

Use common record recipes

Query with a bounded result

xcrun cktool query-records \
  --team-id "$TEAM_ID" \
  --container-id "$CONTAINER_ID" \
  --environment development \
  --database-type public \
  --zone-name _defaultZone \
  --record-type Book \
  --filters "pageCount >= int64Type:1000" \
  --requested-fields title pageCount \
  --limit 50

Read references/records-and-filters.md before composing field JSON, filters, sorts, assets, pagination, or deletions.

Create from a file

xcrun cktool create-record \
  --team-id "$TEAM_ID" \
  --container-id "$CONTAINER_ID" \
  --environment development \
  --database-type public \
  --zone-name _defaultZone \
  --record-type Book \
  --fields-file fixtures/book.json

Preview a bulk deletion

xcrun cktool delete-records \
  --container-id "$CONTAINER_ID" \
  --environment development \
  --database-type public \
  --zone-name _defaultZone \
  --record-type Book \
  --filters "fixtureRun == stringType:run-123" \
  --dry-run true

Do not change the dry run to false until the returned count and target are verified.

Diagnose failures

  • If xcrun cannot find cktool, inspect xcode-select -p, verify Xcode 13 or newer is installed, and select the intended Xcode developer directory.
  • If authentication fails, verify the operation uses the correct token class and check token expiration or revocation. User tokens are short-lived.
  • If a query fails, inspect record type spelling, field types, zone, database, and Queryable/Sortable indexes.
  • If JSON parsing fails, move inline fields to a file and validate the JSON separately.
  • If the CLI reports usage error 64, re-read xcrun cktool help <subcommand> for the installed version.
  • If CloudKit rejects a schema, run validate-schema, inspect the .ckdb diff, and verify the environment/container pair.

Load references on demand

  • Read references/command-reference.md for the complete command surface, required flags, exit codes, and examples.
  • Read references/records-and-filters.md for field JSON, assets, filters, sorts, indexes, pagination, and safe deletion.
  • Read references/authentication-and-automation.md for token precedence, Keychain, environment variables, Xcode test setup, and CI patterns.
  • Read references/sources.md for Apple documentation, WWDC sessions, samples, and the verification snapshot.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.