Provides architectural rules and patterns for building scalable and testable pure Swift modules.
Install
mkdir -p .claude/skills/swift-abivan-tech && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/19261" && unzip -o skill.zip -d .claude/skills/swift-abivan-tech && rm skill.zipInstalls to .claude/skills/swift-abivan-tech
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Clean Architecture, concurrency, and patterns for pure Swift modules.Key capabilities
- →Define UseCases with a single primary public function
- →Ensure UseCases return `Result<T, Error>`
- →Structure Repositories to return raw data types via `async throws`
- →Isolate DataSources to depend only on external APIs/DBs/Network
- →Utilize modern Swift Concurrency (`async`/`await`, `Task`, `TaskGroup`)
How it works
It enforces Clean Architecture by defining clear boundaries between UseCases, Repositories, and DataSources. It promotes modern Swift Concurrency and proper dependency injection to ensure testability and maintainability.
Inputs & outputs
When to use swift
- →Refactor business logic into a UseCase
- →Structure a repository and datasource for data fetching
- →Implement actor-based state management
- →Apply clean architecture to a new module
About this skill
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.,
-
Dependency Graph:
UI/ViewModel->UseCase->Repository->DataSource
2. Swift Language Patterns
- Concurrency: Prefer modern Swift Concurrency (
async/await,Task,TaskGroup) over GCD (DispatchQueue) or Combine publishers for one-shot operations. - Actors: Use
actorfor shared mutable state to avoid data races. - Value Semantics: Default to
structfor models. UseclassONLY when reference semantics or Identity are strictly required. - Serialization: Use
Codable. - Error Handling Boundary: Do NOT leak raw network or database
Errortypes directly to the View. TheResult<T, Error>from a UseCase must be mapped by the ViewModel/Reducer into specific, UI-friendly State enumerations or One-Time Events. - Swift Strict Concurrency: Code should be safe under strict concurrency checking. Use
@Sendableclosures and explicitly mark isolated boundaries. - Closures: Avoid strong reference cycles by explicitly using
[weak self]in escaping closures. However, withasync/await, prefer async functions over escaping closures to eliminate this risk entirely.
When not to use it
- →When working with non-Swift modules
- →When reference semantics or identity are strictly required for models (prefer `struct` otherwise)
- →When GCD or Combine publishers are preferred over modern Swift Concurrency for one-shot operations
Limitations
- →Specific to pure Swift modules
- →UseCases must contain only one primary public function
- →Repositories depend ONLY on DataSources
How it compares
This skill provides a prescriptive set of rules for structuring Swift modules based on Clean Architecture, which is more rigorous than ad-hoc organization or less strict architectural patterns.
Compared to similar skills
swift side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| swift (this skill) | 0 | 4mo | No flags | Advanced |
| swift-concurrency | 4 | 2mo | No flags | Advanced |
| implement-feature | 1 | 6mo | Review | Advanced |
| feature-toggle-developer | 1 | 6mo | Review | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by ABIvan-Tech
View all by ABIvan-Tech →You might also like
swift-concurrency
AvdLee
Expert guidance on Swift Concurrency best practices, patterns, and implementation. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).
implement-feature
tddworks
Guide for implementing features in ClaudeBar following architecture-first design, TDD, rich domain models, and Swift 6.2 patterns. Use this skill when: (1) Adding new functionality to the app (2) Creating domain models that follow user's mental model (3) Building SwiftUI views that consume domain models directly (4) User asks "how do I implement X" or "add feature Y" (5) Implementing any feature that spans Domain, Infrastructure, and App layers
feature-toggle-developer
anyproto
Guides systematic removal of feature toggles from the codebase with automated cleanup detection. Use when removing feature flags, enabling toggles permanently, or cleaning up unused code after toggle removal.
swiftui-patterns-developer
anyproto
SwiftUI view structure, composition, and best practices. Use when refactoring SwiftUI views, organizing view files, or extracting subviews.
swift-concurrency-6-2
JantonioFC
Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent
architecture-audit
rfhayn
Check codebase for architectural violations (factory bypass, raw assign, scope compliance, service layer). TRIGGER when the user discusses creating Core Data objects in production code, adding new entity creation sites, or before PR creation on milestones that touch the service/model layer.