Agent skill · Audited from source
Swift Protocol Di Testing
skill · affaan-m/ECCMIT licenceAudited 22 Sep 2026 · source fb3fb10d9622
Is it safe? Yes — SAFE, grade B (89/100). We read this skill's source at commit fb3fb10d9622 and found no filesystem, network or shell access and no hard-coded secrets. What it does: テスト可能なSwiftコードのためのプロトコルベースの依存性注入——焦点を絞ったプロトコルとSwift Testingを使用してファイルシステム、ネットワーク、外部APIをモックする。
Cite
Cite this page
ModelsAtlas. “Swift Protocol Di Testing (affaan-m/ECC)”. Retrieved 22 Sep 2026. https://modelsatlas.com/skills/affaan-m/swift-protocol-di-testing
2 skills are called “Swift Protocol Di Testing”. You are viewing affaan-m/ECC.
- affaan-m/ECC★ 265k✓SAFE
- xu-xiang/everything-claude-code-zh★ 2k✓SAFE
Trust audit
Audit 0.4.1 · source read 22 Sep 2026
SAFE means nothing in the source contradicts what the skill says it does. Grade B is shared by 17,406 of 18,389 audited skills.
What the source does
- FilesystemNone observedNo reads or writes in the source
- NetworkNone observedNo outbound calls in the source
- ShellNone observedNo commands run in the source
- DependenciesPinnedNothing floats
- SecretsNone foundNo keys in source
Five audit layers
| Layer | What we check | Result | Findings |
|---|---|---|---|
L0 Provenance | Repo owner, licence, archive status, activity | PASS | 0 |
L1 Static source | Secrets, path traversal, supply chain, hidden code | NA | 0 |
L2 Instructions | Prompt injection, authority framing, hidden directives | PASS | 0 |
L3 Inventory | The files and declarations match the source | PASS | 0 |
L4 Sandbox | Run in isolation and watch behaviour | SKIPPED why | 0 |
Gates applied: no behavioural pass.
Findings (0)
No findings at any severity. We re-audit when the source changes.
Audit 0.4.1 · source sha fb3fb10d9622 · 22 Sep 2026Report an issue or request a re-scan
Provenance
Who published it, and what the verdict is pinned to
- Publisheraffaan-m GitHub userOwner of the repository this skill is read from
- Source folderaffaan-m/ECC/docs/ja-JP/skills/swift-protocol-di-testingThe exact folder we audited
- LicenceMITAs the repository states it
- Commit pinned for this verdictfb3fb10d9622A new audit runs when the source changes
- Repository statusNot archivedPushed today
- Sandboxed runNot runSkills are read, not executed; layer L4 is skipped
What it tells the agent
Full source on GitHub ↗Its description: テスト可能なSwiftコードのためのプロトコルベースの依存性注入——焦点を絞ったプロトコルとSwift Testingを使用してファイルシステム、ネットワーク、外部APIをモックする。
---
name: swift-protocol-di-testing
description: テスト可能なSwiftコードのためのプロトコルベースの依存性注入——焦点を絞ったプロトコルとSwift Testingを使用してファイルシステム、ネットワーク、外部APIをモックする。
origin: ECC
---
# プロトコルベースのSwift依存性注入テスト
外部の依存関係(ファイルシステム、ネットワーク、iCloud)を小さく焦点を絞ったプロトコルとして抽象化することで、SwiftコードをテストしやすくするパターンI/Oなしの決定論的テストをサポートする。
## 起動条件
* ファイルシステム、ネットワーク、または外部APIにアクセスするSwiftコードを書く場合
* 実際の障害を起こさずにエラー処理パスをテストする必要がある場合
* 異なる環境(アプリ、テスト、SwiftUIプレビュー)で動作するモジュールを構築する場合
* Swift並行処理(Actor、Sendable)をサポートするテスト可能なアーキテクチャを設計する場合
## コアパターン
### 1. 小さく焦点を絞ったプロトコルを定義する
各プロトコルは1つの外部関心事のみを処理する。
```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?
}
```
### 2. デフォルト(本番用)実装を作成する
```swift
public struct DefaultFileSystemProvider: FileSystemProviding {
public init() {}
public func containerURL(for purpose: Purpose) -> URL? {
FileManager.default.url(forUbiquityContainerIdentifier: nil)
}
}
public struct DefaultFileAccessor: FileAccessorProviding {
public init() {}
public func read(from url: URL) throws -> Data {
try Data(contentsOf: url)
}
public func write(_ data: Data, to url: URL) throws {
try data.write(to: url, options: .atomic)
}
public func fileExists(at url: URL) -> Bool {
FileManager.default.fileExists(atPath: url.path)
}
}
```
### 3. テスト用のモック実装を作成する
```swift
public final class MockFileAccessor: FileAccessorProviding, @unchecked Sendable {
public var files: [URL: Data] = [:]
public var readError: Error?
public var writeError: Error?
public init() {}
public func read(from url: URL) throws -> Data {
if let error = readError { throw error }
guard let data = files[url] else {
throw CocoaError(.fileReadNoSuchFile)
}
return data
}
public func write(_ data: Data, to url: URL) throws {
if let error = writeError { throw error }
files[url] = data
}
public func fileExists(at url: URL) -> Bool {
files[url] != nil
}
}
```
### 4. デフォルトパラメーターで依存関係を注入する
本番コードはデフォルト値を使用し、テストはモックを注入する。
```swift
public actor SyncManager {
private let fileSystem: FileSystemProviding
private let fileAccessor: FileAccessorProviding
public init(
fileSystem: FileSystemProviding = DefaultFileSystemProvider(),
fileAccessor: FileAccessorProviding = DefaultFileAccessor()
) {
self.fileSystem = fileSystem
self.fileAccessor = fileAccessor
}
public func sync() async throws {
guard let containerURL = fileSystem.containerURL(for: .sync) else {
throw SyncError.containerNotAvailable
}
let data = try fileAccessor.read(
from: containerURL.appendingPathComponent("data.json")
)
// Process data...
}
}
```
### 5. Swift Testingを使用してテストを書く
```swift
import Testing
@Test("Sync manager handles missing container")
func testMissingContainer() async {
let mockFileSystem = MockFileSystemProvider(containerURL: nil)
let manager = SyncManager(fileSystem: mockFileSystem)
await #expect(throws: SyncError.containerNotAvailable) {
try await manager.sync()
}
}
@Test("Sync manager reads data correctly")
func testReadData() async throws {
let mockFileAccessor = MockFileAccessor()
mockFileAccessor.files[testURL] = testData
let manager = SyncManager(fileAccessor: mockFileAccessor)
let result = try await manager.loadData()
#expect(result == expectedData)
}
@Test("Sync manager handles read errors gracefully")
func testReadError() async {
let mockFileAccessor = MockFileAccessor()
mockFileAccessor.readError = CocoaError(.fileReadCorruptFile)
let manager = SyncManager(fileAccessor: mockFileAccessor)
await #expect(throws: SyncError.self) {
try await manager.sync()
}
}
```
## ベストプラクティス
* **単一責任**:各プロトコルは1つの関心事を処理する——多くのメソッドを持つ「ゴッドプロトコル」を作らない
* **Sendable 一貫性**:プロトコルがActor境界をまたいで使用される場合に必要
* **デフォルトパラメーター**:本番コードは実際の実装をデフォルトで使用する。テストだけがモックを指定する必要がある
* **エラーのモック**:障害パスをテストするために設定可能なエラープロパティを持つモックを設計する
* **境界のみをモック**:外部の依存関係(ファイルシステム、ネットワーク、API)をモックし、内部型はモックしない
## 避けるべきアンチパターン
* すべての外部アクセスをカバーする単一の大きなプロトコルを作成する
* 外部の依存関係を持たない内部型をモックする
* 適切な依存性注入の代わりに `#if DEBUG` 条件文を使用する
* Actorと組み合わせて使用する際に `Sendable` 一貫性を忘れる
* 過度な設計:型が外部の依存関係を持たない場合、プロトコルは必要ない
## 使用場面
* ファイルシステム、ネットワーク、または外部APIに触れるあらゆるSwiftコード
* 実際の環境では引き起こすことが難しいエラー処理パスをテストする場合
* アプリ、テスト、SwiftUIプレビューのコンテキストで動作するモジュールを構築する場合
* Swift並行処理(Actor、構造化並行処理)を採用したテスト可能なアーキテクチャが必要なアプリExcerpt, first 4,983 characters of SKILL.md, verbatim from the audited commit. It is text from someone else’s repository, quoted so you can judge it before your agent reads it.
Install
Pinned to the audited commit fb3fb10
git clone https://github.com/affaan-m/ECC git -C ECC checkout fb3fb10d9622
The author documents no install command, so this uses the repository directly. Our verdict covers commit fb3fb10d9622 only.
Works in
The author has not said which agents this skill supports, and we have not tested it in any.
Audit history
Every audit, every source change
- ✓SAFE B 89 / 100
first audit · source
fb3fb10d9622
README badge
For maintainers · shows the latest audit
[](https://modelsatlas.com/skills/affaan-m/swift-protocol-di-testing/)
The badge shows our verdict and grade for this skill, and links back to this page. It changes when the audit does.
Similar skills
All coding & review skills →affaan-m/everything-claude-code
Eval-driven development (EDD) framework for AI coding sessions — define capability and regression evals before coding, grade with code-based, model-based, rule, or human graders, and track pass@k and pass^k reliability.…
affaan-m/everything-claude-code
Map a described workflow to the right ECC command group with run-order and stop condition, or browse all command-group recipe families read live from the commands directory. Advisory only — never executes. Use when…
affaan-m/everything-claude-code
Design task-local harnesses, eval gates, and reusable skill extraction for Claude dynamic workflow mode and other adaptive agent harnesses. Use when building a task-local harness, adding eval gates, or extracting a…
affaan-m/everything-claude-code
Run the full Django verification loop — environment check, mypy/ruff/black linting, migration safety, pytest with coverage targets, pip-audit and bandit security scans, settings and logging review, and diff review —…
affaan-m/everything-claude-code
Django architecture patterns, REST API design with DRF, ORM best practices, caching, signals, middleware, and production-grade Django apps. Use when building or reviewing Django apps, DRF APIs, ORM queries, or caching.
affaan-m/everything-claude-code
Django security best practices, authentication, authorization, CSRF protection, SQL injection prevention, XSS prevention, and secure deployment configurations. Use when reviewing Django authentication, authorization,…
Add this badge to your README
[](https://modelsatlas.com/skills/affaan-m/swift-protocol-di-testing/)
<a href="https://modelsatlas.com/skills/affaan-m/swift-protocol-di-testing/"><img src="https://modelsatlas.com/skills/affaan-m/swift-protocol-di-testing/badge.svg" alt="ModelsAtlas: SAFE B"></a>
Questions about Swift Protocol Di Testing
What does the Swift Protocol Di Testing skill do?
Is Swift Protocol Di Testing safe to install?
What can Swift Protocol Di Testing access on my machine?
How current is this page?
Sources
- github.com/affaan-m/ECC/tree/main/docs/ja-JP/skills/swift-protoc — the audited source at commit fb3fb10d9622 and every finding aboveObserved · 22 Sep 2026
Spotted something wrong? Report a correction · Methodology
Keep going in your AI
Opens with this page as the source. We add nothing else to the prompt.
- What does the Swift Protocol Di Testing skill do?
- Is Swift Protocol Di Testing safe to install?
- What can Swift Protocol Di Testing access on my machine?