swift-actor-persistence

swift-actor-persistence is a skill for Claude Code, Codex from Cyvid7-Darus10/claude-code-config. It costs 29 tokens per session (1,045 once invoked), scanned A, a copy of swift-actor-persistence, MIT.

A Swift design guide for storing data safely when several parts of an app may access it at once. It uses actors, a Swift feature that serializes access to shared state, with an in-memory cache and file storage.

In plain words
What is it for?
Use it to build local repositories and persistence layers in Swift 5.5 or newer, especially for Codable records that need cached and file-backed storage.
Why use it?
It reduces data races and avoids having to coordinate shared data manually with locks or dispatch queues. It also supports apps that need local data while offline.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to build local repositories and persistence layers in Swift 5.5 or newer, especially for Codable records that need cached and file-backed storage.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cyvid7-darus10/claude-code-config/swift-actor-persistence
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Cyvid7-Darus10/claude-code-config --skill swift-actor-persistence
Clone the repo
git clone --depth 1 https://github.com/Cyvid7-Darus10/claude-code-config

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for swift-actor-persistence

README.md
[![agentmods](https://agentmods.dev/badge/skills/cyvid7-darus10/claude-code-config/swift-actor-persistence.svg)](https://agentmods.dev/skills/cyvid7-darus10/claude-code-config/swift-actor-persistence)
Your own site
<a href="https://agentmods.dev/skills/cyvid7-darus10/claude-code-config/swift-actor-persistence"><img src="https://agentmods.dev/badge/skills/cyvid7-darus10/claude-code-config/swift-actor-persistence.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,045 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 98% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00029 $0.01045
Opus 5 $0.00015 $0.00522
Sonnet 5 $0.00006 $0.00209
Haiku 4.5 $0.00003 $0.00104

Measured 8d ago against content hash dddfd2f5da0c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

swift-actor-persistence scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

98% identical to swift-actor-persistence — 4 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/swift-actor-persistence/SKILL.md · 144 lines

How it starts

The opening of the file, as written. The whole thing — 144 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

    public func save(_ item: T) throws {
        cache[item.id] = item
        try persistToFile()
    }

    public func delete(_ id: String) throws {
        cache[id] = nil
        try persistToFile()
    }

    public func find(by id: String) -> T? {
        cache[id]
    }

    public func loadAll() -> [T] {
        Array(cache.values)
    }

    // MARK: - Private

    private func persistToFile() throws {
        let data = try JSONEncoder().encode(Array(cache.values))
        try data.write(to: fileURL, options: .atomic)
    }

    private static func loadSynchronously(from url: URL) -> [String: T] {
        guard let data = try? Data(contentsOf: url),
              let items = try? JSONDecoder().decode([T].self, from: data) else {
            return [:]
        }
        return Dictionary(uniqueKeysWithValues: items.map { ($0.id, $0) })
    }
}

Usage

All calls are automatically async due to actor isolation:

Read the full file on GitHub · 144 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 144 lines · 29 tokens per session scan A dddfd2f5da0c

Subscribe to this mod's changes

swift-actor-persistence is a skill published in the GitHub repository Cyvid7-Darus10/claude-code-config (2 stars, last pushed 2mo ago), licensed MIT. It adds 29 tokens to every session and 1,045 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 98% identical to swift-actor-persistence, differing in 4 lines, and is treated as a copy.

Related

Other skills, from other repositories