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)

25 stars

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

$curl -o ~/.claude/skills/ios-persistence/SKILL.md --create-dirs "https://raw.githubusercontent.com/ComeOnOliver/skillshub/main/skills/HoangNguyen0403/agent-skills-standard/ios-persistence/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ios-persistence/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How ios-persistence Compares

Feature / Agentios-persistenceStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/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

25
from ComeOnOliver/skillshub

Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.

android-persistence

25
from ComeOnOliver/skillshub

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

25
from ComeOnOliver/skillshub

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

25
from ComeOnOliver/skillshub

Guides VibeCoder (non-technical users) through natural language development (legacy). Use when user mentions どうすればいい, 次は何, 使い方, 困った, help, what should I do. Do NOT load for: 技術者向け作業, 直接的な実装指示, レビュー.

ui

25
from ComeOnOliver/skillshub

Generates UI components and feedback forms. Use when user mentions コンポーネント, component, UI, ヒーロー, hero, フォーム, form, フィードバック, feedback, 問い合わせ. Do NOT load for: 認証機能, バックエンド実装, データベース操作, ビジネスロジック.

troubleshoot

25
from ComeOnOliver/skillshub

Guides diagnosis and resolution when problems occur. Use when user mentions 動かない, エラーが出た, 壊れた, うまくいかない, broken, doesn't work, error. Do NOT load for: 正常なビルド, 新機能実装, レビュー.

setup

25
from ComeOnOliver/skillshub

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

25
from ComeOnOliver/skillshub

Manages cross-session learning and memory persistence. Use when user mentions 前回何をした, 履歴, 過去の作業, セッション記録, continue from before, session history. Do NOT load for: 実装作業, レビュー, 一時的な情報.

session-init

25
from ComeOnOliver/skillshub

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

25
from ComeOnOliver/skillshub

Reviews code for quality, security, performance, and accessibility issues. Use when user mentions レビュー, review, コードレビュー, セキュリティ, パフォーマンス, 品質チェック, セルフレビュー, PR, diff, 変更確認. Do NOT load for: 実装作業, 新機能開発, バグ修正, セットアップ.

principles

25
from ComeOnOliver/skillshub

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

25
from ComeOnOliver/skillshub

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以外のファイル操作.