[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DAKFFA0GGS5TTAQ39EESSE":3,"skill-same:01M6DAKFFA0GGS5TTAQ39EESSE":60},{"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":23,"publishedAt":34,"linkOnly":35,"markdownContent":36,"markdownBody":37,"frontMatter":38,"refName":40,"commitSha":41,"skillDirectory":42,"forksCount":14,"repositoryHtmlUrl":43,"repositoryHomepageUrl":6,"ownerHtmlUrl":44,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":45,"install":46,"resources":59},"01M6DAKFFA0GGS5TTAQ39EESSE","swift-actor-persistence",null,"Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.","Prekzursil\u002Fagent-skills-toolchain","Prekzursil","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F54636077?v=4","01M6DACZ1PCQHD99SCR1YXG28B","Andrei Mihai Visalon","01M6DACZ670WZF535V3WYYSS4Z",0,"MIT","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002F.agents\u002Flibrary\u002Fskills\u002Fswift-actor-persistence\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33],"swift","persistence","swift actor persistence","design","safe","memory","storage","file","cache","data","2026-11-10 10:12:30",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":39,"description":7},"ECC","main","a298c929b6cbd662e1fce54302ce520d5ceea1a5",".agents\u002Flibrary\u002Fskills\u002Fswift-actor-persistence","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain","https:\u002F\u002Fgithub.com\u002FPrekzursil","2026-11-02 14:30:57",{"source":8,"skillName":5,"commands":47,"prompt":57,"zipAvailable":58},[48,51,54],{"tool":49,"command":50},"npx","npx skills add Prekzursil\u002Fagent-skills-toolchain --skill swift-actor-persistence",{"tool":52,"command":53},"bunx","bunx skills add Prekzursil\u002Fagent-skills-toolchain --skill swift-actor-persistence",{"tool":55,"command":56},"pnpm","pnpm dlx skills add Prekzursil\u002Fagent-skills-toolchain --skill swift-actor-persistence","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002F.agents\u002Flibrary\u002Fskills\u002Fswift-actor-persistence\u002FSKILL.md",true,[],[61,82,111,138,152,168],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":34},"01M6DF7D7478R55P46REYH4QAC","clarify-requirements","Resolve genuine pre-execution ambiguity by scanning repo context, generating 1-6 grounded options, and asking 1-3 focused questions via AskUserQuestion. NOT for mid-task use (injection risk); NOT when the goal is already unambiguous; use to disambiguate vague prompts before any file edits.","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Fworkspace-hooks\u002Fskills\u002Fclarify-requirements\u002FSKILL.md",[],[68,69,70,71,72,73,74,75,76,77,78,79,80,81,31],"clarify requirements","clarify","requirements","risk","options","task","prompts","goal","scanning","use","context","repo","injection","execution",{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":91,"publishedAt":34},"01M6DF79CA4BHJS66J8EZDBPWJ","openmm-md","Run FREE, open-source, Windows-native GPU molecular dynamics via the openmm-md MCP (OpenMM + CUDA on the local NVIDIA GPU). Use for protein \u002F protein-ligand MD when you want a free stack or are on Windows without a Schrodinger license. Covers the full workflow (prepare, solvate, minimize, equilibrate, production, analyze, mmgbsa) AND an honest decision guide vs Schrodinger Desmond, including how to run Desmond legitimately on Linux or a cloud GPU with a real license. This is a deliberately LESSER free alternative and does NOT replace the schrodinger MCP tools. Do NOT use it to pick a free tool when a validated FEP+, WaterMap, IFD-MD, or Prime MM-GBSA result is actually required.","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Fmcp\u002Fopenmm-md-mcp\u002Fskill\u002Fopenmm-md\u002FSKILL.md",[88],{"categoryNo":89,"categoryName":90,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[92,93,94,95,96,97,98,99,100,101,102,103,104,105,77,106,107,108,109,110],"openmm md","how","decision","pick","linux","analyze","tool","stack","open","NVIDIA","gpu","license","workflow","windows","free","molecular dynamics","local","do","MCP",{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":123,"publishedAt":34},"01M6DF76C1MG85VEWP8VZCBNMN","visual-review","Take screenshots of web pages and UI using Playwright for visual review and iteration","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fvisual-review\u002FSKILL.md",[117,120],{"categoryNo":118,"categoryName":119,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":121,"categoryName":122,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",[124,125,126,127,128,129,130,131,132,133,93,134,135,136,137],"review","visual","visual review","pages","web","false","iteration","take","check","slides","ui","screenshot","playwright","screenshots",{"skillNo":139,"name":140,"nameZh":6,"description":141,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":34},"01M6DF73AQVCBZKEN0YXEX9FXP","status","Diagnostic status report — shows metaswarm installation state, project setup, and potential issues","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fstatus\u002FSKILL.md",[],[140,145,146,147,148,149,150,151],"setup","report","project","installation","project setup","issues","state",{"skillNo":153,"name":154,"nameZh":6,"description":155,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":156,"categories":157,"keywords":159,"publishedAt":34},"01M6DF6X6C2XB0P6GX76P7TTYV","start","Use when starting work on any task, when the user mentions metaswarm, or when the user wants to begin tracked development work","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fstart\u002FSKILL.md",[158],{"categoryNo":89,"categoryName":90,"taxonomyType":21,"taxonomyTypeDesc":22},[154,160,73,161,162,163,77,164,165,166,167],"start issue","issue","ready","work on issue","user","work","work on","development",{"skillNo":169,"name":145,"nameZh":6,"description":170,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":171,"categories":172,"keywords":173,"publishedAt":34},"01M6DF6QMJ9AJKFKHHKRT005PQ","Interactive project setup — detects your project, configures metaswarm, writes project-local files","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002Ftools\u002Feditor\u002Fmetaswarm\u002Fskills\u002Fsetup\u002FSKILL.md",[],[145,147,108,174,149,175],"files","interactive"]