core-data-patterns — community core-data-patterns, agile-maestro, community, ide skills, Claude Code, Cursor, Windsurf

v1.0.0

关于此技能

适用于需要高级 Core Data 持久性模式的 macOS App Development Agents。 Core Data persistence patterns for macOS apps. Stack setup, CRUD operations, relationships, migrations.

brdohman brdohman
[2]
[0]
更新于: 3/14/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reference-Only Page Review Score: 7/11

This page remains useful for operators, but Killer-Skills treats it as reference material instead of a primary organic landing page.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution
Review Score
7/11
Quality Score
33
Canonical Locale
en
Detected Body Locale
en

适用于需要高级 Core Data 持久性模式的 macOS App Development Agents。 Core Data persistence patterns for macOS apps. Stack setup, CRUD operations, relationships, migrations.

核心价值

赋予代理管理数据存储和检索的能力,使用 NSPersistentContainer 和 Swift actors,并提供高效的 Core Data 集成和持久性的设置指南。

适用 Agent 类型

适用于需要高级 Core Data 持久性模式的 macOS App Development Agents。

赋予的主要能力 · core-data-patterns

为 macOS 应用程序设置 NSPersistentContainer
实现 Swift actors 进行数据持久性
调试 macOS 应用程序中的 Core Data 持久性问题

! 使用限制与门槛

  • 需要 macOS 开发环境
  • 仅限 Core Data 持久性模式
  • 需要 Swift 编程语言

Why this page is reference-only

  • - Current locale does not satisfy the locale-governance contract.
  • - The underlying skill quality score is below the review floor.

Source Boundary

The section below is supporting source material from the upstream repository. Use the Killer-Skills review above as the primary decision layer.

实验室 Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

常见问题与安装步骤

以下问题与步骤与页面结构化数据保持一致,便于搜索引擎理解页面内容。

? FAQ

core-data-patterns 是什么?

适用于需要高级 Core Data 持久性模式的 macOS App Development Agents。 Core Data persistence patterns for macOS apps. Stack setup, CRUD operations, relationships, migrations.

如何安装 core-data-patterns?

运行命令:npx killer-skills add brdohman/agile-maestro/core-data-patterns。支持 Cursor、Windsurf、VS Code、Claude Code 等 19+ IDE/Agent。

core-data-patterns 适用于哪些场景?

典型场景包括:为 macOS 应用程序设置 NSPersistentContainer、实现 Swift actors 进行数据持久性、调试 macOS 应用程序中的 Core Data 持久性问题。

core-data-patterns 支持哪些 IDE 或 Agent?

该技能兼容 Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer。可使用 Killer-Skills CLI 一条命令通用安装。

core-data-patterns 有哪些限制?

需要 macOS 开发环境;仅限 Core Data 持久性模式;需要 Swift 编程语言。

安装步骤

  1. 1. 打开终端

    在你的项目目录中打开终端或命令行。

  2. 2. 执行安装命令

    运行:npx killer-skills add brdohman/agile-maestro/core-data-patterns。CLI 会自动识别 IDE 或 AI Agent 并完成配置。

  3. 3. 开始使用技能

    core-data-patterns 已启用,可立即在当前项目中调用。

! 参考页模式

此页面仍可作为安装与查阅参考,但 Killer-Skills 不再把它视为主要可索引落地页。请优先阅读上方评审结论,再决定是否继续查看上游仓库说明。

Imported Repository Instructions

The section below is supporting source material from the upstream repository. Use the Killer-Skills review above as the primary decision layer.

Supporting Evidence

core-data-patterns

安装 core-data-patterns,这是一款面向AI agent workflows and automation的 AI Agent Skill。支持 Claude Code、Cursor、Windsurf,一键安装。

SKILL.md
Readonly
Imported Repository Instructions
The section below is supporting source material from the upstream repository. Use the Killer-Skills review above as the primary decision layer.
Supporting Evidence

Core Data Skill

Overview

Core Data persistence patterns for macOS apps.

Stack Setup

swift
1actor PersistenceController { 2 static let shared = PersistenceController() 3 4 let container: NSPersistentContainer 5 6 init(inMemory: Bool = false) { 7 container = NSPersistentContainer(name: "AppModel") 8 9 if inMemory { 10 container.persistentStoreDescriptions.first?.url = URL(fileURLWithPath: "/dev/null") 11 } 12 13 container.loadPersistentStores { _, error in 14 if let error { 15 fatalError("Core Data failed: \(error)") 16 } 17 } 18 19 container.viewContext.automaticallyMergesChangesFromParent = true 20 container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy 21 } 22 23 var viewContext: NSManagedObjectContext { 24 container.viewContext 25 } 26 27 func newBackgroundContext() -> NSManagedObjectContext { 28 container.newBackgroundContext() 29 } 30}

Entity Pattern

swift
1@objc(Item) 2public class Item: NSManagedObject { 3 @NSManaged public var id: UUID 4 @NSManaged public var title: String 5 @NSManaged public var createdAt: Date 6 @NSManaged public var updatedAt: Date 7} 8 9extension Item { 10 @nonobjc public class func fetchRequest() -> NSFetchRequest<Item> { 11 NSFetchRequest<Item>(entityName: "Item") 12 } 13 14 static func create(in context: NSManagedObjectContext, title: String) -> Item { 15 let item = Item(context: context) 16 item.id = UUID() 17 item.title = title 18 item.createdAt = Date() 19 item.updatedAt = Date() 20 return item 21 } 22}

Fetch Requests

swift
1// Basic fetch 2let request = Item.fetchRequest() 3request.predicate = NSPredicate(format: "title CONTAINS[cd] %@", searchText) 4request.sortDescriptors = [NSSortDescriptor(keyPath: \Item.createdAt, ascending: false)] 5request.fetchLimit = 50 6request.fetchBatchSize = 20 7 8let items = try context.fetch(request)

SwiftUI Integration

swift
1struct ItemListView: View { 2 @FetchRequest( 3 sortDescriptors: [SortDescriptor(\.createdAt, order: .reverse)], 4 animation: .default 5 ) 6 private var items: FetchedResults<Item> 7 8 var body: some View { 9 List(items) { item in 10 Text(item.title) 11 } 12 } 13}

Background Operations

swift
1func importData(_ data: [ImportItem]) async throws { 2 let context = PersistenceController.shared.newBackgroundContext() 3 4 try await context.perform { 5 for item in data { 6 let entity = Item(context: context) 7 entity.id = UUID() 8 entity.title = item.title 9 } 10 try context.save() 11 } 12}

Migrations

  1. Create new model version in Xcode
  2. Set as current version
  3. Enable automatic migration:
swift
1description.shouldMigrateStoreAutomatically = true 2description.shouldInferMappingModelAutomatically = true

Testing

swift
1final class CoreDataTests: XCTestCase { 2 var controller: PersistenceController! 3 4 override func setUp() { 5 controller = PersistenceController(inMemory: true) 6 } 7}

CloudKit Container (DA-4)

For iCloud sync, use NSPersistentCloudKitContainer instead of NSPersistentContainer:

swift
1let container = NSPersistentCloudKitContainer(name: "AppModel") 2// CloudKit sync is automatic after setup 3// Conflict resolution uses NSMergeByPropertyObjectTrumpMergePolicy (local wins)

CloudKit schema migration: CloudKit schemas are additive only — you can add fields/entities but never remove or rename them. Plan schema carefully.

Derived Attributes (DA-5)

Use derived attributes for denormalized counts/aggregates to avoid expensive fetch requests:

In the Xcode model editor: select attribute > Data Model Inspector > Derived > set derivation expression.

// Count of children: "children.@count"
// Latest date: "children.@max.createdAt"

Derived attributes are computed by Core Data automatically on save. They avoid N+1 query problems.

Abstract Entity Patterns (DA-6)

Use abstract entities for shared attributes across entity types:

AbstractBaseEntity (abstract)
  ├── id: UUID
  ├── createdAt: Date
  ├── updatedAt: Date
  │
  ├── TaskEntity (concrete)
  │   └── title: String
  │
  └── NoteEntity (concrete)
      └── body: String

When to use: Multiple entities share 3+ identical attributes. Avoid when: Only id/createdAt/updatedAt are shared (just add them to each entity directly — the inheritance complexity isn't worth it for 3 fields).

Core Data Debugging (DA-7)

Launch arguments for diagnostics:

ArgumentWhat It Shows
-com.apple.CoreData.SQLDebug 1SQL queries executed
-com.apple.CoreData.SQLDebug 3SQL + bind variables
-com.apple.CoreData.MigrationDebug 1Migration steps
-com.apple.CoreData.ConcurrencyDebug 1Thread violations
-com.apple.CoreData.CloudKitDebug 1CloudKit sync activity

Add in Xcode: Edit Scheme > Run > Arguments > Arguments Passed On Launch.

Instruments Core Data template: Shows fetch counts, fault counts, save durations. Use when debugging performance. High fault count = objects being accessed that weren't prefetched.

Data Integrity Constraints (DA-8)

Unique Constraints

Set in Xcode model editor: select entity > Data Model Inspector > Constraints. Prevents duplicate entries on the constrained fields.

// Entity: Tag
// Unique constraints: name
// → Two Tags with the same name will merge instead of creating duplicates

Validation Rules

Add in model editor per attribute: Min Value, Max Value, Regex for strings.

swift
1// Programmatic validation (for complex rules) 2override func validateForInsert() throws { 3 try super.validateForInsert() 4 guard title.count >= 1 else { 5 throw ValidationError.titleRequired 6 } 7}

Fetch Request Validation

Always validate predicates against the model at development time:

swift
1// Use typed key paths instead of string-based predicates where possible 2request.predicate = NSPredicate(format: "%K == %@", #keyPath(Item.status), "active")

相关技能

寻找 core-data-patterns 的替代方案 (Alternative) 或可搭配使用的同类 community Skill?探索以下相关开源技能。

查看全部

openclaw-release-maintainer

Logo of openclaw
openclaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

333.8k
0
AI

widget-generator

Logo of f
f

为prompts.chat的信息反馈系统生成可定制的插件小部件

149.6k
0
AI

flags

Logo of vercel
vercel

React 框架

138.4k
0
浏览器

pr-review

Logo of pytorch
pytorch

Python中具有强大GPU加速的张量和动态神经网络

98.6k
0
开发者工具