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

Core Data Pro

skill-laxrajpurohit-swift-skills-pro-core-data-pro · by laxrajpurohit

Use when working with Core Data — modeling entities, NSPersistentContainer setup, background contexts, fetch requests, batch operations, and migrations.

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

Install

$ agentstack add skill-laxrajpurohit-swift-skills-pro-core-data-pro

✓ 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 Used
  • 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-laxrajpurohit-swift-skills-pro-core-data-pro)

Reliability & compatibility

Security review passed
0 installs to date
no reviews yet
2mo 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 Core Data Pro? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Core Data Pro

Use Core Data correctly: safe contexts, efficient fetches, clean migrations. (For new apps, also consider SwiftData — see swiftdata-pro.)

When to use

  • Existing Core Data stacks, or apps needing fine-grained control.
  • Fixing threading crashes, slow fetches, or migration failures.

Trigger: /core-data-pro.

Core principles

  • The view context is main-queue only; never touch it off the main thread.
  • Do writes/imports on a background context, then merge.
  • NSManagedObjects belong to their context — don't pass them across threads, pass IDs.
  • Fetch only what you need (predicates, limits, batching).

Stack setup

let container = NSPersistentContainer(name: "Model")
container.loadPersistentStores { _, error in
    if let error { fatalError("Store load failed: \(error)") }
}
container.viewContext.automaticallyMergesChangesFromParent = true

Threading

❌ Background work on the view context (crashes / corruption)

DispatchQueue.global().async {
    let obj = Item(context: container.viewContext)   // wrong queue
}

✅ Background context with perform

container.performBackgroundTask { context in
    let obj = Item(context: context)
    obj.title = "New"
    try? context.save()   // merges into viewContext automatically
}

Pass object IDs across contexts, not objects:

let id = obj.objectID
container.performBackgroundTask { ctx in
    let bgObj = ctx.object(with: id)
}

Fetching efficiently

❌ Fetch everything, filter in Swift

let all = try context.fetch(Item.fetchRequest())
let recent = all.filter { $0.date > cutoff }     // loads the whole table

✅ Predicate + sort + limit in the request

let req = Item.fetchRequest()
req.predicate = NSPredicate(format: "date > %@", cutoff as NSDate)
req.sortDescriptors = [NSSortDescriptor(key: "date", ascending: false)]
req.fetchLimit = 50
let recent = try context.fetch(req)

Use fetchBatchSize for large lists; NSFetchedResultsController (UIKit) or @FetchRequest (SwiftUI) for table/list binding.

Batch operations

For bulk delete/update, skip loading objects into memory:

let delete = NSBatchDeleteRequest(fetchRequest: Item.fetchRequest())
try context.execute(delete)
// then merge changes into viewContext

Migrations

  • Lightweight migration handles simple schema changes — keep model versions and set

shouldInferMappingModelAutomatically = true.

  • Complex changes need a mapping model / custom NSEntityMigrationPolicy. Never edit a

shipped model version in place; add a new version.

Common mistakes checklist

  • [ ] Accessing the view context off the main thread.
  • [ ] Creating/editing objects on a context's wrong queue (no perform).
  • [ ] Passing NSManagedObjects across threads instead of objectID.
  • [ ] Fetch-all then filter in Swift instead of an NSPredicate.
  • [ ] No fetchLimit/fetchBatchSize on large fetches.
  • [ ] Looping deletes instead of NSBatchDeleteRequest.
  • [ ] Editing a shipped model version instead of adding a new one.

Output format (when reviewing)

Per issue: file:line, rule, before/after. Lead with threading violations (crash risk) and migration hazards.

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.