AgentStack
Browse Sign in
Browse Why AgentStack Sell Docs
Sign in
SKILL verified MIT Self-run

Ios Data Model

skill-jakeintech-claude-ios-skills-ios-data-model · by Jakeintech

Design SwiftData schema from PRD specification or app analysis. Generates @Model classes with relationships, indexes, migrations, CloudKit sync preparation, and test fixtures. Uses context7 for current SwiftData docs.

No reviews yet
0 installs
30 views
0.0% view→install

Install

$ agentstack add skill-jakeintech-claude-ios-skills-ios-data-model

✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.

Security review

✓ Passed

No 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.

View the full security report →

Verified badge

Passed review? Show it. Paste this badge into your README, it links to the public security report.

AgentStack Verified badge Links to your public security report.
[![AgentStack Verified](https://agentstack.voostack.com/badges/verified.svg)](https://agentstack.voostack.com/security/report/skill-jakeintech-claude-ios-skills-ios-data-model)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
5mo ago

Declared compatibility

Claude CodeClaude Desktop

Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.

Preview Execution monitoring

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 →
Are you the author of Ios Data Model? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

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.md and brand book for app context (if no PRD)
  • $ARGUMENTS if user provided inline description

Step 2: Fetch Current SwiftData Docs

Before designing any schema, use context7 MCP to fetch current SwiftData documentation:

  1. Use resolve-library-id to find "SwiftData apple developer"
  2. Query for @Model, @Relationship, @Attribute patterns
  3. Query for ModelContainer configuration patterns
  4. Query for #Predicate and FetchDescriptor usage
  5. 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: .automatic for cross-device sync; .none for local-only
  • Schema versioning: wrap in VersionedSchema from 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:

  1. Write model tests using in-memory ModelContainer
  2. Test relationship cascade behavior
  3. Test unique constraint enforcement
  4. Test predicate correctness
  5. Then write the @Model implementations to make tests pass
  6. Use /ios-tdd for 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.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet, be the first.

Versions

  • v0.1.0 Imported from the upstream source.