Rebuilding MistKit 🔧 CloudKit + Claude Code in 3 Months
Journey through rebuilding MistKit: from 10-year-old CloudKit docs to modern Swift with Claude Code.
Issue #117
Hello everyone!
After building SyntaxKit with AI assistance, I tackled rebuilding MistKit—my CloudKit library frozen since 2021. Using Claude Code and swift-openapi-generator, I transformed Apple's 10-year-old CloudKit REST API docs into 10,476 lines of type-safe Swift. Here's what I learned from 428 sessions over three months.

Rebuilding MistKit: From Documentation to Production
MistKit had been frozen since 2021, missing out on Swift 6, async/await, and modern server-side patterns. I saw an opportunity: if Claude Code could translate SwiftSyntax ASTs into a DSL, it could translate CloudKit's REST API documentation into an OpenAPI specification.
The Technical Solution:
- Polymorphic Types: OpenAPI's
oneOfpattern withCustomFieldValuehandling CloudKit's dynamic field types - Authentication: ClientMiddleware supporting API tokens, web auth, and server-to-server methods
- Error Handling: Comprehensive OpenAPI schema with type-safe error codes and recovery guidance
- Architecture: Three-layer design with generated client (internal), abstraction layer (internal), and clean public API
The Development Workflow:
Using llm.codes, I converted Apple's documentation into markdown and stored it in .claude/docs/, with a CLAUDE.md file acting as a table of contents. This gave Claude persistent context without repeated prompting—essential since its training predates tools like swift-openapi-generator. I provided CloudKit knowledge and architecture, Claude generated schemas and patterns. Built CLI tools (Celestra, Bushel) to validate beyond unit tests. 3 months of side-project work vs 6-12 months solo.
What Works and What Doesn't:
Claude Code excels at:
- Test Generation: Created 4,161 comprehensive tests covering all edge cases
- Pattern Application: Once shown a pattern, applies it consistently across the codebase
- Refactoring at Scale: 200K token context window enables updating dozens of files simultaneously
Claude Code struggles with:
- Architectural Vision: Requires human guidance for system design and holistic decisions
- Boundary Management: "Grabby AI" would reference internal OpenAPI types instead of abstraction layer
- Newer APIs: Training data predates tools like Swift Testing—documentation is essential
The key insight: AI is a force multiplier, not a replacement. I provided vision and domain knowledge, Claude handled implementation and mechanical transformations.
Read the complete story in Part 1 (technical details) and Part 2 (real-world lessons).
Get Started with MistKit
MistKit v1.0 Alpha is available as an open-source Swift package with working Celestra and Bushel CLI examples. Built using swift-openapi-generator for type-safe CloudKit access.
Quick Example:
// Add to Package.swift
dependencies: [
.package(url: "https://github.com/brightdigit/MistKit.git",
from: "1.0.0-alpha.3")
]
// Server-to-Server Authentication
let service = try CloudKitService(
container: "iCloud.com.example.MyApp",
environment: .production,
database: .public,
tokenManager: ServerToServerTokenManager(
keyID: keyID,
privateKey: privateKey
)
)
// Type-safe operations
let records = try await service.queryRecords(
recordType: "Article",
filter: .greaterThan("publishDate", .date(cutoff))
)
Resources:
- Repository: github.com/brightdigit/MistKit
- Documentation: Complete API Reference
- Read the Full Series:
- Examples: Celestra and Bushel CLI Tools
I'd love to hear about your experiences with AI-assisted development and CloudKit projects.
Happy building!
Leo