/avdlee:swift-concurrencyfrom avdlee
Diagnose data races, convert callback-based code to async/await, implement actor isolation patterns, resolve Sendable conformance issues, and guide Swift 6 migration. Use when developers mention: (1) Swift Concurrency, async/await, actors, or tasks, (2) "use Swift Concurrency" or "modern concurrency patterns", (3) migrating to Swift 6, (4) data races or thread safety issues, (5) refactoring closures to async/await, (6) @MainActor, Sendable, or actor isolation, (7) concurrent code architecture or performance optimization, (8) concurrency-related linter warnings (SwiftLint or similar; e.g. async_without_await, Sendable/actor isolation/MainActor lint).
Ships in avdlee. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Package.swift or .pbxproj to determine Swift language mode (5.x vs 6) and toolchain before giving advice.@MainActor, custom actor, actor instance isolation, or nonisolated.@MainActor as a blanket fix. Justify why main-actor isolation is correct for the code.Task.detached only with a clear reason.@preconcurrency, @unchecked Sendable, or nonisolated(unsafe), require:
@MainActor, custom actor, default isolation).Use Quick Fix Mode when:
Skip Quick Fix Mode when:
@unchecked Sendable, @preconcurrency, or nonisolated(unsafe) without a clear invariant.Concurrency behavior depends on build settings. Before advising, determine these via Read on Package.swift or Grep in .pbxproj files:
| Setting | SwiftPM (Package.swift) | Xcode (.pbxproj) |
|---|---|---|
| Default isolation | .defaultIsolation(MainActor.self) | SWIFT_DEFAULT_ACTOR_ISOLATION |
| Strict concurrency | .enableExperimentalFeature("StrictConcurrency=targeted") | SWIFT_STRICT_CONCURRENCY |
| Upcoming features | .enableUpcomingFeature("NonisolatedNonsendingByDefault") | SWIFT_UPCOMING_FEATURE_* |
| Language mode | // swift-tools-version: at top | Swift Language Version build setting |
If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance.
Prefer edits that preserve behavior while satisfying data-race safety.
@MainActor (justify why UI-bound).actor or isolate to @MainActor if UI-only.async function marked @concurrent; for work that doesn’t touch isolated state but can inherit the caller’s isolation (for example with NonisolatedNonsendingByDefault), use nonisolated without @concurrent, or use an actor to guard mutable state.@unchecked Sendable unless you can prove and document thread safety.@MainActor or hop with await MainActor.run { ... }.references/actors.md.extension Foo: @MainActor SomeProtocol).nonisolated; use references/actors.md.let) state.@unchecked Sendable; use references/sendable.md and references/threading.md.async_without_await
async if not required; if required by protocol/override/@concurrent, use narrow suppression with rationale. See references/linting.md.await fulfillment(of:) or Swift Testing equivalents. See references/testing.md.When a developer needs concurrency guidance, follow this decision tree:
Starting fresh with async code?
references/async-await-basics.md for foundational patternsreferences/tasks.md (async let, task groups)Protecting shared mutable state?
references/actors.md (actors, @MainActor)references/sendable.md (Sendable conformance)Managing async operations?
references/tasks.md (Task, child tasks, cancellation)references/async-sequences.md (AsyncSequence, AsyncStream)Working with legacy frameworks?
references/core-data.mdreferences/migration.mdPerformance or debugging issues?
references/performance.md (profiling, suspension points)references/testing.md (XCTest, Swift Testing)Understanding threading behavior?
references/threading.md for thread/task relationship and isolationMemory issues with tasks?
references/memory-management.md for retain cycle preventionreferences/linting.md for rule intent and preferred fixes; avoid dummy awaits as “fixes”.async_without_await warning
async if not required; if required by protocol/override/@concurrent, prefer narrow suppression over adding fake awaits. See references/linting.md.references/sendable.md and references/threading.md (especially Swift 6.2 behavior changes)@MainActorreferences/actors.md (global actors, nonisolated, isolated parameters) and references/threading.md (default isolation)references/threading.md to avoid thread-centric debugging and rely on isolation + Instruments@MainActor) or can safely be nonisolated.references/actors.md for implementation patterns (isolated conformances, nonisolated requirements, and escalation steps).references/testing.md (await fulfillment(of:) and Swift Testing patterns)references/core-data.md (DAO/NSManagedObjectID, default isolation conflicts)| Need | Tool | Key Guidance |
|---|---|---|
| Single async operation | async/await | Default choice for sequential async work |
| Fixed parallel operations | async let | Known count at compile time; auto-cancelled on throw |
| Dynamic parallel operations | withTaskGroup | Unknown count; structured — cancels children on scope exit |
| Sync → async bridge | Task { } | Inherits actor context; use Task.detached only with documented reason |
| Shared mutable state | actor | Prefer over locks/queues; keep isolated sections small |
| UI-bound state | @MainActor | Only for truly UI-related code; justify isolation |
Network request with UI update
Task { @concurrent in
let data = try await fetchData()
await MainActor.run { self.updateUI(with: data) }
}
Processing array items in parallel
await withTaskGroup(of: ProcessedItem.self) { group in
for item in items {
group.addTask { await process(item) }
}
for await result in group {
results.append(result)
}
}
Key changes in Swift 6:
Apply this cycle for each migration change:
swift build or Xcode build to surface new diagnosticsswift test or Cmd+U)If a fix introduces new warnings, resolve them before continuing. Never batch multiple unrelated fixes — keep commits small and reviewable.
For detailed migration steps, see references/migration.md.
Load these files as needed for specific topics:
async-await-basics.md - async/await syntax, execution order, async let, URLSession patternstasks.md - Task lifecycle, cancellation, priorities, task groups, structured vs unstructuredthreading.md - Thread/task relationship, suspension points, isolation domains, nonisolatedmemory-management.md - Retain cycles in tasks, memory safety patternsactors.md - Actor isolation, @MainActor, global actors, reentrancy, custom executors, Mutexsendable.md - Sendable conformance, value/reference types, @unchecked, region isolationlinting.md - Concurrency-focused lint rules and SwiftLint async_without_awaitasync-sequences.md - AsyncSequence, AsyncStream, when to use vs regular async methodscore-data.md - NSManagedObject sendability, custom executors, isolation conflictsperformance.md - Profiling with Instruments, reducing suspension points, execution strategiestesting.md - XCTest async patterns, Swift Testing, concurrency testing utilitiesmigration.md - Swift 6 migration strategy, closure-to-async conversion, @preconcurrency, FRP migrationreferences/testing.md).references/performance.md).references/memory-management.md).Task.isCancelled in long-running operations.Mutex instead.See references/glossary.md for quick definitions of core concurrency terms used across this skill.
Note: This skill is based on the comprehensive Swift Concurrency Course by Antoine van der Lee.
references/_index.md (opens in a new tab)references/actors.md (opens in a new tab)references/async-algorithms.md (opens in a new tab)references/async-await-basics.md (opens in a new tab)references/async-sequences.md (opens in a new tab)references/core-data.md (opens in a new tab)references/glossary.md (opens in a new tab)references/linting.md (opens in a new tab)references/memory-management.md (opens in a new tab)references/migration.md (opens in a new tab)references/performance.md (opens in a new tab)references/sendable.md (opens in a new tab)references/tasks.md (opens in a new tab)references/testing.md (opens in a new tab)references/threading.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
5 skills in this plugin
/core-data-expertExpert Core Data guidance (iOS/macOS): stack setup, fetch requests & NSFetchedResultsController, saving/merge conflicts, threading & Swift Concurrency, batch operations & persistent history, migrations, performance, and NSPersistentCloudKitContainer/CloudKit sync./swift-testing-expertExpert guidance for Swift Testing: test structure, #expect/#require macros, traits and tags, parameterized tests, test plans, parallel execution, async waiting patterns, and XCTest migration. Use when writing new Swift tests, modernizing XCTest suites, debugging flaky tests, or improving test quality and maintainability in Apple-platform or Swift server projects./swiftui-expert-skillWrite, review, or improve SwiftUI code following best practices for state management, view composition, performance, macOS-specific APIs, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns./update-swiftui-apisScan Apple's SwiftUI documentation for deprecated APIs and update the SwiftUI Expert Skill with modern replacements. Use when asked to "update latest APIs", "refresh deprecated SwiftUI APIs", "check for new SwiftUI deprecations", "scan for API changes", or after a new iOS/Xcode release. Requires the Sosumi MCP to be available.npx claudepluginhub ulpi-io/plugin-marketplace --plugin avdlee