swift-concurrency
Diagnose Swift Concurrency issues, refactor callback-based code to async/await, and guide Swift 6 migration when working with tasks, actors, @MainActor, Sendable, data races, thread safety, or concurrency-related compiler and linter warnings.
Install / Use
npx skills add AvdLee/Swift-Concurrency-Agent-Skill --skill swift-concurrencyInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Development & EngineeringSupported Platforms
Tags
Our assessment of swift-concurrency
swift-concurrency scores 92/100 on our quality scale, 901st of 4,698 Development & Engineering skills we index (top 20%).
Its SKILL.md is 12 KB long, well organised into 13 sections with 3 code examples: a thorough specification that gives an agent plenty to work with.
With 1,661 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so swift-concurrency is actively maintained.
- Our last check on 2026-10-27 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit β read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-03. Automated pattern scan on 2026-10-03. It catches known dangerous patterns, not every risk β read a skill before letting an agent act on it.
swift-concurrency compared with similar skills
All 4 of these similar skills score higher than swift-concurrency; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| swift-concurrency (this skill)by AvdLee | 92 | 1.7k | 2mo ago | SKILL.md |
| taste-skillby Leonxlnx | 100 | 116.8k | 8d ago | CLAUDE.md |
| ai-job-searchby ai-job-search-dev | 100 | 72.1k | today | CLAUDE.md |
| claude-howtoby luongnv89 | 100 | 47.3k | 2d ago | CLAUDE.md |
| lobehubby lobehub | 100 | 85.6k | today | MCP Server |
Frequently asked questions
- How do I install swift-concurrency?
- Run
npx skills add AvdLee/Swift-Concurrency-Agent-Skill --skill swift-concurrency. The install tabs above show the steps for each supported agent. - Which AI agents does swift-concurrency work with?
- It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is swift-concurrency safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is swift-concurrency still maintained?
- The repository was last updated about 2 months ago, so swift-concurrency is actively maintained.
Skill content
View source on GitHubname: swift-concurrency description: Diagnose Swift Concurrency issues, refactor callback-based code to async/await, and guide Swift 6 migration when working with tasks, actors, @MainActor, Sendable, data races, thread safety, or concurrency-related compiler and linter warnings.
Swift Concurrency
Fast Path
Before proposing a fix:
- Analyze
Package.swiftor.pbxprojto determine Swift language mode, strict concurrency level, default isolation, and upcoming features. Do this always, not only for migration work. - Capture the exact diagnostic and offending symbol.
- Determine the isolation boundary:
@MainActor, custom actor, actor instance isolation, ornonisolated. - Confirm whether the code is UI-bound or intended to run off the main actor. When spawning unstructured tasks, inspect the synchronous prefix (everything before the first
await): start on@MainActoronly when that prefix truly needs main-actor access; otherwise useTask { @concurrent in ... }and hop back withMainActor.runonly after the suspension. A trivial non-main line (for example,print) followed by main-actor work in the same prefix is not a reason to use@concurrent. For delayed retries, timers, and backoff tasks, separate the waiting from the UI mutation. The sleep often belongs off the main actor even when the final state update belongs on it.
Project settings that change concurrency behavior:
| Setting | SwiftPM (Package.swift) | Xcode (.pbxproj) |
|---|---|---|
| Language mode | swiftLanguageVersions or -swift-version (// swift-tools-version: is not a reliable proxy) | Swift Language Version |
| Strict concurrency | .enableExperimentalFeature("StrictConcurrency=targeted") | SWIFT_STRICT_CONCURRENCY |
| Default isolation | .defaultIsolation(MainActor.self) | SWIFT_DEFAULT_ACTOR_ISOLATION |
| Upcoming features | .enableUpcomingFeature("NonisolatedNonsendingByDefault") | SWIFT_UPCOMING_FEATURE_* |
| Approachable Concurrency | N/A (use individual upcoming features) | SWIFT_APPROACHABLE_CONCURRENCY |
Xcode 26 note: New projects created in Xcode 26 will often start with
SWIFT_DEFAULT_ACTOR_ISOLATION = MainActorandSWIFT_APPROACHABLE_CONCURRENCY = YESenabled by default. Treat these as likely defaults for newly created projects, not as confirmed settings.
If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance. Do not guess, even for new Xcode 26 projects.
Guardrails:
- Do not recommend
@MainActoras a blanket fix. Justify why the code is truly UI-bound. - Prefer structured concurrency over unstructured tasks. Use
Task.detachedonly with a clear reason. - If recommending
@preconcurrency,@unchecked Sendable, ornonisolated(unsafe), require a documented safety invariant and a follow-up removal plan. - Optimize for the smallest safe change. Do not refactor unrelated architecture during migration.
- Course references are for deeper learning only. Use them sparingly and only when they clearly help answer the developer's question.
Quick Fix Mode
Use Quick Fix Mode when all of these are true:
- The issue is localized to one file or one type.
- The isolation boundary is clear.
- The fix can be explained in 1-2 behavior-preserving steps.
Skip Quick Fix Mode when any of these are true:
- Build settings or default isolation are unknown.
- The issue crosses module boundaries or changes public API behavior.
- The likely fix depends on unsafe escape hatches.
Common Diagnostics
| Diagnostic | First check | Smallest safe fix | Escalate to |
|---|---|---|---|
| Main actor-isolated ... cannot be used from a nonisolated context | Is this truly UI-bound? | Isolate the caller to @MainActor or use await MainActor.run { ... } only when main-actor ownership is correct. | references/actors.md, references/threading.md |
| Actor-isolated type does not conform to protocol | Must the requirement run on the actor? | Prefer isolated conformance (e.g., extension Foo: @MainActor SomeProtocol); use nonisolated only for truly nonisolated requirements. | references/actors.md |
| Sending value of non-Sendable type ... risks causing data races | What isolation boundary is being crossed? | Keep access inside one actor, or convert the transferred value to an immutable/value type. | references/sendable.md, references/threading.md |
| SwiftLint async_without_await | Is async actually required by protocol, override, or @concurrent? | Remove async, or use a narrow suppression with rationale. Never add fake awaits. | references/linting.md |
| wait(...) is unavailable from asynchronous contexts | Is this legacy XCTest async waiting? | Replace with await fulfillment(of:) or Swift Testing equivalents. | references/testing.md |
| Core Data concurrency warnings | Are NSManagedObject instances crossing contexts or actors? | Pass NSManagedObjectID or map to a Sendable value type. | references/core-data.md |
| @Observable isolation or Sendable errors | Is the @Observable class annotated with the correct actor? | Add @MainActor for UI state; pass Sendable snapshots across boundaries. | references/observation.md |
| Thread.current unavailable from asynchronous contexts | Are you debugging by thread instead of isolation? | Reason in terms of isolation and use Instruments/debugger instead. | references/threading.md |
| SwiftLint concurrency-related warnings | Which specific lint rule triggered? | Use references/linting.md for rule intent and preferred fixes; avoid dummy awaits. | references/linting.md |
| ... cannot satisfy conformance requirement for a 'Sendable' type parameter (SendableMetatype) | Does the conformance carry global-actor isolation? | Remove actor isolation from the conformance, or avoid passing the metatype across isolation boundaries. See SendableMetatype section in references/actors.md. | references/actors.md |
When Quick Fixes Fail
- Gather project settings if not already confirmed.
- Re-evaluate which isolation boundaries the type crosses.
- Route to the matching reference file for a deeper fix.
- If the fix may change behavior, document the invariant and add verification steps.
Smallest Safe Fixes
Prefer changes that preserve behavior while satisfying data-race safety:
- UI-bound state: isolate the type or member to
@MainActor. - Shared mutable state: move it behind an
actor, or use@MainActoronly if the state is UI-owned. - Background work: when work must hop off caller isolation, use an
asyncAPI marked@concurrent; when work can safely inherit caller isolation, usenonisolatedwithout@concurrent. When spawning aTask, match entry isolation to its synchronous prefix. If nothing before the firstawaitneeds the main actor, useTask { @concurrent in ... }and hop back viaawait MainActor.run { ... }for the UI update. If the prefix mixes a trivial non-main statement with main-actor work, keep the inherited@MainActorstartβsplitting the cheap line off-main is not worth an extra hop. - Sendability issues: prefer immutable values and explicit boundaries over
@unchecked Sendable.
Concurrency Tool Selection
| 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 |
Common Scenarios
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)
}
}
Task entry isolation
Match a Task's entry isolation to its synchronous prefix (everything from { to the first await).
- If anything in that prefix needs
@MainActor, keep the inherited@MainActorstart. - If nothing in that prefix needs
@MainActor, preferTask { @concurrent in ... }and hop back only for UI-owned mutation.
// β Synchronous prefix is empty; first work hops away
Task {
await hopToOtherIsolationDomain()
}
// β Synchronous prefix is only `print` (trivial, non-main); first await hops away
Task {
print("Also not main-thread-bound")
await hopToOtherIsolationDomain()
}
// β
Start off the main actor, hop back only for UI work
Task { @concurrent in
await hopToOtherIsolationDomain()
await MainActor.run { updateUI() }
}
// β
Synchronous prefix DOES contain main-actor work β keep inheritance
Task {
print("debug") // trivial, non-main β rides along
self.isLoading = true // needs @MainActor, before any await
await fetchData()
}
Swift 6 Migration Quick Guide
Key changes in Swift 6:
- Strict concurrency checking enabled by default
- Complete data-race safety at compile time
- Sendable requirements enforced on boundaries
- Isolation checking for all async boundaries
Migration Validation Loop
Apply this cycle for each migration change:
- Build β Run
swift buildor Xcode build to surface new diagnostics - Fix β Address one category of error at a time (e.g., all Sendable issues first)
- Rebuild β Confirm the fix compiles cleanly before moving on
- Test β Run the test suite to catch regressions (
swift testor Cmd+U) - Only proceed to the next file/module when all diagnostics are resolved
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.
Reference Router
Open the smallest reference that matches the question:
- Foundations
references/async-await-basics.mdβ async/await syntax, execution order, async let, URLSession patternsreferences/tasks.mdβ Task lifecycle, cancellation, priorities, task groups, structured vs unstructuredreferences/actors.mdβ Actor isolation, @MainActor, global actors, reentrancy, custom executors, Mutexreferences/sendable.mdβ Sendable conformance, value/reference types, @unchecked, region isolationreferences/threading.mdβ Execution model, suspension points, Swift 6.2 isolation behavior
- Streams
references/async-sequences.mdβ AsyncSequence, AsyncStream, when to use vs regular async methodsreferences/async-algorithms.mdβ Debounce, throttle, merge, combineLatest, channels, timers
- Applied topics
references/testing.mdβ Swift Testing first, XCTest fallback, leak checksreferences/performance.mdβ Profiling with Instruments, reducing suspension points, execution strategiesreferences/memory-management.mdβ Retain cycles in tasks, memory safety patternsreferences/core-data.mdβ NSManagedObject sendability, custom executors, isolation conflictsreferences/observation.mdβ @Observable with @MainActor, cross-isolation access, Sendable constraints
- Migration and tooling
references/migration.mdβ Swift 6 migration strategy, closure-to-async conversion, @preconcurrency, FRP migrationreferences/linting.mdβ Concurrency-focused lint rules and SwiftLintasync_without_await
- Glossary
references/glossary.mdβ Quick definitions of core concurrency terms
Verification Checklist
When changing concurre
Truncated for display β read the full file on GitHub.
Related Skills
taste-skill
116.8kAgent skills that give coding agents taste: art direction, reference images and a browser check instead of generic AI pages
ai-job-search
72.1kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
claude-howto
47.3kA visual, example-driven guide to Claude Code β from basic concepts to advanced agents, with copy-paste templates that bring immediate value.
lobehub
85.6kπ€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit β see the Safety scan above for what the skill file itself contains.
