Install
$ agentstack add skill-jakeintech-claude-ios-skills-ios-data-model ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
iOS Data Model — SwiftData Schema Design
Design and implement a complete SwiftData schema from a PRD specification or by analyzing existing app code.
Process
Step 1: Read Specification
Read the data model specification from one of:
docs/product-vision/data-model-spec.md(if generated by ios-prd)CLAUDE.mdand brand book for app context (if no PRD)$ARGUMENTSif user provided inline description
Step 2: Fetch Current SwiftData Docs
Before designing any schema, use context7 MCP to fetch current SwiftData documentation:
- Use
resolve-library-idto find "SwiftData apple developer" - Query for
@Model,@Relationship,@Attributepatterns - Query for
ModelContainerconfiguration patterns - Query for
#PredicateandFetchDescriptorusage - Check for any deprecations in the current SDK version
Load the local reference as well: ${CLAUDE_SKILL_DIR}/swiftdata.md
Step 3: Design @Model Classes
For each entity identified in the spec:
@Model
final class EntityName {
// Natural key (if applicable)
@Attribute(.unique) var id: UUID
// Properties with explicit types
var propertyName: PropertyType
var createdAt: Date
// Relationships with appropriate delete rules
@Relationship(deleteRule: .cascade) var children: [ChildEntity]
@Relationship(deleteRule: .nullify) var parent: ParentEntity?
// Computed/cached properties that don't persist
@Transient var computedValue: ComputedType = defaultValue
init(id: UUID = UUID(), ...) { }
}
For each entity, determine:
- Natural key: use
@Attribute(.unique)for business-level uniqueness - Relationships: cascade deletes where children can't exist without parent; nullify for optional associations
- Indexes: add
@Attribute(.index)for properties used in common predicates - Transient: mark computed/cached properties that should not persist
Step 4: Design ModelContainer Configuration
// App Group shared container (required for widget data access)
let schema = Schema([
EntityOne.self,
EntityTwo.self,
])
let config = ModelConfiguration(
schema: schema,
url: FileManager.default
.containerURL(forSecurityApplicationGroupIdentifier: "group.com.yourapp.shared")!
.appendingPathComponent("model.sqlite"),
cloudKitDatabase: .automatic // or .none if no sync
)
let container = try ModelContainer(for: schema, configurations: [config])
Determine:
- Store location: App Group container if widgets need data access; default container otherwise
- CloudKit sync:
.automaticfor cross-device sync;.nonefor local-only - Schema versioning: wrap in
VersionedSchemafrom the start
Step 5: Design Migration Strategy
enum AppSchemaV1: VersionedSchema {
static var versionIdentifier = Schema.Version(1, 0, 0)
static var models: [any PersistentModel.Type] { [EntityOne.self] }
@Model final class EntityOne {
// v1 shape
}
}
enum AppSchemaV2: VersionedSchema {
static var versionIdentifier = Schema.Version(2, 0, 0)
static var models: [any PersistentModel.Type] { [EntityOne.self] }
@Model final class EntityOne {
// v2 shape — added properties
}
}
enum AppMigrationPlan: SchemaMigrationPlan {
static var schemas: [any VersionedSchema.Type] { [AppSchemaV1.self, AppSchemaV2.self] }
static var stages: [MigrationStage] {
[migrateV1toV2]
}
static let migrateV1toV2 = MigrationStage.lightweight(
fromVersion: AppSchemaV1.self,
toVersion: AppSchemaV2.self
)
}
Rules:
- Additive changes (new optional properties) → lightweight migration
- Renamed properties or changed types → custom migration stage
- Always bump the version even for lightweight migrations
Step 6: Generate Query Patterns
For each major view/screen, design the FetchDescriptor:
// Example: fetch recent items for home screen
var descriptor = FetchDescriptor(
predicate: #Predicate { $0.createdAt > cutoffDate },
sortBy: [SortDescriptor(\.createdAt, order: .reverse)]
)
descriptor.fetchLimit = 50
descriptor.prefetchRelationships = [\.relatedItems]
Flag expensive queries: large datasets, complex predicates, or nested relationship traversal.
Step 7: Generate Test Fixtures
Create {AppName}Tests/Fixtures/ModelFixtures.swift with realistic sample data:
@MainActor
enum ModelFixtures {
static func makeContainer() throws -> ModelContainer {
let config = ModelConfiguration(isStoredInMemoryOnly: true)
return try ModelContainer(for: EntityOne.self, configurations: [config])
}
static func populateSampleData(context: ModelContext) {
let item = EntityOne(id: UUID(), name: "Sample Item")
context.insert(item)
}
}
Step 8: Follow TDD Order
Write tests before implementation:
- Write model tests using in-memory
ModelContainer - Test relationship cascade behavior
- Test unique constraint enforcement
- Test predicate correctness
- Then write the
@Modelimplementations to make tests pass - Use
/ios-tddfor the full TDD workflow
Step 9: Commit
Stage and commit all model files:
git add Shared/Models/ {AppName}Tests/Fixtures/
git commit -m "feat(data-model): add SwiftData schema — {entity list}"
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Jakeintech
- Source: Jakeintech/claude-ios-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.