Concurrency
You MUST use this skill for ANY concurrency, async/await, threading, or Swift 6 concurrency work.
<!-- AXIOM_AUDITOR_INLINE_BEGIN — auto-maintained by scripts/build-inlined-auditors.ts; do not hand-edit --><!-- AXIOM_AUDITOR_INLINE_END -->Not on Claude Code? Where this router says "Launch
some-auditoragent", read that auditor's file in this suite and follow it inline — the same procedure, needing only file search and read.Available here:
skills/concurrency-auditor.md.Agents that need Bash — builds, tests, simulators, crash symbolication — stay Claude Code-only; there is no inline equivalent for those.
Quick Reference
Decision Tree
- Data races / actor isolation / @MainActor / Sendable / Swift 6 migration? →
skills/swift-concurrency.md1a. Need specific API syntax (actor definition, TaskGroup, AsyncStream, continuations)? →skills/swift-concurrency-ref.md1b. NotificationCenter observer,userInfocasting, or Sendable errors unpacking a notification? →skills/swift-concurrency-ref.md(Typed Notifications —MainActorMessage/AsyncMessage, iOS 26+) - Writing async/await code? →
skills/swift-concurrency.md - assumeIsolated / @preconcurrency? →
skills/assume-isolated.md3a. Warning-free Swift 6 build that crashes in production with_dispatch_assert_queue_failor_swift_task_checkIsolatedSwift? →skills/isolation-inheritance-diag.md - Mutex / lock / synchronization? →
skills/synchronization.md - Profile async performance / actor contention? →
skills/concurrency-profiling.md - Value type / ARC / generic optimization? → See axiom-performance (skills/swift-performance.md)
- borrowing / consuming / ~Copyable? → See axiom-swift (skills/ownership-conventions.md)
- Combine / @Published / AnyCancellable / reactive streams? → See axiom-uikit (skills/combine-patterns.md)
- Want automated concurrency scan? → concurrency-auditor (Agent)
Concurrency in practice
- HealthKit queries with Swift Concurrency (canonical bridging example) → See axiom-health (skills/queries.md)
Conflict Resolution
concurrency vs axiom-performance: When app freezes or feels slow:
- Try concurrency FIRST — Main thread blocking is the #1 cause of UI freezes. Check for synchronous work on @MainActor before profiling.
- Only use axiom-performance if concurrency fixes don't help — Profile after ruling out obvious blocking.
- To pin a specific freeze to app code, see the Hang Window Workflow in axiom-performance (skills/hang-diagnostics.md) — re-scope
xcprof analyzeto the hang window with--start-ms/--end-ms --user-binaryto surface the app-owned frame on the main thread.
concurrency vs axiom-build: When seeing Swift 6 concurrency errors:
- Use concurrency, NOT axiom-build — Concurrency errors are CODE issues, not environment issues.
concurrency vs axiom-data: When concurrency errors involve Core Data or SwiftData:
- Core Data threading (NSManagedObjectContext thread confinement) → use axiom-data first
- SwiftData + @MainActor ModelContext → use concurrency
- General "background saves losing data" → use axiom-data first
- GRDB Sendable patterns (struct records,
databaseSelectionas computed property, Swift 6 conformance) → See axiom-data (skills/grdb-performance.md) §8
Critical Patterns
Swift Concurrency (skills/swift-concurrency.md):
- Progressive journey: single-threaded → async → concurrent → actors
- @concurrent attribute for forced background execution
- Isolated conformances, main actor mode
- 12 copy-paste patterns including delegate value capture, weak self in Tasks
- Comprehensive decision tree for 7 common error messages
API Reference (skills/swift-concurrency-ref.md):
- Actor definition, reentrancy, global actors, nonisolated
- Sendable patterns, @unchecked Sendable, sending parameter
- Task/TaskGroup/cancellation, async let, withDiscardingTaskGroup
- AsyncStream, continuations, buffering policies
- Isolation patterns (#isolation, @preconcurrency, nonisolated(unsafe))
- DispatchQueue/DispatchGroup/completion handler migration
Synchronization (skills/synchronization.md):
- Mutex (iOS 18+), OSAllocatedUnfairLock (iOS 16+), Atomic types
- Lock vs actor decision tree
- Danger patterns: locks across await, semaphores in async context
Profiling (skills/concurrency-profiling.md):
- Swift Concurrency Instruments template
- Diagnosing main thread blocking, actor contention, thread pool exhaustion
- Safe vs unsafe primitives for cooperative pool
Runtime Isolation Crashes (skills/isolation-inheritance-diag.md):
_dispatch_assert_queue_failand_swift_task_checkIsolatedSwiftsignatures- Closure isolation inheritance (Core Data
perform, Combine.map, NotificationCenter.sink) - Delegate method isolation inheritance (CLLocationManager, NSDocument, AVAudioPlayerDelegate, WKNavigationDelegate)
MainActor.assumeIsolatedmisuse- Actor reentrancy state staleness
Automated Scanning
Concurrency audit → Launch concurrency-auditor agent or /axiom:audit concurrency (5-phase semantic audit: maps isolation architecture, detects 8 anti-patterns, reasons about missing concurrency patterns, correlates compound risks, scores Swift 6.4 readiness)
Anti-Rationalization
Example Invocations
User: "I'm getting 'data race' errors in Swift 6"
→ Read: skills/swift-concurrency.md
User: "How do I use @MainActor correctly?"
→ Read: skills/swift-concurrency.md
User: "How do I create a TaskGroup?"
→ Read: skills/swift-concurrency-ref.md
User: "What's the AsyncStream API?"
→ Read: skills/swift-concurrency-ref.md
User: "How do I use assumeIsolated?"
→ Read: skills/assume-isolated.md
User: "Should I use Mutex or actor?"
→ Read: skills/synchronization.md
User: "My async code is slow, how do I profile it?"
→ Read: skills/concurrency-profiling.md
User: "My warning-free Swift 6 build crashes in production with _dispatch_assert_queue_fail"
→ Read: skills/isolation-inheritance-diag.md
User: "Core Data context.perform crashes inside an @MainActor view model"
→ Read: skills/isolation-inheritance-diag.md
User: "CLLocationManager delegate method is crashing with _swift_task_checkIsolatedSwift"
→ Read: skills/isolation-inheritance-diag.md
User: "My app is slow due to unnecessary copying" → See axiom-performance (skills/swift-performance.md)
User: "Check my code for Swift 6 concurrency issues"
→ Invoke: concurrency-auditor agent


