ios-concurrencylisted
Swift Concurrency expert skill covering async/await, structured concurrency (Task, TaskGroup), actors and @MainActor, Sendable protocol and checking, AsyncSequence/AsyncStream, continuations for bridging callback APIs, Swift 6 strict concurrency mode, and common concurrency patterns (debouncing, throttling, actor-based shared state, background processing). Use this skill whenever the user writes concurrent Swift code, works with async/await, actors, or Sendable, migrates to Swift 6 concurrency, or needs to handle background work and thread safety. Triggers on: async, await, Task, TaskGroup, actor, @MainActor, Sendable, @Sendable, concurrency, AsyncSequence, AsyncStream, continuation, withCheckedContinuation, nonisolated, GlobalActor, Swift 6, strict concurrency, data race, thread safety, background task, parallel, concurrent, dispatch queue migration, or any Swift concurrency question.
ebbaunqualified520/ios-agent-skills · ★ 0 · AI & Automation · score 72
Install: claude install-skill ebbaunqualified520/ios-agent-skills
# iOS Concurrency Skill
## Core Rules
1. **Use async/await for ALL new asynchronous code.** Do not use completion handlers or Combine for async operations in new code.
2. **Use structured concurrency (Task, TaskGroup).** Avoid unstructured task leaks. Prefer `async let` or `TaskGroup` over spawning loose `Task {}` blocks.
3. **Mark UI-updating code with @MainActor.** SwiftUI views are already `@MainActor`-isolated. UIKit code that touches UI must run on `@MainActor`.
4. **Use actors for shared mutable state** instead of locks, semaphores, or serial dispatch queues.
5. **All types crossing actor boundaries must be Sendable.** The compiler enforces this in strict concurrency mode.
6. **Prefer value types (struct, enum) for Sendable.** They are implicitly Sendable when all stored properties are Sendable.
7. **Use `withCheckedContinuation` to bridge callback-based APIs** to async/await. Never resume a continuation more than once.
8. **Use `AsyncStream` for bridging delegate/callback patterns** to `AsyncSequence`.
9. **`Task.detached` is rarely needed.** Use `Task {}` with explicit actor isolation instead. Detached tasks lose actor context and priority inheritance.
10. **Always handle Task cancellation cooperatively.** Check `Task.isCancelled` or call `try Task.checkCancellation()` at appropriate points.
## Decision Guide
| Scenario | Solution |
|----------|----------|
| Single async operation | `async func` / `Task {}` |
| Multiple independent operations | `TaskGroup` / `asyn