← ClaudeAtlas

swift-concurrencylisted

Guide for building, auditing, and refactoring Swift code using modern concurrency patterns (Swift 6+). This skill should be used when working with async/await, Tasks, actors, MainActor, Sendable types, isolation domains, or when migrating legacy callback/Combine code to structured concurrency. Covers Approachable Concurrency settings, isolated parameters, and common pitfalls.
ibossyNr1/aaas-vault · ★ 12 · AI & Automation · score 67
Install: claude install-skill ibossyNr1/aaas-vault
# Swift Concurrency ## Overview This skill provides guidance for writing thread-safe Swift code using modern concurrency patterns. It covers three main workflows: building new async code, auditing existing code for issues, and refactoring legacy patterns to Swift 6+. **Core principle**: Isolation is inherited by default. With Approachable Concurrency, code starts on MainActor and propagates through the program automatically. Opt out explicitly when needed. ## Workflow Decision Tree ``` What are you doing? │ ├─► BUILDING new async code │ └─► See "Building Workflow" below │ ├─► AUDITING existing code │ └─► See "Auditing Checklist" below │ └─► REFACTORING legacy code └─► See "Refactoring Workflow" below ``` ## Building Workflow When writing new async code, follow this decision process: ### Step 1: Determine Isolation Needs ``` Does this type manage UI state or interact with UI? │ ├─► YES → Mark with @MainActor │ └─► NO → Does it have mutable state shared across contexts? │ ├─► YES → Consider: Can it live on MainActor anyway? │ │ │ ├─► YES → Use @MainActor (simpler) │ │ │ └─► NO → Use a custom actor (requires justification) │ └─► NO → Leave non-isolated (default with Approachable Concurrency) ``` ### Step 2: Design Async Functions ```swift // PREFER: Inherit caller's isolation (works everywhere) func fetchData(isolation: isolated (any Actor)? = #isolation) as