swift
Installation
SKILL.md
Swift Architecture Standards
Use this skill for pure Swift modules where clean boundaries, concurrency, and testability matter.
1. Clean Architecture Rules (Domain Layer)
When writing Swift business logic (Domain/Core modules):
-
UseCases (Interactors):
- A UseCase MUST contain only one primary public function:
func execute() async -> Result<T, Error>. - Do NOT use
callAsFunctionfor this to maintain explicit naming. - UseCases MUST always return a standard Swift
Result<T, Error>. - Any external
HelperorManagerMUST be injected into the UseCase, not the Repository.
- A UseCase MUST contain only one primary public function:
-
Repositories and DataSources:
- Repositories return raw data types (e.g.,
User,[Item]) viaasync throws, NOTResult<T, Error>. The UseCase catches compilation errors and maps them toResult. - Repositories depend ONLY on DataSources. A Repository MUST NOT depend on another Repository.
- DataSources depend only on external APIs/DBs/Network. A DataSource MUST NOT depend on another DataSource.
- Use
protocolfor Repositories to allow easy mocking in unit tests.
- Repositories return raw data types (e.g.,