swift-actor-persistence

Create actor-based Swift repositories with in-memory cache and atomic file persistence.

7|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/Davie521/claude-skills --skill swift-actor-persistence-davie521
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-actor-persistence
Source: https://github.com/Davie521/claude-skills/tree/main/plugins/swift/skills/swift-actor-persistence
Command: npx skills add https://github.com/Davie521/claude-skills --skill swift-actor-persistence-davie521

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Thread-safe data persistence in Swift is hard when multiple parts of an app access shared state. This Skill provides an actor-based pattern that combines an in-memory cache with file-backed storage to eliminate data races by design.

Core Features & Use Cases

  • Actor-based repository providing serialized access to generic Codable & Identifiable models
  • In-memory cache with durable, atomic file persistence to disk
  • Synchronous initialization to simplify startup while maintaining safety and performance
  • Suitable for offline-first apps requiring reliable local storage and consistent reads

Quick Start

Create a LocalRepository for your model and use await to persist and read data.

Frequently Asked Questions about swift-actor-persistence

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle thread-safe data persistence in Swift when multiple parts of my app access shared state?

Thread-safe data persistence in Swift is achieved using an actor-based repository pattern that serializes access to shared state, combining an in-memory cache with file-backed storage to eliminate data races by design.

How do I implement a local repository for Codable and Identifiable models in Swift?

Implement a local repository for Codable and Identifiable models by creating an actor-backed class that exposes save, delete, find, and loadAll APIs, using await to interact with the in-memory cache and durable file persistence.

Can I use Swift actors for offline-first local storage across general domain models?

Yes, Swift actors can be used for offline-first local storage across general domain models, provided the models conform to Codable and Identifiable, ensuring consistent reads and reliable atomic writes to disk.

What is the best way to serialize concurrent access to local storage in Swift 5.5+?

The best way to serialize concurrent access to local storage in Swift 5.5+ is using actors, which provide serialized access to an in-memory cache combined with atomic file persistence, ensuring safe concurrent operations.

Does synchronous initialization work with actor-based persistence for app startup loading?

Yes, the actor-based persistence pattern supports synchronous initialization to simplify app startup loading while maintaining safety and performance, loading cached data immediately before allowing subsequent concurrent read operations.