Skip to content
Back to skills

Ios Persistence

ASecurity

Implement local persistence with SwiftData, Core Data, and Keychain. Use when setting up SwiftData models, Core Data stacks, or local persistence in iOS.

  • 549 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added June 6, 2026
developmentswift

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned June 6, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill ios-persistence --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ios Persistence?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ios Persistence
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-ios-persistence/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-ios-persistence)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ios-persistence
description: Implement local persistence with SwiftData, Core Data, and Keychain. Use when setting up SwiftData models, Core Data stacks, or local persistence in iOS.
metadata:
  triggers:
    files:
    - '**/*.xcdatamodeld'
    - '**/*Model.swift'
    keywords:
    - PersistentContainer
    - FetchRequest
    - ManagedObject
    - Query
    - ModelContainer
    - Repository
---
# iOS Persistence

## **Priority: P0**

## Implementation Workflow

1. **Choose storage tier** — SwiftData for iOS 17+, Core Data for legacy, Keychain for secrets, UserDefaults for flags only.
2. **Define models** — Use `@Model` macro (SwiftData) or `.xcdatamodeld` (Core Data).
3. **Configure container** — Use `@MainActor` for `ModelContainer` (SwiftData) or `NSPersistentContainer` (Core Data).
4. **Perform background writes** — Use `newBackgroundContext()` (Core Data) to avoid UI lag; never heavy I/O on `viewContext`.
5. **Secure sensitive data** — Use Keychain for tokens and PII; never store in `UserDefaults`.

See [SwiftData and Core Data implementation examples](references/implementation.md)

## 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)

Files in this skill

  • SKILL.md1.4 KB
  • evals/evals.json1.4 KB
  • references/implementation.md2.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.