Install any skill in seconds. Free to start, no credit card required.
Get Started Free →loulanyue/swift-actor-persistence
Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.
Passed 17 of 22 test cases with the skill, and 13 of 22 without it.
and 4 more in the full report
5 fixed12 passed either way4 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 5 test cases the skill fixed. Same model, same prompt, with and without the skill.
How should the delete method be implemented in a file-backed Swift actor repository when removing an item by its ID?
| Checked | Without skill | With skill |
|---|---|---|
| The specified identifier key is removed from the internal dictionary cache. | Passed | Passed |
| Disk persistence is triggered immediately after removing the item from cache. | Missed | Passed |
The instructions your model reads when the skill loads.
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.
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
public func save(_ item: T) throws {
cache[item.id] = item
try persistToFile()
}
public func delete(_ id: String) throws {
cache[id] = nil
try persistToFile()
}
test cases passed, vs 13 / 22 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.