swiftdata-pro — скилл для Claude Code: проверка и улучшение
Скилл для написания, проверки и улучшения кода SwiftData с соблюдением современных API и best practices. Нужен, если вы работаете с SwiftData в проектах на Swift.
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-codeЧто делает swiftdata-pro
swiftdata-pro анализирует SwiftData-код по пяти направлениям: базовые правила фреймворка, безопасность и поддерживаемость предикатов, особенности CloudKit, возможности индексирования для iOS 18+ и паттерны наследования классов для iOS 26+. Скилл загружает только релевантные справочники — если проект не использует CloudKit, эта проверка не запускается.
При анализе скилл находит настоящие проблемы, а не придираться к стилю. Проверяет удаление связей, корректность работы @Query внутри SwiftUI-представлений, предикаты, которые падают в runtime (например, isEmpty == false), и правильность структуры проекта. Если вы просите улучшить код, скилл применяет исправления сразу, если только написать отчёт — показывает проблемы по файлам с примерами до и после.
Скилл ориентирован на Swift 6.2 и не предложит Core Data вместо SwiftData без вашего согласия. Не добавляет внешних фреймворков самостоятельно.
Какие задачи решает
- Проверить SwiftData-код на соответствие современным API и best practices
- Найти ошибки в предикатах, которые приводят к краху во время выполнения
- Убедиться, что delete rules и relationships настроены правильно
- Оптимизировать индексирование для iOS 18+
- Проверить CloudKit-специфичные ограничения в моделях
Примеры запросов агенту
- Проверь код в `DestinationListView.swift` на ошибки SwiftData
- Напиши скилл swiftdata-pro для моделей в этом проекте, обнови их по best practices
- Проанализируй предикаты в этом файле — есть ли там опасные паттерны?
Как установить swiftdata-pro
1Через Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-code2Вручную: положить файлы
~/.claude/skills/swiftdata-pro/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/swiftdata-pro/
1Через Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a codex2Вручную: положить файлы
.agents/skills/swiftdata-pro/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a cursor2Вручную: положить файлы
.cursor/skills/swiftdata-pro/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install twostraws/SwiftData-Agent-Skill swiftdata-pro2Вручную: положить файлы
.github/skills/swiftdata-pro/SKILL.md1Через Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a gemini-cli2Командой платформы
gemini skills install https://github.com/twostraws/SwiftData-Agent-Skill --path swiftdata-proВручную: положить файлы
.devin/skills/swiftdata-pro/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Похожие
Вопросы о swiftdata-pro
Как установить swiftdata-pro в Claude Code?
Выполните npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a claude-code, затем откройте ~/.claude/skills/swiftdata-pro/SKILL.md. Для Cursor команда: npx skills add twostraws/SwiftData-Agent-Skill --skill swiftdata-pro -a cursor, файл будет в .cursor/skills/swiftdata-pro/SKILL.md.
Что делает swiftdata-pro?
Анализирует и улучшает SwiftData-код: проверяет предикаты на опасные паттерны, корректность связей и delete rules, особенности CloudKit и iOS 18+ индексирования. Находит реальные ошибки и показывает примеры исправлений.
Как skилл работает с CloudKit?
Если в проекте используется CloudKit, скилл дополнительно проверяет ограничения на уникальность, optionality полей и особенности eventual consistency. Для проектов без CloudKit эта проверка не запускается.
Исходный текст
SKILL.md · MIT
---
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<Destination> { $0.sights.isEmpty == false }
// After
#Predicate<Destination> { !$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<Destination>())
}
}
```
### 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.
© Paul Hudson · MIT · twostraws/SwiftData-Agent-Skill