ios-persistence
Standards for SwiftData, Core Data, and Local Storage. Use when implementing SwiftData, Core Data models, or local persistence in iOS. (triggers: **/*.xcdatamodeld, **/*Model.swift, PersistentContainer, FetchRequest, ManagedObject, Query, ModelContainer, Repository)
Best use case
ios-persistence is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Standards for SwiftData, Core Data, and Local Storage. Use when implementing SwiftData, Core Data models, or local persistence in iOS. (triggers: **/*.xcdatamodeld, **/*Model.swift, PersistentContainer, FetchRequest, ManagedObject, Query, ModelContainer, Repository)
Teams using ios-persistence should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/ios-persistence/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How ios-persistence Compares
| Feature / Agent | ios-persistence | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Standards for SwiftData, Core Data, and Local Storage. Use when implementing SwiftData, Core Data models, or local persistence in iOS. (triggers: **/*.xcdatamodeld, **/*Model.swift, PersistentContainer, FetchRequest, ManagedObject, Query, ModelContainer, Repository)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# iOS Persistence Standards ## **Priority: P0** ## Implementation Guidelines ### SwiftData (Current iOS 17+) - **Models**: Use the **`@Model`** macro for your Swift classes. - **Container**: Use **`@MainActor`** for configuring the `ModelContainer`. - **UI State**: Use **`@Query`** for reactive data fetching in **SwiftUI** views. - **Context API**: Access `modelContext` from the `@Environment` for CRUD (**modelContext.insert**, **modelContext.delete**, **modelContext.save**). ### Core Data (Stable & Large Legacy) - **Mapping**: Define your entities and attributes in the **`.xcdatamodeld`** file. - **Stack**: Use **`NSPersistentContainer`** to encapsulate the SQLite store. - **Background**: Perform heavy writes on `newBackgroundContext()` to avoid UI lag. - **Main Context**: Use **`viewContext`** only for UI thread operations. ### Local Persistence (Small Data) - **Keychain**: Use for **Auth tokens**, passwords, and PII. Never store sensitive keys in `UserDefaults`. - **UserDefaults**: Use for lightweight settings/flags (e.g., `isDarkModeEnabled`). - **File System**: Save images or PDFs to the **`Documents`** directory using `Data.write(to:)`. ## Anti-Patterns - **No heavy I/O on ViewContext**: Use private background contexts. - **No string-based predicates**: Use KeyPaths or generated helpers. - **No missing merge strategy**: Set mergePolicy explicitly (e.g., mergeByPropertyObjectTrump). ## References - [SwiftData & Core Data Implementation](references/implementation.md)
Related Skills
swift-actor-persistence
Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.
android-persistence
Standards for Room Database and DataStore. Use when implementing Room database schemas or DataStore preferences in Android. (triggers: **/*Dao.kt, **/*Database.kt, **/*Entity.kt, @Dao, @Entity, RoomDatabase)
langgraph-persistence
INVOKE THIS SKILL when your LangGraph needs to persist state, remember conversations, travel through history, or configure subgraph checkpointer scoping. Covers checkpointers, thread_id, time travel, Store, and subgraph persistence modes.
vibecoder-guide-legacy
Guides VibeCoder (non-technical users) through natural language development (legacy). Use when user mentions どうすればいい, 次は何, 使い方, 困った, help, what should I do. Do NOT load for: 技術者向け作業, 直接的な実装指示, レビュー.
ui
Generates UI components and feedback forms. Use when user mentions コンポーネント, component, UI, ヒーロー, hero, フォーム, form, フィードバック, feedback, 問い合わせ. Do NOT load for: 認証機能, バックエンド実装, データベース操作, ビジネスロジック.
troubleshoot
Guides diagnosis and resolution when problems occur. Use when user mentions 動かない, エラーが出た, 壊れた, うまくいかない, broken, doesn't work, error. Do NOT load for: 正常なビルド, 新機能実装, レビュー.
setup
Sets up new projects and generates workflow files like CLAUDE.md, AGENTS.md, Plans.md. Use when user mentions セットアップ, setup, 初期化, initialize, 新規プロジェクト, ワークフローファイル生成. Do NOT load for: 実装作業, レビュー, ビルド検証, デプロイ.
session-memory
Manages cross-session learning and memory persistence. Use when user mentions 前回何をした, 履歴, 過去の作業, セッション記録, continue from before, session history. Do NOT load for: 実装作業, レビュー, 一時的な情報.
session-init
Initializes session with environment check and task status overview. Use when user mentions セッション開始, 作業開始, 状況確認, what should I work on, start session. Do NOT load for: 実装作業, レビュー, セッション途中の作業.
review
Reviews code for quality, security, performance, and accessibility issues. Use when user mentions レビュー, review, コードレビュー, セキュリティ, パフォーマンス, 品質チェック, セルフレビュー, PR, diff, 変更確認. Do NOT load for: 実装作業, 新機能開発, バグ修正, セットアップ.
principles
Provides development principles, guidelines, and VibeCoder guidance. Use when user mentions 原則, principles, ガイドライン, guidelines, VibeCoder, 安全性, safety, 差分編集, diff-aware. Triggers: 原則, principles, ガイドライン, VibeCoder, 安全性, 差分編集. Do not use for actual implementation - use impl skill instead.
plans-management
Manages Plans.md tasks and marker operations. Use when user mentions タスクを追加, Plans.md更新, 完了マーク, タスク状態変更, add task, update plans, mark complete. Do NOT load for: 実装作業, レビュー, Plans.md以外のファイル操作.