Skip to content
affaan-m avatar

Swift Protocol Di Testing

Protocol-based dependency injection patterns that let Swift code be tested without touching real file systems or networks.

CCM score
77 of 100
skills.sh installs
12K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers small focused protocols for file system, file access, and bookmark storage, each with a production default and a configurable mock
  • Includes Sendable-conforming mock implementations with injectable error properties for exercising failure paths deterministically
  • Enforces one concern per protocol and mocking only external boundaries, not internal types with no external dependencies
  • Designed for Swift code using actors and Swift Testing that must run in app, test, and SwiftUI preview contexts

Install

$ npx -y skills add affaan-m/ecc --skill swift-protocol-di-testing -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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.

// 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
}

Details

Repository
github.com/affaan-m/ecc
Categories
Testing & QA, Mobile Apps
First seen
Jul 14, 2026

Questions

What does the swift-protocol-di-testing skill do?

It makes Swift code testable by putting external dependencies like the file system, network, and external APIs behind small, focused protocols. Its tests are written with Swift Testing and run deterministically without real I/O.

How do I install the swift-protocol-di-testing skill?

Run npx -y skills add affaan-m/ecc --skill swift-protocol-di-testing -y in your project. The skill then lets your agent write Swift code with injectable protocols and mock implementations for tests.

Which category does swift-protocol-di-testing belong to and how does it rank?

It is in the Testing & QA category, where it ranks in the top 50. It sits alongside skills such as tdd, webapp-testing and test-driven-development in that category.

When should I use swift-protocol-di-testing?

Use it when Swift code touches the file system, network, or external APIs and you need to test error paths without triggering real failures. It also helps modules that must run in app, test, and SwiftUI preview contexts.

More from affaan-m/ecc

All 257

Similar to Swift Protocol Di Testing

More Testing & QA