swift-concurrency
Skill0 starsChanged 3 months agoMITView on GitHub
Procedure for reviewing real Swift code for concurrency correctness — async/await, actors, Sendable, cancellation, task lifetime — not a Swift Concurrency tutorial. Use when the task involves async/await, Task, actors, MainActor, Sendable, or a data-race/concurrency question like "is this thread-safe?".
25 other projects use a version of this.
Adopted by
Most recently taken up by
- tornikegomareli/Skillstheir own version, first seen Nov 8, 2026
- uinaf/slopwaketheir own version, first seen Nov 3, 2026
- igorkulman/pi-skillstheir own version, first seen Nov 1, 2026
- VelimirMueller/claude-skillstheir own version, first seen Nov 1, 2026
- VelimirMueller/ai-development-skillstheir own version, first seen Nov 1, 2026
- The-Artificer-of-Ciphers-LLC/skills-from-the-artificertheir own version, first seen Nov 1, 2026
Used with
Projects with it also use swiftdata, swift-testing and 9 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
xfstudioSkillswiftui-expert-skill
Write, review, or improve SwiftUI code following best practices for state management, view composition, performance, modern APIs, Swift concurrency, and iOS 26+ Liquid Glass adoption. Use when building new SwiftUI features, refactoring existing views, reviewing code quality, or adopting modern SwiftUI patterns.
Also in 8 projects that use this
eugenepyvovarovSkillswift-concurrency-expert
Swift Concurrency review and remediation for Swift 6.2+. Use when asked to review Swift Concurrency usage, improve concurrency compliance, or fix Swift concurrency compiler errors in a feature or file.
Also in 4 projects that use this
AvdLeeSkillswift-testing-expert
Expert 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.
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
Other versions25 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 25
- Provenance-Emu/Provenance★ 6.4ksame name
- pluk-inc/markdown-preview★ 2.8ksame name
- pluk-inc/md-preview.app★ 2.8ksame name
- AvdLee/Swift-Concurrency-Agent-Skill★ 1.7ksame name
- AFK-surf/OpenBridge★ 430same name
- Prisma-Labs-Dev/apple-skills★ 336same name
- jamesrochabrun/skills★ 209same name
- pepicrft/fuckingapproachableswiftconcurrency★ 156same name
- wendylabsinc/claude-skills★ 62same name
- nonameplum/agent-skills★ 17same name
15 more not listed
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 repository10 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 4 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 24 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 28
If ios-agent MCP is configured, mcp__ios-agent__review_swift_concurrency alongside the manual read — STATIC_ANALYSIS tier, same as reading …
- Distinctive: line 71
Read the actual code — never assess concurrency from a description of it.
- Very specific: line 73
Check which detection patterns above apply.
- Distinctive: line 78
If the question is "is this thread-safe," don't answer yes/no from this reading alone — see Evidence Requirements.
- Distinctive: line 80
If Swift 6 / strict concurrency mode isn't enabled, say so — it's the single highest-leverage recommendation available, since it turns …
- Very specific: line 137
Never say "thread-safe" from this skill's static read alone — STATIC_ANALYSIS plus a concurrency-relevant test or Swift 6 strict-mode build …
- Distinctive: line 140
Never say a data race "does not exist" — say "no data-race pattern found during static inspection."
- Very specific: line 142
Never claim @unchecked Sendable usage is "safe" without stating the specific invariant that makes it safe (e.g.
“Common” is measured: kept by at least 6 in 10 of the 24 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
Purpose
Review real project code for concurrency correctness, and grade every finding at the evidence tier it actually earned — never assert "thread-safe" from reading code alone.
When to Use
Any task touching async/await, Task, actors, @MainActor,
Sendable, or a direct question about thread safety, data races, or
cancellation behavior.
Inputs
- The actual code under review — read it, don't reason about concurrency in the abstract.
- Whether the project has Swift 6 language mode (or
-strict-concurrency=completeunder Swift 5) enabled — this changes what the compiler itself can prove vs. what only a careful read can flag. - If
ios-agentMCP is configured,mcp__ios-agent__review_swift_concurrencyalongside the manual read —STATIC_ANALYSIStier, same as reading the code, never higher (perios-evidence-reporting's tool-tier rule).
Core Knowledge
- Structured vs. unstructured concurrency:
async letand task groups tie a child task's lifetime to its parent's scope — the parent can't return until children finish or are cancelled. UnstructuredTask {}has no such guarantee; it keeps running independent of whoever created it unless something explicitly cancels it. @MainActorisolation: UI-touching state needs main-actor isolation.@Observable/ObservableObjecttypes get no isolation for free — annotate the type (or the specific properties/methods that need it) explicitly.Sendable: a type crossing an isolation boundary (passed into aTask, an actor method, or another isolation domain) needs to be safe to do so — genuinely immutable, internally synchronized, or a value type with no shared mutable state.- Actor reentrancy: an actor method that
awaits can be re-entered by another call to the same actor during the suspension — actors are not a mutex. State checked before anawaitis not guaranteed to still hold after it resumes. - Cancellation is cooperative: calling
.cancel()on aTasksets a flag; it does not stop execution. Code has to actually checkTask.isCancelledor calltry Task.checkCancellation()to respond.
Detection Patterns
| Pattern | Risk | Detect by |
Unstructured Task {} in onAppear/init/button action, never stored or cancelled | Outlives the view; can touch deallocated state or double-fire on re-render | grep for Task { inside SwiftUI lifecycle hooks/actions with no stored handle and no .task {} alternative used |
| Long-running loop with no cancellation check | .cancel() does nothing — work keeps running after the caller gave up | grep for/while loops inside async functions for absence of Task.isCancelled/checkCancellation |
View-model type read/written from both SwiftUI and a background task, not @MainActor | Data race on non-Sendable state; Swift 6 refuses to compile, Swift 5 may silently corrupt | Check whether types backing SwiftUI views carry @MainActor; check whether Swift 6 mode is even enabled to catch this at all |
@unchecked Sendable / nonisolated(unsafe) | Manually disables the compiler's only mechanical safety net for this type — a real race risk hiding behind a suppression | grep for both exact terms |
Task.detached used out of habit | Loses the calling actor's isolation, priority, and task-local values (e.g. a request ID for logging) for no deliberate reason | grep Task.detached; check whether escaping context was actually intentional |
Continuation (withCheckedContinuation) resumed on more than one path, or not on all paths | Double-resume crashes at runtime; missed resume hangs the awaiting task forever | Trace every exit path (success, error, early return) out of the continuation closure |
State read before an await inside an actor method, relied on unchanged after it resumes | Actor reentrancy — another call can interleave during the suspension and change that state | Look for a state read, then an await, then logic that trusts the pre-await value without re-checking |
Task stored as a property, never cancelled in deinit/equivalent | Wastes resources or touches a gone context indefinitely | Check every stored Task property has a matching cancel; prefer .task {} for SwiftUI, which handles this automatically |
Procedure
- Read the actual code — never assess concurrency from a description of it.
- Check which detection patterns above apply; for each hit, read
enough surrounding code to confirm it's real, not a false positive
(e.g. a
Task.detachedthat's genuinely meant to escape context). - For each real finding, state: the pattern, the risk, and the concrete fix — a code diff, not a description of one.
- If the question is "is this thread-safe," don't answer yes/no from this reading alone — see Evidence Requirements.
- If Swift 6 / strict concurrency mode isn't enabled, say so — it's the single highest-leverage recommendation available, since it turns several of these patterns into compile errors instead of silent bugs.
Common Mistakes
- Treating "no data race pattern found by reading" as "this is thread-safe" — a static read can't see the actual concurrent interleaving.
- Suggesting
@unchecked Sendableas a quick fix for a compiler warning instead of understanding what the warning is protecting against. - Recommending
Task.detachedas the default for "fire and forget" work — plainTask {}is almost always the right default.
Verification
- A pattern match from step 2 above is
STATIC_ANALYSIS. - Confirming the compiler rejects a violation under Swift 6 strict
mode is
BUILD_VERIFIED— genuinely stronger evidence than a manual read, since the compiler is checking every path, not just the ones read. - A concurrency-relevant test (e.g. asserting a task actually stops
after cancellation, or a continuation resumes exactly once across
its tested paths) is
TEST_VERIFIED. - Actual concurrent behavior observed under Thread Sanitizer or in a
real run is
RUNTIME_VERIFIED.
Evidence Requirements
Per ios-evidence-reporting's matrix, "thread-safe" specifically
requires STATIC_ANALYSIS and a concurrency-relevant test or Swift 6
strict-mode compilation — never inspection alone. Grade every finding
honestly:
Claim:
"Task cancellation is handled correctly."
Static:
Cancellation path inspected — Task.isCancelled checked at the loop
boundary in FeedLoader.swift:88.
Tests:
No test currently exercises cancellation.
Runtime:
Not observed.
Final:
PARTIALLY VERIFIED — STATIC_ANALYSIS only. Recommend a test that
cancels mid-loop and asserts the loop actually stops.Claim Restrictions
- Never say "thread-safe" from this skill's static read alone —
STATIC_ANALYSISplus a concurrency-relevant test or Swift 6 strict-mode build is the minimum. - Never say a data race "does not exist" — say "no data-race pattern found during static inspection."
- Never claim
@unchecked Sendableusage is "safe" without stating the specific invariant that makes it safe (e.g. "immutable afterinit") — an unjustified suppression is itself a finding to report, not a claim to validate.
Output Format
One finding per issue: pattern name, file:line, risk, concrete fix (a
diff, not prose), and the evidence tier the finding itself is graded
at. Close with the ios-evidence-reporting status block.
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.

