[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73G5BES0QTJ6M5ZGF8PD48C":3,"skill-same:01M73G5BES0QTJ6M5ZGF8PD48C":49},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M73G5BES0QTJ6M5ZGF8PD48C","swift-actor-persistence",null,"Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fswift-actor-persistence\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: swift-actor-persistence\ndescription: Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.\norigin: ECC\n---\n\n# Swift Actors for Thread-Safe Persistence\n\nPatterns 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.\n\n## When to Activate\n\n- Building a data persistence layer in Swift 5.5+\n- Need thread-safe access to shared mutable state\n- Want to eliminate manual synchronization (locks, DispatchQueues)\n- Building offline-first apps with local storage\n\n## Core Pattern\n\n### Actor-Based Repository\n\nThe actor model guarantees serialized access — no data races, enforced by the compiler.\n\n```swift\npublic actor LocalRepository\u003CT: Codable & Identifiable> where T.ID == String {\n    private var cache: [String: T] = [:]\n    private let fileURL: URL\n\n    public init(directory: URL = .documentsDirectory, filename: String = \"data.json\") {\n        self.fileURL = directory.appendingPathComponent(filename)\n        \u002F\u002F Synchronous load during init (actor isolation not yet active)\n        self.cache = Self.loadSynchronously(from: fileURL)\n    }\n\n    \u002F\u002F MARK: - Public API\n\n    public func save(_ item: T) throws {\n        cache[item.id] = item\n        try persistToFile()\n    }\n\n    public func delete(_ id: String) throws {\n        cache[id] = nil\n        try persistToFile()\n    }\n\n    public func find(by id: String) -> T? {\n        cache[id]\n    }\n\n    public func loadAll() -> [T] {\n        Array(cache.values)\n    }\n\n    \u002F\u002F MARK: - Private\n\n    private func persistToFile() throws {\n        let data = try JSONEncoder().encode(Array(cache.values))\n        try data.write(to: fileURL, options: .atomic)\n    }\n\n    private static func loadSynchronously(from url: URL) -> [String: T] {\n        guard let data = try? Data(contentsOf: url),\n              let items = try? JSONDecoder().decode([T].self, from: data) else {\n            return [:]\n        }\n        return Dictionary(uniqueKeysWithValues: items.map { ($0.id, $0) })\n    }\n}\n```\n\n### Usage\n\nAll calls are automatically async due to actor isolation:\n\n```swift\nlet repository = LocalRepository\u003CQuestion>()\n\n\u002F\u002F Read — fast O(1) lookup from in-memory cache\nlet question = await repository.find(by: \"q-001\")\nlet allQuestions = await repository.loadAll()\n\n\u002F\u002F Write — updates cache and persists to file atomically\ntry await repository.save(newQuestion)\ntry await repository.delete(\"q-001\")\n```\n\n### Combining with @Observable ViewModel\n\n```swift\n@Observable\nfinal class QuestionListViewModel {\n    private(set) var questions: [Question] = []\n    private let repository: LocalRepository\u003CQuestion>\n\n    init(repository: LocalRepository\u003CQuestion> = LocalRepository()) {\n        self.repository = repository\n    }\n\n    func load() async {\n        questions = await repository.loadAll()\n    }\n\n    func add(_ question: Question) async throws {\n        try await repository.save(question)\n        questions = await repository.loadAll()\n    }\n}\n```\n\n## Key Design Decisions\n\n| Decision | Rationale |\n|----------|-----------|\n| Actor (not class + lock) | Compiler-enforced thread safety, no manual synchronization |\n| In-memory cache + file persistence | Fast reads from cache, durable writes to disk |\n| Synchronous init loading | Avoids async initialization complexity |\n| Dictionary keyed by ID | O(1) lookups by identifier |\n| Generic over `Codable & Identifiable` | Reusable across any model type |\n| Atomic file writes (`.atomic`) | Prevents partial writes on crash |\n\n## Best Practices\n\n- **Use `Sendable` types** for all data crossing actor boundaries\n- **Keep the actor's public API minimal** — only expose domain operations, not persistence details\n- **Use `.atomic` writes** to prevent data corruption if the app crashes mid-write\n- **Load synchronously in `init`** — async initializers add complexity with minimal benefit for local files\n- **Combine with `@Observable`** ViewModels for reactive UI updates\n\n## Anti-Patterns to Avoid\n\n- Using `DispatchQueue` or `NSLock` instead of actors for new Swift concurrency code\n- Exposing the internal cache dictionary to external callers\n- Making the file URL configurable without validation\n- Forgetting that all actor method calls are `await` — callers must handle async context\n- Using `nonisolated` to bypass actor isolation (defeats the purpose)\n\n## When to Use\n\n- Local data storage in iOS\u002FmacOS apps (user data, settings, cached content)\n- Offline-first architectures that sync to a server later\n- Any shared mutable state that multiple parts of the app access concurrently\n- Replacing legacy `DispatchQueue`-based thread safety with modern Swift concurrency\n","# Swift Actors for Thread-Safe Persistence\n\nPatterns 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.\n\n## When to Activate\n\n- Building a data persistence layer in Swift 5.5+\n- Need thread-safe access to shared mutable state\n- Want to eliminate manual synchronization (locks, DispatchQueues)\n- Building offline-first apps with local storage\n\n## Core Pattern\n\n### Actor-Based Repository\n\nThe actor model guarantees serialized access — no data races, enforced by the compiler.\n\n```swift\npublic actor LocalRepository\u003CT: Codable & Identifiable> where T.ID == String {\n    private var cache: [String: T] = [:]\n    private let fileURL: URL\n\n    public init(directory: URL = .documentsDirectory, filename: String = \"data.json\") {\n        self.fileURL = directory.appendingPathComponent(filename)\n        \u002F\u002F Synchronous load during init (actor isolation not yet active)\n        self.cache = Self.loadSynchronously(from: fileURL)\n    }\n\n    \u002F\u002F MARK: - Public API\n\n    public func save(_ item: T) throws {\n        cache[item.id] = item\n        try persistToFile()\n    }\n\n    public func delete(_ id: String) throws {\n        cache[id] = nil\n        try persistToFile()\n    }\n\n    public func find(by id: String) -> T? {\n        cache[id]\n    }\n\n    public func loadAll() -> [T] {\n        Array(cache.values)\n    }\n\n    \u002F\u002F MARK: - Private\n\n    private func persistToFile() throws {\n        let data = try JSONEncoder().encode(Array(cache.values))\n        try data.write(to: fileURL, options: .atomic)\n    }\n\n    private static func loadSynchronously(from url: URL) -> [String: T] {\n        guard let data = try? Data(contentsOf: url),\n              let items = try? JSONDecoder().decode([T].self, from: data) else {\n            return [:]\n        }\n        return Dictionary(uniqueKeysWithValues: items.map { ($0.id, $0) })\n    }\n}\n```\n\n### Usage\n\nAll calls are automatically async due to actor isolation:\n\n```swift\nlet repository = LocalRepository\u003CQuestion>()\n\n\u002F\u002F Read — fast O(1) lookup from in-memory cache\nlet question = await repository.find(by: \"q-001\")\nlet allQuestions = await repository.loadAll()\n\n\u002F\u002F Write — updates cache and persists to file atomically\ntry await repository.save(newQuestion)\ntry await repository.delete(\"q-001\")\n```\n\n### Combining with @Observable ViewModel\n\n```swift\n@Observable\nfinal class QuestionListViewModel {\n    private(set) var questions: [Question] = []\n    private let repository: LocalRepository\u003CQuestion>\n\n    init(repository: LocalRepository\u003CQuestion> = LocalRepository()) {\n        self.repository = repository\n    }\n\n    func load() async {\n        questions = await repository.loadAll()\n    }\n\n    func add(_ question: Question) async throws {\n        try await repository.save(question)\n        questions = await repository.loadAll()\n    }\n}\n```\n\n## Key Design Decisions\n\n| Decision | Rationale |\n|----------|-----------|\n| Actor (not class + lock) | Compiler-enforced thread safety, no manual synchronization |\n| In-memory cache + file persistence | Fast reads from cache, durable writes to disk |\n| Synchronous init loading | Avoids async initialization complexity |\n| Dictionary keyed by ID | O(1) lookups by identifier |\n| Generic over `Codable & Identifiable` | Reusable across any model type |\n| Atomic file writes (`.atomic`) | Prevents partial writes on crash |\n\n## Best Practices\n\n- **Use `Sendable` types** for all data crossing actor boundaries\n- **Keep the actor's public API minimal** — only expose domain operations, not persistence details\n- **Use `.atomic` writes** to prevent data corruption if the app crashes mid-write\n- **Load synchronously in `init`** — async initializers add complexity with minimal benefit for local files\n- **Combine with `@Observable`** ViewModels for reactive UI updates\n\n## Anti-Patterns to Avoid\n\n- Using `DispatchQueue` or `NSLock` instead of actors for new Swift concurrency code\n- Exposing the internal cache dictionary to external callers\n- Making the file URL configurable without validation\n- Forgetting that all actor method calls are `await` — callers must handle async context\n- Using `nonisolated` to bypass actor isolation (defeats the purpose)\n\n## When to Use\n\n- Local data storage in iOS\u002FmacOS apps (user data, settings, cached content)\n- Offline-first architectures that sync to a server later\n- Any shared mutable state that multiple parts of the app access concurrently\n- Replacing legacy `DispatchQueue`-based thread safety with modern Swift concurrency\n",{"name":5,"origin":24,"description":7},"ECC","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa","core\u002Fskills\u002Fswift-actor-persistence",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-12 23:12:27",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill swift-actor-persistence",{"tool":41,"command":42},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill swift-actor-persistence",{"tool":44,"command":45},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill swift-actor-persistence","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fswift-actor-persistence\u002FSKILL.md",true,[],[50,58,65,73,81,89],{"skillNo":51,"name":52,"nameZh":6,"description":53,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":54,"licenseFileUrl":6,"sourceHtmlUrl":55,"categories":56,"keywords":57,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":69,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":85,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]