swift-actor-persistence

Installation
Summary

Thread-safe data persistence in Swift using actors with in-memory cache and file-backed storage.

  • Implements an actor-based repository pattern that eliminates data races at compile time, replacing manual synchronization with Swift's actor model
  • Combines fast O(1) in-memory lookups with atomic file persistence, supporting any Codable & Identifiable model type
  • Provides synchronous initialization to avoid async complexity, with automatic await enforcement on all public API calls
  • Designed for offline-first apps, local user data storage, and concurrent access patterns in iOS/macOS applications
SKILL.md

Swift Actors for Thread-Safe Persistence

Patterns for building thread-safe data persistence layers using Swift actors. Combines in-memory caching with file-backed storage, leveraging the actor model to eliminate data races at compile time.

When to Activate

  • Building a data persistence layer in Swift 5.5+
  • Need thread-safe access to shared mutable state
  • Want to eliminate manual synchronization (locks, DispatchQueues)
  • Building offline-first apps with local storage

Core Pattern

Actor-Based Repository

The actor model guarantees serialized access — no data races, enforced by the compiler.

public actor LocalRepository<T: Codable & Identifiable> where T.ID == String {
Related skills
Installs
3.4K
GitHub Stars
179.7K
First Seen
Feb 17, 2026