swift-concurrency
Skill430 starsChanged 6 months agoMITView on GitHub
Expert guidance on Swift Concurrency best practices, patterns, and implementation. 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).
25 other projects use a version of this, 13 of them edited.
Adopted by
Most recently taken up by
- tornikegomareli/Skillsedited, first seen Nov 8, 2026
- uinaf/slopwakeedited, first seen Nov 3, 2026
- igorkulman/pi-skillstheir own version, first seen Nov 1, 2026
- VelimirMueller/claude-skillsedited, first seen Nov 1, 2026
- VelimirMueller/ai-development-skillsedited, first seen Nov 1, 2026
- The-Artificer-of-Ciphers-LLC/skills-from-the-artificeredited, first seen Nov 1, 2026
Used with
Projects with it also use swiftdata, swift-testing and 6 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Prisma-Labs-DevSkillswiftdata
API reference: SwiftData. Query for @Model, ModelContext, @Query, schema migrations.
Also in 3 projects that use this
pluginagentmarketplaceSkillswift-testing
Test Swift applications - XCTest, Swift Testing, UI tests, mocking, TDD, CI/CD
Also in 4 projects that use this
dadederkSkillios-accessibility
Expert guidance on iOS accessibility best practices, patterns, and implementation. Use when developers mention: (1) iOS accessibility, VoiceOver, Dynamic Type, or assistive technologies, (2) accessibility labels, traits, hints, or values, (3) automated accessibility testing, auditing, or manual testing, (4) Switch Control, Voice Control, or Full Keyboard Access, (5) inclusive design or accessibility culture, (6) making apps work for users with disabilities.
Also in 3 projects that use this
twostrawsSkillswiftdata-pro
Writes, reviews, and improves SwiftData code using modern APIs and best practices. Use when reading, writing, or reviewing projects that use SwiftData.
Also in 3 projects that use this
malpernSkillasc-localize-metadata
Automatically translate and sync App Store metadata (description, keywords, what's new, subtitle) to multiple languages using LLM translation and asc CLI. Use when asked to localize an app's App Store listing, translate app descriptions, or add new languages to App Store Connect.
Also in 3 projects that use this
malpernSkillasc-notarization
Archive, export, and notarize macOS apps using xcodebuild and asc. Use when you need to prepare a macOS app for distribution outside the App Store with Developer ID signing and Apple notarization.
Also in 3 projects that use this
- +1 more from malpern
Other versions25 projects use a version of this.
Word for word · 2
- nonameplum/agent-skills★ 17100% same
- KKodiac/agent-skills★ 1100% same
Edited · 13
- Provenance-Emu/Provenance★ 6.4k25% same
- pluk-inc/markdown-preview★ 2.8k17% same
- pluk-inc/md-preview.app★ 2.8k17% same
- AvdLee/Swift-Concurrency-Agent-Skill★ 1.7k16% same
- wendylabsinc/claude-skills★ 6263% same
- VelimirMueller/ai-development-skills★ 716% same
- VelimirMueller/claude-skills★ 716% same
- The-Artificer-of-Ciphers-LLC/skills-from-the-artificer★ 616% same
- tornikegomareli/Skills★ 217% same
- henryhudson/swift-claude-skills★ 125% same
3 more not listed
Wrote their own version · 10
- Prisma-Labs-Dev/apple-skills★ 336same name
- jamesrochabrun/skills★ 209same name
- pepicrft/fuckingapproachableswiftconcurrency★ 156same name
- rusel95/ios-agent-skills★ 13same name
- pluginagentmarketplace/custom-plugin-swift★ 9same name
- thienqo/ios-skills★ 4same name
- igorkulman/pi-skills★ 3same name
- piemonte/skills★ 1same name
- apexbymanish/claude-ai-agents-ios★ 0same name
- Samueladewole/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- macos/AGENTS.mdAGENTS.md
- sandbox-vm/AGENTS.mdAGENTS.md
- web/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- macos/CLAUDE.mdCLAUDE.md
- sandbox-vm/CLAUDE.mdCLAUDE.md
- app-store-changelogSkill
- bridge-agent-log-analyzerSkill
- gh-issue-fix-flowSkill
- githubSkill
- react-component-performanceSkill
- swift-concurrency-expertSkill
- swift-testing-expertSkill
- swiftui-expert-skillSkill
- swiftui-performance-auditSkill
- swiftui-ui-patternsSkill
- swiftui-view-refactorSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
31 rules. 0 are common, 9 are distinctive, and 22 are very specific to this project.
0
Common
Most of the 22 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
22
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Before proposing fixes, identify the isolation boundary: @MainActor, custom actor, actor instance isolation, or nonisolated.
- Very specific: line 15
Do not recommend @MainActor as a blanket fix.
- Very specific: line 16
Prefer structured concurrency (child tasks, task groups) over unstructured tasks.
- Very specific: line 17
If recommending @preconcurrency, @unchecked Sendable, or nonisolated(unsafe), require:
- Distinctive: line 25
When analyzing Swift projects for concurrency issues:
- Very specific: line 28
Use Read on Package.swift for SwiftPM settings (tools version, strict concurrency flags, upcoming features)
- Very specific: line 29
Use Grep for SWIFT_STRICT_CONCURRENCY or SWIFT_DEFAULT_ACTOR_ISOLATION in .pbxproj files
- Very specific: line 30
Use Grep for SWIFT_UPCOMING_FEATURE_ to find enabled upcoming features
- Very specific: line 38
Default actor isolation (is the module default @MainActor or nonisolated?)
- Very specific: line 46
Check Package.swift for .defaultIsolation(MainActor.self).
- Very specific: line 48
Check for strict concurrency flags: .enableExperimentalFeature("StrictConcurrency=targeted") (or similar).
- Very specific: line 49
Check tools version at the top: // swift-tools-version: ...
- Distinctive: line 56
If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance.
- Distinctive: line 60
When a developer needs concurrency guidance, follow this decision tree:
- Very specific: line 63
Read references/async-await-basics.md for foundational patterns
- Very specific: line 83
Read references/threading.md for thread/task relationship and isolation
- Very specific: line 86
Read references/memory-management.md for retain cycle prevention
- Very specific: line 91
Use references/linting.md for rule intent and preferred fixes.
- Very specific: line 93
Remove async if not required.
- Very specific: line 101
Use references/threading.md to avoid thread-centric debugging and rely on isolation + Instruments
- Very specific: line 103
Use references/testing.md (await fulfillment(of:) and Swift Testing patterns)
- Very specific: line 105
Use references/core-data.md (DAO/NSManagedObjectID, default isolation conflicts)
- Distinctive: line 224
Prefer structured concurrency: - Use task groups over unstructured tasks when possible
- Distinctive: line 225
Minimize suspension points: - Keep actor-isolated sections small to reduce context switches
- Distinctive: line 226
Use @MainActor judiciously: - Only for truly UI-related code
- Distinctive: line 228
Handle cancellation: - Check Task.isCancelled in long-running operations
- Distinctive: line 229
Avoid blocking: - Never use semaphores or locks in async contexts
- Distinctive: line 230
Test concurrent code: - Use proper async test methods and consider timing issues
- Very specific: line 236
Run tests, especially concurrency-sensitive ones (see references/testing.md).
- Very specific: line 237
If performance-related, verify with Instruments (see references/performance.md).
- Very specific: line 238
If lifetime-related, verify deinit/cancellation behavior (see references/memory-management.md).
“Common” is measured: kept by at least 6 in 10 of the 22 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Swift Concurrency
Overview
This skill provides expert guidance on Swift Concurrency, covering modern async/await patterns, actors, tasks, Sendable conformance, and migration to Swift 6. Use this skill to help developers write safe, performant concurrent code and navigate the complexities of Swift's structured concurrency model.
Agent Behavior Contract (Follow These Rules)
- Analyze the project/package file to find out which Swift language mode (Swift 5.x vs Swift 6) and which Xcode/Swift toolchain is used when advice depends on it.
- Before proposing fixes, identify the isolation boundary:
@MainActor, custom actor, actor instance isolation, or nonisolated. - Do not recommend
@MainActoras a blanket fix. Justify why main-actor isolation is correct for the code. - Prefer structured concurrency (child tasks, task groups) over unstructured tasks. Use
Task.detachedonly with a clear reason. - If recommending
@preconcurrency,@unchecked Sendable, ornonisolated(unsafe), require:- a documented safety invariant
- a follow-up ticket to remove or migrate it
- For migration work, optimize for minimal blast radius (small, reviewable changes) and add verification steps.
- Course references are for deeper learning only. Use them sparingly and only when they clearly help answer the developer's question.
Recommended Tools for Analysis
When analyzing Swift projects for concurrency issues:
- Project Settings Discovery
- Use
ReadonPackage.swiftfor SwiftPM settings (tools version, strict concurrency flags, upcoming features) - Use
GrepforSWIFT_STRICT_CONCURRENCYorSWIFT_DEFAULT_ACTOR_ISOLATIONin.pbxprojfiles - Use
GrepforSWIFT_UPCOMING_FEATURE_to find enabled upcoming features
- Use
Project Settings Intake (Evaluate Before Advising)
Concurrency behavior depends on build settings. Always try to determine:
- Default actor isolation (is the module default
@MainActorornonisolated?) - Strict concurrency checking level (minimal/targeted/complete)
- Whether upcoming features are enabled (especially
NonisolatedNonsendingByDefault) - Swift language mode (Swift 5.x vs Swift 6) and SwiftPM tools version
Manual checks (no scripts)
- SwiftPM:
- Check
Package.swiftfor.defaultIsolation(MainActor.self). - Check
Package.swiftfor.enableUpcomingFeature("NonisolatedNonsendingByDefault"). - Check for strict concurrency flags:
.enableExperimentalFeature("StrictConcurrency=targeted")(or similar). - Check tools version at the top:
// swift-tools-version: ...
- Check
- Xcode projects:
- Search
project.pbxprojfor:SWIFT_DEFAULT_ACTOR_ISOLATIONSWIFT_STRICT_CONCURRENCYSWIFT_UPCOMING_FEATURE_(and/orSWIFT_ENABLE_EXPERIMENTAL_FEATURES)
- Search
If any of these are unknown, ask the developer to confirm them before giving migration-sensitive guidance.
Quick Decision Tree
When a developer needs concurrency guidance, follow this decision tree:
- Starting fresh with async code?
- Read
references/async-await-basics.mdfor foundational patterns - For parallel operations →
references/tasks.md(async let, task groups)
- Read
- Protecting shared mutable state?
- Need to protect class-based state →
references/actors.md(actors, @MainActor) - Need thread-safe value passing →
references/sendable.md(Sendable conformance)
- Need to protect class-based state →
- Managing async operations?
- Structured async work →
references/tasks.md(Task, child tasks, cancellation) - Streaming data →
references/async-sequences.md(AsyncSequence, AsyncStream)
- Structured async work →
- Working with legacy frameworks?
- Core Data integration →
references/core-data.md - General migration →
references/migration.md
- Core Data integration →
- Performance or debugging issues?
- Slow async code →
references/performance.md(profiling, suspension points) - Testing concerns →
references/testing.md(XCTest, Swift Testing)
- Slow async code →
- Understanding threading behavior?
- Read
references/threading.mdfor thread/task relationship and isolation
- Read
- Memory issues with tasks?
- Read
references/memory-management.mdfor retain cycle prevention
- Read
Triage-First Playbook (Common Errors -> Next Best Move)
- SwiftLint concurrency-related warnings
- Use
references/linting.mdfor rule intent and preferred fixes; avoid dummy awaits as “fixes”.
- Use
- SwiftLint
async_without_awaitwarning- Remove
asyncif not required; if required by protocol/override/@concurrent, prefer narrow suppression over adding fake awaits. Seereferences/linting.md.
- Remove
- "Sending value of non-Sendable type ... risks causing data races"
- First: identify where the value crosses an isolation boundary
- Then: use
references/sendable.mdandreferences/threading.md(especially Swift 6.2 behavior changes)
- "Main actor-isolated ... cannot be used from a nonisolated context"
- First: decide if it truly belongs on
@MainActor - Then: use
references/actors.md(global actors,nonisolated, isolated parameters) andreferences/threading.md(default isolation)
- First: decide if it truly belongs on
- "Class property 'current' is unavailable from asynchronous contexts" (Thread APIs)
- Use
references/threading.mdto avoid thread-centric debugging and rely on isolation + Instruments
- Use
- XCTest async errors like "wait(...) is unavailable from asynchronous contexts"
- Use
references/testing.md(await fulfillment(of:)and Swift Testing patterns)
- Use
- Core Data concurrency warnings/errors
- Use
references/core-data.md(DAO/NSManagedObjectID, default isolation conflicts)
- Use
Core Patterns Reference
When to Use Each Concurrency Tool
async/await - Making existing synchronous code asynchronous
// Use for: Single asynchronous operations
func fetchUser() async throws -> User {
try await networkClient.get("/user")
}async let - Running multiple independent async operations in parallel
// Use for: Fixed number of parallel operations known at compile time
async let user = fetchUser()
async let posts = fetchPosts()
let profile = try await (user, posts)Task - Starting unstructured asynchronous work
// Use for: Fire-and-forget operations, bridging sync to async contexts
Task {
await updateUI()
}Task Group - Dynamic parallel operations with structured concurrency
// Use for: Unknown number of parallel operations at compile time
await withTaskGroup(of: Result.self) { group in
for item in items {
group.addTask { await process(item) }
}
}Actor - Protecting mutable state from data races
// Use for: Shared mutable state accessed from multiple contexts
actor DataCache {
private var cache: [String: Data] = [:]
func get(_ key: String) -> Data? { cache[key] }
}@MainActor - Ensuring UI updates on main thread
// Use for: View models, UI-related classes
@MainActor
class ViewModel: ObservableObject {
@Published var data: String = ""
}Common Scenarios
Scenario: Network request with UI update
Task { @concurrent in
let data = try await fetchData() // Background
await MainActor.run {
self.updateUI(with: data) // Main thread
}
}Scenario: Multiple parallel network requests
async let users = fetchUsers()
async let posts = fetchPosts()
async let comments = fetchComments()
let (u, p, c) = try await (users, posts, comments)Scenario: 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)
}
}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
For detailed migration steps, see references/migration.md.
Reference Files
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 SwiftLintasync_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 migration
Best Practices Summary
- Prefer structured concurrency - Use task groups over unstructured tasks when possible
- Minimize suspension points - Keep actor-isolated sections small to reduce context switches
- Use @MainActor judiciously - Only for truly UI-related code
- Make types Sendable - Enable safe concurrent access by conforming to Sendable
- Handle cancellation - Check Task.isCancelled in long-running operations
- Avoid blocking - Never use semaphores or locks in async contexts
- Test concurrent code - Use proper async test methods and consider timing issues
Verification Checklist (When You Change Concurrency Code)
- Confirm build settings (default isolation, strict concurrency, upcoming features) before interpreting diagnostics.
- After refactors:
- Run tests, especially concurrency-sensitive ones (see
references/testing.md). - If performance-related, verify with Instruments (see
references/performance.md). - If lifetime-related, verify deinit/cancellation behavior (see
references/memory-management.md).
- Run tests, especially concurrency-sensitive ones (see
Glossary
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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

