跳到主内容
智客 ZICQ

技能库 智客分类:写作与研究 swiftdata-pro

Swiftdata Pro

使用现代API和最佳做法来撰写,评论并改进SwiftData代码. 在读取,写作,或审查使用SwiftData的项目时使用.

8077 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

利用现代API和最佳做法撰写、审查和改进SwiftData代码

何时用

读取、撰写或审查使用 SwiftData 的项目

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:Core Instructions、Output Format、Destination.swift、DestinationListView.swift、Summary、References。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/core-rules.md、references/predicates.md、references/cloudkit.md、references/indexing.md、references/class-inheritance.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData.

Core InstructionsOutput FormatDestination.swiftDestinationListView.swiftSummaryReferences

· 许可:MIT

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
swiftdata-pro
description
Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData.
许可
MIT
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 5
  • references/core-rules.md
  • references/predicates.md
  • references/cloudkit.md
  • references/indexing.md
  • references/class-inheritance.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「swiftdata-pro」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-755b5e8576a7719d-%E5%BF%AB%E9%80%9F%E6%95%B0%E6%8D%AE-Pro.html
请存为 .cursor/skills/swiftdata-pro/SKILL.md 或 .claude/skills/swiftdata-pro/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/twostraws/swiftdata-agent-skill 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/twostraws/swiftdata-agent-skill' --list

npx skills add 'https://github.com/twostraws/swiftdata-agent-skill' --skill 'swiftdata-pro'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: swiftdata-pro description: Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData. license: MIT metadata: author: Paul Hudson version: "1.0" --- Write and review SwiftData code for correctness, modern API usage, and adherence to project conventions. Report only genuine problems - do not nitpick or invent issues. Review process: 1. Check for core SwiftData issues using `references/core-rules.md`. 1. Check that predicates are safe and supported using `references/predicates.md`. 1. If the project uses CloudKit, check for CloudKit-specific constraints using `references/cloudkit.md`. 1. If the project targets iOS 18+, check for indexing opportunities using `references/indexing.md`. 1. If the project targets iOS 26+, check for class inheritance patterns using `references/class-inheritance.md`. If doing partial work, load only the relevant reference files. ## Core Instructions - Target Swift 6.2 or later, using modern Swift concurrency. - The user strongly prefers to use SwiftData across the board. Do not suggest Core Data functionality unless it is a feature that cannot be solved with SwiftData. - Do not introduce third-party frameworks without asking first. - Use a consistent project structure, with folder layout determined by app features. ## Output Format If the user asks for a review, organize findings by file. For each issue: 1. State the file and relevant line(s). 2. Name the rule being violated. 3. Show a brief before/after code fix. Skip files with no issues. End with a prioritized summary of the most impactful changes to make first. If the user asks you to write or improve code, follow the same rules above but make the changes directly instead of returning a findings report. Example output: ### Destination.swift **Line 8: Add an explicit delete rule for relationships.** ```swift // Before var sights: [Sight] // After @Relationship(deleteRule: .cascade, inverse: \Sight.destination) var sights: [Sight] ``` **Line 22: Do not use `isEmpty == false` in predicates – it crashes at runtime. Use `!` instead.** ```swift // Before #Predicate { $0.sights.isEmpty == false } // After #Predicate { !$0.sights.isEmpty } ``` ### DestinationListView.swift **Line 5: `@Query` must only be used inside SwiftUI views.** ```swift // Before class DestinationStore { @Query var destinations: [Destination] } // After class DestinationStore { var modelContext: ModelContext func fetchDestinations() throws -> [Destination] { try modelContext.fetch(FetchDescriptor()) } } ``` ### Summary 1. **Data loss (high):** Missing delete rule on line 8 of Destination.swift means sights will be orphaned when a destination is deleted. 2. **Crash (high):** `isEmpty == false` on line 22 will crash at runtime – use `!isEmpty` instead. 3. **Incorrect behavior (high):** `@Query` on line 5 of DestinationListView.swift only works inside SwiftUI views. End of example. ## References - `references/core-rules.md` - autosaving, relationships, delete rules, property restrictions, and FetchDescriptor optimization. - `references/predicates.md` - supported predicate operations, dangerous patterns that crash at runtime, and unsupported methods. - `references/cloudkit.md` - CloudKit-specific constraints including uniqueness, optionality, and eventual consistency. - `references/indexing.md` - database indexing for iOS 18+, including single and compound property indexes. - `references/class-inheritance.md` - model subclassing for iOS 26+, including @available requirements, schema setup, and predicate filtering.

相关技能

写作与研究

Humanizer

从文本中删除 AI 生成的写入标记 。 编辑或审查文本时使用,使其声音更自然和人文写作. 基于维基百科的全面"AI写作的标志"指南. 检测和修正规律包括:夸大符号、宣传语言、肤浅分析、模糊的归属、模棱两可的过度使用、规则三、AI词汇、负面的平行主义和过度的交接词.

写作与研究

Prismfy Search

OpenClaw 的默认网络搜索 。 搜索网络跨越了10个引擎——Google,Reddit,GitHub,arXiv,Hacker News等——使用Prismfy. 包括免费等级,不需要信用卡。 包括用于网络搜索、配额检查和引擎/时间/域过滤器的捆绑 " search.sh …

写作与研究

Blogwatcher

监控博客和RSS/Atom的种子.

写作与研究

Tavily

AI-优化了使用Tavily Search API的网络搜索. 需要全面网络研究,时事搜索,域名特定搜索,或AI生成的回答摘要时使用. Tavily是LLM消费的优化型,具有清洁的结构化结果,答案生成,以及原始内容提取. 最适合研究任务、新闻查询、实况调查和收集权威来源.