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.zip

Installs 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.
69 charsno explicit “when” trigger
Advanced

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

You give it
Swift business logic or module requiring clean architecture and concurrency patterns
You get back
Pure Swift module adhering to Clean Architecture, using modern concurrency, and testable components

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):

  1. UseCases (Interactors):

    • A UseCase MUST contain only one primary public function: func execute() async -> Result<T, Error>.
    • Do NOT use callAsFunction for this to maintain explicit naming.
    • UseCases MUST always return a standard Swift Result<T, Error>.
    • Any external Helper or Manager MUST be injected into the UseCase, not the Repository.
  2. Repositories and DataSources:

    • Repositories return raw data types (e.g., User, [Item]) via async throws, NOT Result<T, Error>. The UseCase catches compilation errors and maps them to Result.
    • 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 protocol for Repositories to allow easy mocking in unit tests.
  3. 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 actor for shared mutable state to avoid data races.
  • Value Semantics: Default to struct for models. Use class ONLY when reference semantics or Identity are strictly required.
  • Serialization: Use Codable.
  • Error Handling Boundary: Do NOT leak raw network or database Error types directly to the View. The Result<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 @Sendable closures and explicitly mark isolated boundaries.
  • Closures: Avoid strong reference cycles by explicitly using [weak self] in escaping closures. However, with async/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.

SkillInstallsUpdatedSafetyDifficulty
swift (this skill)04moNo flagsAdvanced
swift-concurrency42moNo flagsAdvanced
implement-feature16moReviewAdvanced
feature-toggle-developer16moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

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).

433

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

16

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.

14

swiftui-patterns-developer

anyproto

SwiftUI view structure, composition, and best practices. Use when refactoring SwiftUI views, organizing view files, or extracting subviews.

10

swift-concurrency-6-2

JantonioFC

Swift 6.2 Approachable Concurrency — single-threaded by default, @concurrent

00

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.

00

Search skills

Search the agent skills registry