[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DAKMR1VY85CA8W46TP5A8R":3,"skill-same:01M6DAKMR1VY85CA8W46TP5A8R":63},{"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":37,"linkOnly":38,"markdownContent":39,"markdownBody":40,"frontMatter":41,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":14,"repositoryHtmlUrl":46,"repositoryHomepageUrl":6,"ownerHtmlUrl":47,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":48,"install":49,"resources":62},"01M6DAKMR1VY85CA8W46TP5A8R","swift-protocol-di-testing",null,"Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.","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-protocol-di-testing\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36],"testing","swift","protocol","swift protocol di testing","code","protocols","file","network","injection","system","dependency","swift testing","dependency injection","2026-11-10 10:12:30",false,"---\nname: swift-protocol-di-testing\ndescription: Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.\norigin: ECC\n---\n\n# Swift Protocol-Based Dependency Injection for Testing\n\nPatterns for making Swift code testable by abstracting external dependencies (file system, network, iCloud) behind small, focused protocols. Enables deterministic tests without I\u002FO.\n\n## When to Activate\n\n- Writing Swift code that accesses file system, network, or external APIs\n- Need to test error handling paths without triggering real failures\n- Building modules that work across environments (app, test, SwiftUI preview)\n- Designing testable architecture with Swift concurrency (actors, Sendable)\n\n## Core Pattern\n\n### 1. Define Small, Focused Protocols\n\nEach protocol handles exactly one external concern.\n\n```swift\n\u002F\u002F File system access\npublic protocol FileSystemProviding: Sendable {\n    func containerURL(for purpose: Purpose) -> URL?\n}\n\n\u002F\u002F File read\u002Fwrite operations\npublic protocol FileAccessorProviding: Sendable {\n    func read(from url: URL) throws -> Data\n    func write(_ data: Data, to url: URL) throws\n    func fileExists(at url: URL) -> Bool\n}\n\n\u002F\u002F Bookmark storage (e.g., for sandboxed apps)\npublic protocol BookmarkStorageProviding: Sendable {\n    func saveBookmark(_ data: Data, for key: String) throws\n    func loadBookmark(for key: String) throws -> Data?\n}\n```\n\n### 2. Create Default (Production) Implementations\n\n```swift\npublic struct DefaultFileSystemProvider: FileSystemProviding {\n    public init() {}\n\n    public func containerURL(for purpose: Purpose) -> URL? {\n        FileManager.default.url(forUbiquityContainerIdentifier: nil)\n    }\n}\n\npublic struct DefaultFileAccessor: FileAccessorProviding {\n    public init() {}\n\n    public func read(from url: URL) throws -> Data {\n        try Data(contentsOf: url)\n    }\n\n    public func write(_ data: Data, to url: URL) throws {\n        try data.write(to: url, options: .atomic)\n    }\n\n    public func fileExists(at url: URL) -> Bool {\n        FileManager.default.fileExists(atPath: url.path)\n    }\n}\n```\n\n### 3. Create Mock Implementations for Testing\n\n```swift\npublic final class MockFileAccessor: FileAccessorProviding, @unchecked Sendable {\n    public var files: [URL: Data] = [:]\n    public var readError: Error?\n    public var writeError: Error?\n\n    public init() {}\n\n    public func read(from url: URL) throws -> Data {\n        if let error = readError { throw error }\n        guard let data = files[url] else {\n            throw CocoaError(.fileReadNoSuchFile)\n        }\n        return data\n    }\n\n    public func write(_ data: Data, to url: URL) throws {\n        if let error = writeError { throw error }\n        files[url] = data\n    }\n\n    public func fileExists(at url: URL) -> Bool {\n        files[url] != nil\n    }\n}\n```\n\n### 4. Inject Dependencies with Default Parameters\n\nProduction code uses defaults; tests inject mocks.\n\n```swift\npublic actor SyncManager {\n    private let fileSystem: FileSystemProviding\n    private let fileAccessor: FileAccessorProviding\n\n    public init(\n        fileSystem: FileSystemProviding = DefaultFileSystemProvider(),\n        fileAccessor: FileAccessorProviding = DefaultFileAccessor()\n    ) {\n        self.fileSystem = fileSystem\n        self.fileAccessor = fileAccessor\n    }\n\n    public func sync() async throws {\n        guard let containerURL = fileSystem.containerURL(for: .sync) else {\n            throw SyncError.containerNotAvailable\n        }\n        let data = try fileAccessor.read(\n            from: containerURL.appendingPathComponent(\"data.json\")\n        )\n        \u002F\u002F Process data...\n    }\n}\n```\n\n### 5. Write Tests with Swift Testing\n\n```swift\nimport Testing\n\n@Test(\"Sync manager handles missing container\")\nfunc testMissingContainer() async {\n    let mockFileSystem = MockFileSystemProvider(containerURL: nil)\n    let manager = SyncManager(fileSystem: mockFileSystem)\n\n    await #expect(throws: SyncError.containerNotAvailable) {\n        try await manager.sync()\n    }\n}\n\n@Test(\"Sync manager reads data correctly\")\nfunc testReadData() async throws {\n    let mockFileAccessor = MockFileAccessor()\n    mockFileAccessor.files[testURL] = testData\n\n    let manager = SyncManager(fileAccessor: mockFileAccessor)\n    let result = try await manager.loadData()\n\n    #expect(result == expectedData)\n}\n\n@Test(\"Sync manager handles read errors gracefully\")\nfunc testReadError() async {\n    let mockFileAccessor = MockFileAccessor()\n    mockFileAccessor.readError = CocoaError(.fileReadCorruptFile)\n\n    let manager = SyncManager(fileAccessor: mockFileAccessor)\n\n    await #expect(throws: SyncError.self) {\n        try await manager.sync()\n    }\n}\n```\n\n## Best Practices\n\n- **Single Responsibility**: Each protocol should handle one concern — don't create \"god protocols\" with many methods\n- **Sendable conformance**: Required when protocols are used across actor boundaries\n- **Default parameters**: Let production code use real implementations by default; only tests need to specify mocks\n- **Error simulation**: Design mocks with configurable error properties for testing failure paths\n- **Only mock boundaries**: Mock external dependencies (file system, network, APIs), not internal types\n\n## Anti-Patterns to Avoid\n\n- Creating a single large protocol that covers all external access\n- Mocking internal types that have no external dependencies\n- Using `#if DEBUG` conditionals instead of proper dependency injection\n- Forgetting `Sendable` conformance when used with actors\n- Over-engineering: if a type has no external dependencies, it doesn't need a protocol\n\n## When to Use\n\n- Any Swift code that touches file system, network, or external APIs\n- Testing error handling paths that are hard to trigger in real environments\n- Building modules that need to work in app, test, and SwiftUI preview contexts\n- Apps using Swift concurrency (actors, structured concurrency) that need testable architecture\n","# Swift Protocol-Based Dependency Injection for Testing\n\nPatterns for making Swift code testable by abstracting external dependencies (file system, network, iCloud) behind small, focused protocols. Enables deterministic tests without I\u002FO.\n\n## When to Activate\n\n- Writing Swift code that accesses file system, network, or external APIs\n- Need to test error handling paths without triggering real failures\n- Building modules that work across environments (app, test, SwiftUI preview)\n- Designing testable architecture with Swift concurrency (actors, Sendable)\n\n## Core Pattern\n\n### 1. Define Small, Focused Protocols\n\nEach protocol handles exactly one external concern.\n\n```swift\n\u002F\u002F File system access\npublic protocol FileSystemProviding: Sendable {\n    func containerURL(for purpose: Purpose) -> URL?\n}\n\n\u002F\u002F File read\u002Fwrite operations\npublic protocol FileAccessorProviding: Sendable {\n    func read(from url: URL) throws -> Data\n    func write(_ data: Data, to url: URL) throws\n    func fileExists(at url: URL) -> Bool\n}\n\n\u002F\u002F Bookmark storage (e.g., for sandboxed apps)\npublic protocol BookmarkStorageProviding: Sendable {\n    func saveBookmark(_ data: Data, for key: String) throws\n    func loadBookmark(for key: String) throws -> Data?\n}\n```\n\n### 2. Create Default (Production) Implementations\n\n```swift\npublic struct DefaultFileSystemProvider: FileSystemProviding {\n    public init() {}\n\n    public func containerURL(for purpose: Purpose) -> URL? {\n        FileManager.default.url(forUbiquityContainerIdentifier: nil)\n    }\n}\n\npublic struct DefaultFileAccessor: FileAccessorProviding {\n    public init() {}\n\n    public func read(from url: URL) throws -> Data {\n        try Data(contentsOf: url)\n    }\n\n    public func write(_ data: Data, to url: URL) throws {\n        try data.write(to: url, options: .atomic)\n    }\n\n    public func fileExists(at url: URL) -> Bool {\n        FileManager.default.fileExists(atPath: url.path)\n    }\n}\n```\n\n### 3. Create Mock Implementations for Testing\n\n```swift\npublic final class MockFileAccessor: FileAccessorProviding, @unchecked Sendable {\n    public var files: [URL: Data] = [:]\n    public var readError: Error?\n    public var writeError: Error?\n\n    public init() {}\n\n    public func read(from url: URL) throws -> Data {\n        if let error = readError { throw error }\n        guard let data = files[url] else {\n            throw CocoaError(.fileReadNoSuchFile)\n        }\n        return data\n    }\n\n    public func write(_ data: Data, to url: URL) throws {\n        if let error = writeError { throw error }\n        files[url] = data\n    }\n\n    public func fileExists(at url: URL) -> Bool {\n        files[url] != nil\n    }\n}\n```\n\n### 4. Inject Dependencies with Default Parameters\n\nProduction code uses defaults; tests inject mocks.\n\n```swift\npublic actor SyncManager {\n    private let fileSystem: FileSystemProviding\n    private let fileAccessor: FileAccessorProviding\n\n    public init(\n        fileSystem: FileSystemProviding = DefaultFileSystemProvider(),\n        fileAccessor: FileAccessorProviding = DefaultFileAccessor()\n    ) {\n        self.fileSystem = fileSystem\n        self.fileAccessor = fileAccessor\n    }\n\n    public func sync() async throws {\n        guard let containerURL = fileSystem.containerURL(for: .sync) else {\n            throw SyncError.containerNotAvailable\n        }\n        let data = try fileAccessor.read(\n            from: containerURL.appendingPathComponent(\"data.json\")\n        )\n        \u002F\u002F Process data...\n    }\n}\n```\n\n### 5. Write Tests with Swift Testing\n\n```swift\nimport Testing\n\n@Test(\"Sync manager handles missing container\")\nfunc testMissingContainer() async {\n    let mockFileSystem = MockFileSystemProvider(containerURL: nil)\n    let manager = SyncManager(fileSystem: mockFileSystem)\n\n    await #expect(throws: SyncError.containerNotAvailable) {\n        try await manager.sync()\n    }\n}\n\n@Test(\"Sync manager reads data correctly\")\nfunc testReadData() async throws {\n    let mockFileAccessor = MockFileAccessor()\n    mockFileAccessor.files[testURL] = testData\n\n    let manager = SyncManager(fileAccessor: mockFileAccessor)\n    let result = try await manager.loadData()\n\n    #expect(result == expectedData)\n}\n\n@Test(\"Sync manager handles read errors gracefully\")\nfunc testReadError() async {\n    let mockFileAccessor = MockFileAccessor()\n    mockFileAccessor.readError = CocoaError(.fileReadCorruptFile)\n\n    let manager = SyncManager(fileAccessor: mockFileAccessor)\n\n    await #expect(throws: SyncError.self) {\n        try await manager.sync()\n    }\n}\n```\n\n## Best Practices\n\n- **Single Responsibility**: Each protocol should handle one concern — don't create \"god protocols\" with many methods\n- **Sendable conformance**: Required when protocols are used across actor boundaries\n- **Default parameters**: Let production code use real implementations by default; only tests need to specify mocks\n- **Error simulation**: Design mocks with configurable error properties for testing failure paths\n- **Only mock boundaries**: Mock external dependencies (file system, network, APIs), not internal types\n\n## Anti-Patterns to Avoid\n\n- Creating a single large protocol that covers all external access\n- Mocking internal types that have no external dependencies\n- Using `#if DEBUG` conditionals instead of proper dependency injection\n- Forgetting `Sendable` conformance when used with actors\n- Over-engineering: if a type has no external dependencies, it doesn't need a protocol\n\n## When to Use\n\n- Any Swift code that touches file system, network, or external APIs\n- Testing error handling paths that are hard to trigger in real environments\n- Building modules that need to work in app, test, and SwiftUI preview contexts\n- Apps using Swift concurrency (actors, structured concurrency) that need testable architecture\n",{"name":5,"origin":42,"description":7},"ECC","main","a298c929b6cbd662e1fce54302ce520d5ceea1a5",".agents\u002Flibrary\u002Fskills\u002Fswift-protocol-di-testing","https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain","https:\u002F\u002Fgithub.com\u002FPrekzursil","2026-11-02 14:30:57",{"source":8,"skillName":5,"commands":50,"prompt":60,"zipAvailable":61},[51,54,57],{"tool":52,"command":53},"npx","npx skills add Prekzursil\u002Fagent-skills-toolchain --skill swift-protocol-di-testing",{"tool":55,"command":56},"bunx","bunx skills add Prekzursil\u002Fagent-skills-toolchain --skill swift-protocol-di-testing",{"tool":58,"command":59},"pnpm","pnpm dlx skills add Prekzursil\u002Fagent-skills-toolchain --skill swift-protocol-di-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FPrekzursil\u002Fagent-skills-toolchain\u002Fblob\u002Fmain\u002F.agents\u002Flibrary\u002Fskills\u002Fswift-protocol-di-testing\u002FSKILL.md",true,[],[64,84,113,138,152,168],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":37},"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",[],[71,72,73,74,75,76,77,78,79,80,81,82,32,83,30],"clarify requirements","clarify","requirements","risk","options","task","prompts","goal","scanning","use","context","repo","execution",{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":93,"publishedAt":37},"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",[90],{"categoryNo":91,"categoryName":92,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[94,95,96,97,98,99,100,101,102,103,104,105,106,107,80,108,109,110,111,112],"openmm md","how","decision","pick","linux","analyze","tool","stack","open","NVIDIA","gpu","license","workflow","windows","free","molecular dynamics","local","do","MCP",{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":123,"publishedAt":37},"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",[119,122],{"categoryNo":120,"categoryName":121,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[124,125,126,127,128,129,130,131,132,133,95,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":37},"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":37},"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":91,"categoryName":92,"taxonomyType":21,"taxonomyTypeDesc":22},[154,160,76,161,162,163,80,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":37},"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,110,174,149,175],"files","interactive"]