
Swift Protocol Dependency Injection Testing
Write Swift code whose file, network, and API access can be swapped for fast, deterministic mocks in tests.
- Repository
- affaan-m/ECC
- Stars
- 295,127
- Licence
- MIT
- Files
- 1 file
What it does
This skill teaches the agent a specific way to structure Swift apps so that code touching the file system, network, or external services goes through small protocols instead of calling those services directly. When you ask for Swift code or tests, the agent writes production versions of these protocols plus mock versions that simulate success and failure without real I/O, using Apple's Swift Testing framework. It is a coding guide the agent follows, not a tool that changes your files on its own.
Great for
- Swift and iOS/macOS developers who want unit tests for file, network, or iCloud code
- Teams adopting Swift concurrency (actors, Sendable) who need testable architecture
- Developers who want to test error paths that are hard to trigger in real environments
Skip it if
- Projects not written in Swift, since the patterns and examples are Swift-only
- Simple code with no external dependencies, where the skill itself warns that a protocol adds unnecessary complexity
- Non-developers looking for a finished app; this only shapes code the agent writes
Try asking
- “Refactor my SyncManager so file access can be mocked, and write Swift Testing tests for its error cases”
- “Create a FileAccessorProviding protocol and a mock for my Swift app's read and write code”
- “Write tests for a Swift function that loads data from iCloud without touching the real container”
- “Design a testable network layer in Swift using actors and Sendable protocols”
Install in 3 steps
- 1
Download the skill
The ZIP contains the 1 original files, the MIT licence and an attribution note.
swift-protocol-di-testing.zip - 2
Add it to your agent
Claude Code (all projects)
mkdir -p ~/.claude/skills && unzip swift-protocol-di-testing.zip -d ~/.claude/skills/Claude Code / Agent SDK (this project only)
mkdir -p .claude/skills && unzip swift-protocol-di-testing.zip -d .claude/skills/Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.
- 3
Ask for the task
No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.
Get better results
- Ask for one focused protocol per external concern rather than one large protocol, as the skill recommends.
- Review the mock code: the skill's example mock is explicitly not thread-safe, so check it before using it in concurrent tests.
- Provide your existing Swift types so the agent can apply the default-parameter injection pattern to your real code.
What's inside
- SKILL.md
Redistributed unmodified from affaan-m/ECC under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.