From ios-platform
Reviews and writes Swift concurrency code for correctness, modern API usage, and common async/await pitfalls. Use when reading, writing, or reviewing Swift concurrency code targeting Swift 6.2+.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ios-platform:beepus-maximus-ios-swift-concurrencyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Review and write Swift concurrency code for correctness, modern API usage, and adherence to data-race safety. Report only genuine problems -- do not nitpick or invent issues.
references/actors-and-isolation.mdreferences/async-algorithms.mdreferences/async-streams-and-continuations.mdreferences/compiler-diagnostics.mdreferences/linting-and-suppression.mdreferences/memory-management.mdreferences/migration-patterns.mdreferences/sendable-and-data-safety.mdreferences/structured-concurrency.mdreferences/synchronization-framework.mdreferences/testing-concurrency.mdReview and write Swift concurrency code for correctness, modern API usage, and adherence to data-race safety. Report only genuine problems -- do not nitpick or invent issues.
Owns: Actor isolation, Sendable compliance, async/await patterns, structured concurrency, AsyncStream/AsyncSequence, continuations, Task lifecycle, cancellation, GCD-to-concurrency migration, Swift 6.2 concurrency features, concurrency-related compiler diagnostics, Synchronization framework (Mutex, Atomic).
Does NOT own: SwiftUI view architecture, networking layer design, general Swift language features, third-party framework APIs, Metal/GPU concurrency.
Mutex<T> (Synchronization framework) only when synchronous access is required or actor overhead is measurable.async let over Task {} wherever possible. Structured tasks propagate cancellation and collect errors automatically.@unchecked Sendable is a code smell -- It silences diagnostics without fixing races. Prefer actors, value types, sending parameters, or Mutex<T> (which is unconditionally Sendable). The only legitimate use of @unchecked Sendable is types with internal locking that are provably thread-safe.withCheckedThrowingContinuation for callback APIs, AsyncStream for delegate/multi-value APIs. Resume continuations exactly once on every code path.@MainActor may be implicit.await -- Actor state may have changed during suspension. A ! after await inside an actor is a latent crash.@concurrent, isolated conformances, and default actor isolation may post-date training data. Always consult the reference files before writing or reviewing Swift 6.2 concurrency code -- never rely on model knowledge alone.references/actors-and-isolation.md and references/sendable-and-data-safety.md to prioritize what to inspect.@concurrent, caller-actor async, isolated conformances).references/actors-and-isolation.md.references/structured-concurrency.md.references/async-streams-and-continuations.md.references/memory-management.md.references/async-algorithms.md.references/synchronization-framework.md.references/migration-patterns.md.references/compiler-diagnostics.md.references/testing-concurrency.md.If doing a partial review, load only the relevant reference files.
async let) over unstructured (Task {}).async/await and closure-based variants, always prefer async/await.@unchecked Sendable to fix compiler errors. Prefer actors, value types, or sending parameters instead.Organize findings by file. For each issue:
Skip files with no issues. End with a prioritized summary of the most impactful changes.
Example:
Line 18: Actor reentrancy -- state may have changed across the await.
// Before
actor Cache {
var items: [String: Data] = [:]
func fetch(_ key: String) async throws -> Data {
if items[key] == nil {
items[key] = try await download(key)
}
return items[key]!
}
}
// After
actor Cache {
var items: [String: Data] = [:]
func fetch(_ key: String) async throws -> Data {
if let existing = items[key] { return existing }
let data = try await download(key)
items[key] = data
return data
}
}
| Scenario | Use |
|---|---|
| Shared mutable state, background service | actor |
| ViewModel with UI-bound state | @MainActor class |
| Pure data model | struct: Sendable |
| Simple value protection (sync API) | Mutex<State> (Synchronization framework, iOS 18+) |
| High-frequency primitive ops (counter, flag) | Atomic<T> (Synchronization framework, iOS 18+) |
| Wrapping non-Sendable state as Sendable | Mutex<T> |
| Legacy interop, pre-iOS 18 | OSAllocatedUnfairLock |
| Type | Sendable? |
|---|---|
| Struct with all Sendable properties | Yes -- declare conformance |
| Enum with Sendable associated values | Yes -- declare conformance |
Final class with only let Sendable properties | Yes -- declare conformance |
| Class with internal locking | @unchecked Sendable (verify safety) |
Class with mutable var and no sync | No -- use actor or restructure |
| Keyword | Purpose |
|---|---|
@concurrent | Offload async function to concurrent pool |
nonisolated | Opt out of actor isolation |
nonisolated(nonsending) | Stay on caller's executor (explicit) |
isolated deinit | Run deinit on the class's actor |
sending | Transfer ownership across isolation boundary |
Task.immediate | Start task synchronously on current executor |
references/actors-and-isolation.md -- Actor isolation, reentrancy, @MainActor, global actor inference, nonisolated, global/static state protection, isolated deinit.references/structured-concurrency.md -- Task groups, async let, structured vs unstructured, Task {} dangers, concurrency limits.references/async-streams-and-continuations.md -- AsyncStream lifecycle, continuation management, checked vs unsafe continuations, bridging patterns.references/async-algorithms.md -- AsyncAlgorithms operators: debounce, throttle, merge, combineLatest, zip, chain, removeDuplicates, chunks, AsyncChannel, Combine migration mapping.references/memory-management.md -- Retain cycles in tasks, weak self patterns, async sequence retention, task handle lifecycle, diagnostic checklist.references/sendable-and-data-safety.md -- Sendable conformance, value types, @unchecked Sendable dangers, transfer patterns.references/migration-patterns.md -- GCD to async/await, completion handlers to async, DispatchQueue to actor, Swift 6 migration process, project settings, tooling.references/compiler-diagnostics.md -- Swift 6.2 compiler error to remedy mapping, common error messages and fixes, approachable concurrency mode.references/testing-concurrency.md -- Race detection, confirmation for async, @MainActor in tests, Swift Testing patterns.references/synchronization-framework.md -- Synchronization framework: Mutex, Atomic, memory orderings, when to use vs actors, anti-patterns, iOS 18+.references/linting-and-suppression.md -- SwiftLint concurrency rules, compiler warning fix order, suppression strategies, @preconcurrency, documentation requirements.npx claudepluginhub 4eleven7/claude-skills --plugin ios-platformProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.