重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
swiftdata-expert-skill by vanab/swiftdata-agent-skill
npx skills add https://github.com/vanab/swiftdata-agent-skill --skill swiftdata-expert-skill使用此技能,通过从 iOS 17 到当前更新的 Apple 文档模式,来构建、审查和强化 SwiftData 持久化架构。优先考虑数据完整性、迁移安全性、同步正确性和可预测的并发行为。
#Index、#Unique、HistoryDescriptor、DataStore、继承示例)。ModelContainer;没有它,插入会失败,获取结果为空。SchemaMigrationPlan。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
rg "modelContainer\\(|ModelContainer\\(" -nrg "^@Model|#Unique|#Index|@Relationship|@Attribute|@Transient" -nrg "modelContext|mainContext|ModelContext\\(" -nrg "SchemaMigrationPlan|VersionedSchema|MigrationStage|fetchHistory|deleteHistory|historyToken" -nrg "cloudKitDatabase|iCloud|CloudKit|groupContainer|AppGroup|NSPersistentCloudKitContainer" -n.modelContainer(...) 修饰符或手动 ModelContainer(...)。save()。isUndoEnabled) 以及操作是在 mainContext 还是自定义上下文中进行。automatic、.private(...)、.none)。references/modeling-and-schema.md。references/model-context-and-lifecycle.md。references/querying-and-fetching.md。references/relationships-and-inheritance.md。references/migrations-and-history.md。references/cloudkit-sync.md。references/core-data-adoption.md。references/concurrency-and-actors.md。references/troubleshooting-and-updates.md。references/implementation-playbooks.md。.modelContainer(...) 已附加到应用或窗口根视图,并且包含了模型类型。@Attribute(.unique) 或 #Unique 约束,并依赖插入-更新行为。.cascade 与 .nullify)并检查是否存在无限制的 delete(model:where:)。isUndoEnabled: true 并且更改通过 mainContext 保存(不仅仅是后台上下文)。cloudKitDatabase。fetchHistory),配合令牌和作者过滤。historyTokenExpired:
FetchDescriptor 设置。@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
.modelContainer(for: [Trip.self, Accommodation.self])
}
}
let config = ModelConfiguration(isStoredInMemoryOnly: false)
let container = try ModelContainer(
for: Trip.self,
Accommodation.self,
configurations: config
)
struct TripListView: View {
@Query private var trips: [Trip]
init(searchText: String) {
let predicate = #Predicate<Trip> {
searchText.isEmpty || $0.name.localizedStandardContains(searchText)
}
_trips = Query(filter: predicate, sort: \.startDate, order: .forward)
}
var body: some View { List(trips) { Text($0.name) } }
}
do {
try modelContext.delete(
model: Trip.self,
where: #Predicate { $0.endDate < .now },
includeSubclasses: true
)
try modelContext.save()
} catch {
// 处理删除和保存失败。
}
references/modeling-and-schema.mdreferences/model-context-and-lifecycle.mdreferences/querying-and-fetching.mdreferences/relationships-and-inheritance.mdreferences/migrations-and-history.mdreferences/cloudkit-sync.mdreferences/core-data-adoption.mdreferences/concurrency-and-actors.mdreferences/troubleshooting-and-updates.mdreferences/implementation-playbooks.mdfetchLimit、偏移量、仅标识符获取)。ModelConfiguration 实现特定环境的行为(内存测试、CloudKit、应用组、只读存储)。cascade、nullify 等)。每周安装次数
48
仓库
GitHub 星标数
5
首次出现
2026年2月8日
安全审计
安装于
codex46
gemini-cli46
github-copilot46
kimi-cli46
amp46
opencode46
Use this skill to build, review, and harden SwiftData persistence architecture with Apple-documented patterns from iOS 17 through current updates. Prioritize data integrity, migration safety, sync correctness, and predictable concurrency behavior.
#Index, #Unique, HistoryDescriptor, DataStore, inheritance examples).ModelContainer wiring before debugging data issues; without it, inserts fail and fetches are empty.SchemaMigrationPlan when needed.rg "modelContainer\\(|ModelContainer\\(" -nrg "^@Model|#Unique|#Index|@Relationship|@Attribute|@Transient" -nrg "modelContext|mainContext|ModelContext\\(" -nrg "SchemaMigrationPlan|VersionedSchema|MigrationStage|fetchHistory|deleteHistory|historyToken" -nrg "cloudKitDatabase|iCloud|CloudKit|groupContainer|AppGroup|NSPersistentCloudKitContainer" -n.modelContainer(...) modifier or manual ModelContainer(...).save() is required.isUndoEnabled) and whether operations occur on mainContext or custom contexts.automatic, .private(...), .none).references/modeling-and-schema.md.references/model-context-and-lifecycle.md.references/querying-and-fetching.md.references/relationships-and-inheritance.md.references/migrations-and-history.md.references/cloudkit-sync.md.references/implementation-playbooks.md..modelContainer(...) is attached at app or window root and the model type is included.@Attribute(.unique) or #Unique constraints and rely on insert-upsert behavior..cascade vs .nullify) and check for unbounded delete(model:where:).isUndoEnabled: true and that changes are saved via mainContext (not only background context).@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
RootView()
}
.modelContainer(for: [Trip.self, Accommodation.self])
}
}
let config = ModelConfiguration(isStoredInMemoryOnly: false)
let container = try ModelContainer(
for: Trip.self,
Accommodation.self,
configurations: config
)
struct TripListView: View {
@Query private var trips: [Trip]
init(searchText: String) {
let predicate = #Predicate<Trip> {
searchText.isEmpty || $0.name.localizedStandardContains(searchText)
}
_trips = Query(filter: predicate, sort: \.startDate, order: .forward)
}
var body: some View { List(trips) { Text($0.name) } }
}
do {
try modelContext.delete(
model: Trip.self,
where: #Predicate { $0.endDate < .now },
includeSubclasses: true
)
try modelContext.save()
} catch {
// Handle delete and save failures.
}
references/modeling-and-schema.mdreferences/model-context-and-lifecycle.mdreferences/querying-and-fetching.mdreferences/relationships-and-inheritance.mdreferences/migrations-and-history.mdreferences/cloudkit-sync.mdreferences/core-data-adoption.mdreferences/concurrency-and-actors.mdreferences/troubleshooting-and-updates.mdfetchLimit, offsets, identifier-only fetches) for scalability.ModelConfiguration for environment-specific behavior (in-memory tests, CloudKit, app groups, read-only stores).cascade, nullify, and others).Weekly Installs
48
Repository
GitHub Stars
5
First Seen
Feb 8, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex46
gemini-cli46
github-copilot46
kimi-cli46
amp46
opencode46
Kotlin Exposed ORM 模式指南:DSL查询、DAO、事务管理与生产配置
1,300 周安装
Azure Data Tables Python 技能包 - 高效管理 Azure 表存储数据
1 周安装
Azure Cosmos Java SDK 技能包 - 高效开发云原生数据库应用
1 周安装
Azure Cosmos DB Python SDK 技能包 - 云端NoSQL数据库开发与集成指南
1 周安装
Azure App Configuration Java 客户端库 - 云应用配置管理解决方案
1 周安装
Azure AI VoiceLive Python 技能包:实现实时语音处理的AI开发工具
1 周安装
Azure AI Vision图像分析Python技能 - 使用Python进行智能图像识别与内容分析
1 周安装
references/core-data-adoption.md.references/concurrency-and-actors.md.references/troubleshooting-and-updates.md.cloudKitDatabase if multiple containers exist.fetchHistory) with token + author filtering.historyTokenExpired appears:
FetchDescriptor settings.references/implementation-playbooks.md