Swift Actor Persistence
Thread-safe Swift persistence built on actors, pairing an in-memory cache with atomic file-backed storage.
- CCM score
- 73 of 100
- skills.sh installs
- 12K
- GitHub stars
- 312.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers an actor-based repository that serializes all reads and writes, with the compiler enforcing data-race safety
- Includes a generic
LocalRepositoryoverCodable & Identifiabletypes, plus an@ObservableViewModel integration example - Enforces atomic file writes (
.atomic) to prevent partial writes on crash, and warns againstnonisolatedbypasses - Designed for offline-first iOS and macOS apps that replace legacy
DispatchQueueorNSLocksynchronization
Install
$ npx -y skills add affaan-m/ecc --skill swift-actor-persistence -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
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 {
private var cache: [String: T] = [:]
private let fileURL: URL
public init(directory: URL = .documentsDirectory, filename: String = "data.json") {
self.fileURL = directory.appendingPathComponent(filename)
// Synchronous load during init (actor isolation not yet active)
self.cache = Self.loadSynchronously(from: fileURL)
}
// MARK: - Public API
Details
- Repository
- github.com/affaan-m/ecc
- Categories
- Mobile Apps, Databases
- First seen
- Jul 14, 2026
Questions
What does the swift-actor-persistence skill do?
It guides building a thread-safe data persistence layer in Swift using actors, with an in-memory cache backed by file storage. The actor model keeps shared mutable state free of data races by design.
How do I install the swift-actor-persistence skill?
Run npx -y skills add affaan-m/ecc --skill swift-actor-persistence -y in your project. Once installed, the agent can design actor-based repositories with atomic file writes for local Swift storage.
When should I use swift-actor-persistence instead of locks or DispatchQueues?
Use it when persisting data in Swift 5.5 or later and you want to design out data races instead of managing locks. It suits local storage in iOS or macOS apps and offline-first architectures that sync to a server later.
Which Mobile Apps skills lead the category alongside swift-actor-persistence?
Other skills in the Mobile Apps category include vercel-react-native-skills, animate-expo, write-swift, firebase-crashlytics and xcode-project-setup. swift-actor-persistence focuses specifically on thread-safe Swift persistence with actors.
More from affaan-m/ecc
All 257- Swift Protocol Di Testing12K
- Blueprint12K
- Git Workflow11.9K
- Foundation Models On Device11.9K
- Exa Search11.9K
- Swift Concurrency 6 211.9K
- Nestjs Patterns11.9K
- Data Scraper Agent11.9K
- Hexagonal Architecture11.9K
- Mcp Server Patterns11.9K
- Plankton Code Quality11.9K
- Fal Ai Media11.8K
- Visa Doc Translate11.8K
- Inventory Demand Planning11.8K
- Customs Trade Compliance11.8K
- Brand Voice11.8K
- Seo11.7K
- Kotlin Ktor Patterns11.7K
- Enterprise Agent Ops11.7K
- Quality Nonconformance11.7K
- Ralphinho Rfc Pipeline11.7K
- Crosspost11.7K
- Agent Eval11.7K
- Production Scheduling11.6K
Similar to Swift Actor Persistence
More Mobile Appsfoundation-models-on-deviceaffaan-m/ecc11.9K installsApple FoundationModels framework for on-device LLM — text generation, guided generation with @Generable, tool calling, and snapshot streaming in iOS 26+.
swift-concurrency-6-2affaan-m/ecc11.9K installsSwift 6.2 Approachable Concurrency — single-threaded by default, @concurrent for explicit background offloading, isolated conformances for main actor types.
vega-multi-tv-migrationamazonappdev/devices-agent-skills11.8K installsMigrate Vega OS (Amazon Fire TV) applications to multi-platform React Native monorepo supporting Android TV, Apple TV, and other platforms. Covers analysis, imp
apple-appstore-reviewergithub/awesome-copilot11.6K installsServes as a reviewer of the codebase with instructions on looking for Apple App Store optimizations or rejection reasons.
heroui-nativeheroui-inc/heroui11.5K installsHeroUI Native component library for React Native (Tailwind v4 via Uniwind). Use when building mobile UIs with HeroUI Native — creating Buttons, Cards, TextField
dart-flutter-patternsaffaan-m/ecc11.2K installsProduction-ready Dart and Flutter patterns covering null safety, immutable state, async composition, widget architecture, popular state management frameworks (B