Agent skill

swift-protocol-di-testing

Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.

mturacgithub.com/mturacGitHub ↗
codexcopilotcursorMIT
Install
npx skills add mturac/everything-openai-codex --skill swift-protocol-di-testing --agent codex

Same command for any agent — swap --agent for claude-code, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 6 KB
Bundled scripts: none
Path: skills/swift-protocol-di-testing/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 84
Language: JavaScript

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Swift Protocol-Based Dependency Injection for Testing Patterns for making Swift code testable by abstracting external dependencies (file system, network, iCloud) behind small, focused protocols. Enables deterministic tests without I/O. ## When to Activate - Writing Swift code that accesses file system, network, or external APIs - Need to test error handling paths without triggering real failures - Building modules that work across environments (app, test, SwiftUI preview) - Designing testable architecture with Swift concurrency (actors, Sendable) ## Core Pattern ### 1. Define Small, Focused Protocols Each protocol handles exactly one external concern. ```swift // File system access public protocol FileSystemProviding: Sendable { func containerURL(for purpose: Purpose) -> URL? } // File read/write operations public protocol FileAccessorProviding: Sendable { func read(from url: URL) throws -> Data func write(_ data: Data, to url: URL) throws func fileExists(at url: URL) -> Bool } // Bookmark storage (e.g., for sandboxed apps) public protocol BookmarkStorageProviding: Sendable { func saveBookmark(_ data: Data, for key: String) throws func loadBookmark(for key: String) throws -> Data

What's inside
Steps it walks through
  1. When to Activate
  2. Core Pattern
  3. 1. Define Small, Focused Protocols
  4. 2. Create Default (Production) Implementations
  5. 3. Create Mock Implementations for Testing
  6. 4. Inject Dependencies with Default Parameters
  7. 5. Write Tests with Swift Testing
  8. Best Practices
  9. Anti-Patterns to Avoid
  10. When to Use
More from everything-openai-codex
All skills →
About this skill
What does the swift-protocol-di-testing skill do?

Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.

How do I install it?

Run `npx skills add mturac/everything-openai-codex --skill swift-protocol-di-testing --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From mturac/everything-openai-codex, a repository with 84 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going