
Swift Concurrency
Navigate Swift Concurrency topics—from async/await and actors to migration, testing, and Instruments—when building or hardening iOS/macOS code with Swift 6 isolation rules.
Install
npx skills add https://github.com/avdlee/swift-concurrency-agent-skill --skill swift-concurrencyWhat is this skill?
- Reference index routing quick fixes (compiler errors) vs deep dives across 15+ topic files
- Foundations: async/await bridges, Task/cancellation/groups, actors/@MainActor, Sendable, threading model
- Streams: AsyncSequence vs AsyncStream plus async-algorithms (debounce, throttle, merge, channels)
- Applied: Swift Testing-first test guidance, Instruments performance workflow, Core Data isolation patterns
- Migration and linting guardrails for Swift 6 rollout order and concurrency-focused rules
Adoption & trust: 11.9k installs on skills.sh; 1.5k GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+200% hot-view momentum).
Recommended Skills
Journey fit
Swift Concurrency work lands in Build when implementing or refactoring app code; the same reference supports Ship (testing, perf) and Operate (memory, long-lived tasks). Mobile client code (SwiftUI/UIKit) is the primary shelf; reference files also cover Core Data and concurrency linting that tie back to app-layer implementation.
Common Questions / FAQ
Is Swift Concurrency safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Swift Concurrency
# Reference Index Quick navigation for the Swift Concurrency skill. ## Foundations | File | Use it for | |---|---| | `async-await-basics.md` | closure-to-async bridges and foundational async/await usage | | `tasks.md` | `Task`, cancellation, task groups, structured vs unstructured work | | `actors.md` | actor isolation, `@MainActor`, reentrancy, isolated conformances | | `sendable.md` | `Sendable`, `@Sendable`, region isolation, escape hatches | | `threading.md` | execution model, suspension points, Swift 6.2 isolation behavior | ## Streams | File | Use it for | |---|---| | `async-sequences.md` | deciding between `AsyncSequence`, `AsyncStream`, and one-shot async APIs | | `async-algorithms.md` | debounce, throttle, merge, `combineLatest`, channels, timers | ## Applied Topics | File | Use it for | |---|---| | `testing.md` | Swift Testing first, XCTest fallback, leak checks | | `performance.md` | Instruments workflow, actor hops, suspension cost | | `memory-management.md` | retain cycles, long-lived tasks, cleanup | | `core-data.md` | `NSManagedObjectID`, `perform`, default isolation conflicts | ## Migration and Tooling | File | Use it for | |---|---| | `migration.md` | rollout order, build settings, migration guardrails | | `linting.md` | concurrency-focused lint rules | | `glossary.md` | quick definitions | ## Problem Router - "I need to fix a compiler error quickly" → `../SKILL.md` - "I need to replace a callback with async/await" → `async-await-basics.md` - "I need to protect shared mutable state" → `actors.md` - "I need to pass data safely across boundaries" → `sendable.md` - "I need stream operators" → `async-algorithms.md` - "I need to understand why code runs where it runs" → `threading.md` - "I need to stop a leak or lifetime issue" → `memory-management.md` - "I need to migrate to Swift 6" → `migration.md` - "I need to test async code" → `testing.md` - "I need to optimize slow async code" → `performance.md` # Actors Use this when: - You need to protect class-based mutable state from concurrent access. - You are choosing between `actor`, `@MainActor`, `nonisolated`, or `Mutex`. - You are resolving protocol conformance issues on actor-isolated types. Skip this file if: - You mainly need to make a value safe to transfer across boundaries. Use `sendable.md`. - You are debugging execution threads or suspension behavior. Use `threading.md`. Jump to: - Actor Isolation - Global Actors / @MainActor - Isolated vs Nonisolated - Actor Reentrancy - Isolated Deinit / Isolated Conformances (Swift 6.2+) - `#isolation` Macro - Mutex: Alternative to Actors - Decision Tree ## What is an Actor? Actors protect mutable state by ensuring only one task accesses it at a time. They're reference types with automatic synchronization. ```swift actor Counter { var value = 0 func increment() { value += 1 } } ``` **Key guarantee**: Only one task can access mutable state at a time (serialized access). > **Course Deep Dive**: This topic is covered in detail in [Lesson 5.1: Understanding actors in Swift Concurrency](https://www.swiftconcurrencycourse.com?utm_source=github&utm_medium=agent-skill&utm_campaign=lesson-reference) ## Actor Isolation ### Enforced by compiler ```swift actor BankAccount { var balance: Int = 0 func deposit(_ amount: Int) { balance += amount } } let account = BankAccount() account.balance += 1 // ❌ Error: can't mutate from outside await account.deposit(1) // ✅ Must use actor's methods ``` ### Reading properties ```swift let account = BankAccount() await account.deposit(100) print(await account.balance) // Must await reads too ``` Always use `await` when accessing actor properties/methods—you don't know if another task is inside. ## Actors vs Classes ### Similarities - Reference types (copies share same instance) - Can have properties, methods, initializers - Can conform to protocols ### Differences - **No inheritance** (except `NSObject` for Objec