swift-actor-persistence

Implement actor-based thread-safe persistence with in-memory cache and atomic file writes for Swift apps.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/sakamoto-family-smile/agent_monorepo --skill swift-actor-persistence-sakamoto-family-smile
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swift-actor-persistence
Source: https://github.com/sakamoto-family-smile/agent_monorepo/tree/main/.claude/skills/ecc/swift-actor-persistence
Command: npx skills add https://github.com/sakamoto-family-smile/agent_monorepo --skill swift-actor-persistence-sakamoto-family-smile

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Thread-safe data persistence for Swift apps by combining an in-memory cache with a durable, file-backed store using the actor model to prevent data races.

Core Features & Use Cases

  • Actor-based repository guarantees serialized access to shared state, eliminating data races.
  • In-memory cache with durable file persistence using atomic writes for crash resilience.
  • Generic over Codable & Identifiable, enabling reuse across multiple model types.
  • Async API exposure enforced by actor isolation, simplifying concurrency.

Quick Start

Instantiate LocalRepository with your Codable model and use its async methods to save, delete, find, and loadAll.

Frequently Asked Questions about swift-actor-persistence

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

FAQPage Schema
How do I make local file storage thread-safe in Swift?

Thread-safe Swift persistence is achieved by using an actor-based repository that serializes access to an in-memory cache and file-backed storage. This prevents data races when multiple components access shared state concurrently.

What is the best way to persist Codable objects locally in an iOS app?

Persisting Codable objects locally is best handled by a generic repository pattern that combines an in-memory cache with durable file storage. It exposes async methods to save, delete, find, and loadAll data while ensuring crash resilience through atomic file writes.

Can I use Swift actors for offline data caching?

Yes, you can use Swift actors for offline data caching. The repository loads data synchronously during initialization and maintains an in-memory cache backed by file storage, providing low-latency access for offline scenarios.

Does Swift actor isolation prevent data races with local storage?

Yes, actor isolation prevents data races with local storage by guaranteeing serialized access to shared state. The repository's async API enforces this isolation, simplifying concurrency management across multiple components accessing the same data.

How do I implement atomic file writes for Swift local storage?

Atomic file writes for Swift local storage are implemented within the repository's save mechanism to ensure crash resilience. This prevents data corruption by writing to temporary files before replacing the original file upon successful completion.